The named-advice
block contains all the fields that make up a strategy. Developers can provide up to 5 different pieces of advice in a given strategy through individual named-advice
blocks. Each of these blocks requires a unique ID.
selection-strategy {
id (prefer-price)
match {
RideShare (this)
}
// This named advice will always advise-for a value.
// Since advice-for is set to lowerBoundOpen 0.0, any price will match.
named-advice ("price") {
advice("${this.priceRange.min.value}")
advise-for { lowerBoundOpen(0.0) }
}
}
You can also use simplified syntax with selection-strategy
to handle common filtering by combining both the advice
with the advice-for
or advice-against
keys.
selection-strategy {
id (reject-bitcoin-payment-restaurants)
match {
food.AcceptsBitcoin(acceptsBitcoin) {
to-input: food.FindRestaurant(_)
}
}
advise-against ("${acceptsBitcoin}”)
}
selection-strategy {
id (prefer-thai-restaurants)
match {
food.CuisineStyle(style) {
to-input: food.FindRestaurant(_)
}
}
advise-for ("${style == ‘Thai’}”)
}
For more information about named-advice, see Selection Strategies.
advice optional | Specify a statement to test in the named-advice block |
advise-against optional | The range of scores indicating that this strategy is bad, aka AGAINST |
advise-for optional | The range of scores indicating that this strategy is good, aka FOR |
with-value-at optional | Specify a property to use for a memorization strategy |