O'Reilly logo

Programming Game AI by Example by Mat Buckland

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

Chapter 9 Goal-Driven Agent Behavior .....................379
The Return of Eric the Brave ...............................380
Implementation ......................................382
Goal_Composite::ProcessSubgoals ........................385
Goal_Composite::RemoveAllSubgoals ......................386
Examples of Goals Used by Raven Bots .........................387
Goal_Wander ...................................387
Goal_TraverseEdge ................................388
Goal_FollowPath .................................391
Goal_MoveToPosition ...............................393
Goal_AttackTarget.................................395
Goal Arbitration......................................398
Calculating the Desirability of Locating a Health Item ..............400
Calculating the Desirability of Locating a Specific Weapon............401
Calculating the Desirability of Attacking the Target................403
Calculating the Desirability of Exploring the Map ................403
Putting It All Together ...............................404
Spin-offs .........................................405
Personalities ....................................405
State Memory ...................................406
Example One — Automatic Resuming of Interrupted Activities......407
Example Two — Negotiating Special Path Obstacles ...........408
Command Queuing ................................410
Using the Queue to Script Behavior ........................412
Summing Up .......................................414
Chapter 10 Fuzzy Logic .............................415
Crisp Sets .........................................417
Set Operators ...................................418
Fuzzy Sets.........................................419
Defining Fuzzy Boundaries with Membership Functions .............419
Fuzzy Set Operators ................................421
Hedges .......................................423
Fuzzy Linguistic Variables ................................423
Fuzzy Rules ........................................424
Designing FLVs for Weapon Selection ......................425
Designing the Desirability FLV.......................426
Designing the Distance to Target FLV ...................427
Designing the Ammo Status FLV......................428
Designing the Rule Set for Weapon Selection ...................428
Fuzzy Inference ..................................429
Rule One ..................................429
Rule Two ..................................430
Rule Three .................................430
Defuzzification ...............................433
From Theory to Application: Coding a Fuzzy Logic Module ..............437
The FuzzyModule Class ..............................437
The FuzzySet Base Class .............................439
The Triangular Fuzzy Set Class ..........................440
The Right Shoulder Fuzzy Set Class........................441
x | Contents
Creating a Fuzzy Linguistic Variable Class ....................443
Designing Classes for Building Fuzzy Rules ...................445
How Raven Uses the Fuzzy Logic Classes ........................451
The Combs Method ....................................452
Fuzzy Inference and the Combs Method......................454
Implementation ..................................455
Summing Up .......................................455
Last Words ............................................457
Appendix A C++ Templates ..........................459
Appendix B UML Class Diagrams ........................465
Appendix C Setting Up Your Development Environment .............475
References ............................................477
Bugs and Errata .........................................479
Index ...............................................481
Contents | xi
This page intentionally left blank.

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