there are two basic or common way to make decision using utility, firstis called absolute utility and the second is relative utility. absolute utility is a simply evaluates each option and takes the on e with the most score, unlike the relative utility selects an option at random but use the score of each option to define the probabil;ity that it will be selected.
the approach is referred to as weight based random and is implemented as follow;
- add up the total weight of all valid options.
- pick a random number between 0 and the total weight from step to step.
- going through the valid options one at a time and reduce the random number by the weight for each option, if your result is less than or equal to zero, pick this option.
relative and absolute utilities each have merit and demerit, absolute utilty is but when you want to ensure that the ai always takes takes the most appropriate action available. unfortunately this can become predictable given a predictability of absolute utility picking at random it ensures a certain amount of variation still giving perference to the most appropriate choices.
the combines absolute and relative untilities into a synergistic whole avoiding the weekness of both together and is also more flexible and expressive for the game designers. the idea is that rather assigning a single utility value to each option, we assign to rank and weight.
Finally, we use weight-based random to select from among those options that remain. Once again, the four steps are as follows:
- Eliminate the options with a weight of zero.
- Find the highest rank category, and eliminate options that don’t belong to it.
- Find the best remaining option (i.e., the one with the highest weight), and eliminate options that are much worse (i.e., much lower weight) than it.
- Use weight-based random to select from the options that remain.
Once this is done, we can use relative utility to pick from among the options within the best category in a random but reasonable way.