O'Reilly logo

Behavioral Mathematics for Game AI by Dave Mark

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selecting an Option

At the end of ScoreAllTargets(), we have a list of all the possible attack combinations. Selecting an option is a simple exercise at this point. Because we built our scoring algorithm so that the lower the value, the better the option, we can logically deduce that the target with the lowest score is the best option for us to select. We can sort mvTargets of targets by the Score value so that the lowest value is at the beginning of the vector. (Naturally, we could simply walk the list and make a note of the lowest-scored item. I sort it here because doing so will come in handy in Chapter 16.) We then set our target and weapon to the values held in that location. The entire function for selecting a target is:

 CDude* CAgent::SelectTarget() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required