cs 680 game ai
play

CS 680: GAME AI WEEK 4: DECISION MAKING IN RTS GAMES 2/6/2012 - PowerPoint PPT Presentation

CS 680: GAME AI WEEK 4: DECISION MAKING IN RTS GAMES 2/6/2012 Santiago Ontan santi@cs.drexel.edu https://www.cs.drexel.edu/~santi/teaching/2012/CS680/intro.html Reminders Projects: Project 1 is simpler than it seems: 1)


  1. CS 680: GAME AI WEEK 4: DECISION MAKING IN RTS GAMES 2/6/2012 Santiago Ontañón santi@cs.drexel.edu https://www.cs.drexel.edu/~santi/teaching/2012/CS680/intro.html

  2. Reminders • Projects: • Project 1 is simpler than it seems: • 1) Implement a basic AI (doesn’t have to play well) • 2) Pick a path-finding/decision making algorithm and experiment with it • Progress self-check indicator: • Your progress is good is you already have a basic AI that can play a complete game of S3/Starcraft (whether it wins or not).

  3. Outline • Student Presentation: “Near Optimal Hierarchical Pathfinding” • Student Presentation: “Intelligent Moving of Groups in Real-Time Strategy Games” • Decision Making • Basics: Hardcoded Methods • Decision Theory • Adversarial Search • Project Discussion

  4. Outline • Student Presentation: “Near Optimal Hierarchical Pathfinding” • Student Presentation: “Intelligent Moving of Groups in Real-Time Strategy Games” • Decision Making • Basics: Hardcoded Methods • Decision Theory • Adversarial Search • Project Discussion

  5. Decision Making • A situation is characterized by: • Known information about the state of the world • Unknown information about the state of the world • Set of possible actions to execute • Problem: • Given a situation, which of the possible actions is the best?

  6. Example: RTS Games • Known information: • Player data, explored terrain • Unknown: • Unexplored terrain • Enemy strategy • Actions: • Build barracks • Build refinery • Build supply depot • Wait • Explore

  7. Example: Final Fantasy VI • Known information: • Party information • Two enemies • Unknown: • Resistances • Attack power • Remaining health • Actions:

  8. Basic RTS AI Diagram Perception Unit Analysis Map Analysis Strategy Strategy Economy Logistics Attack Give Orders Arbiter Unit AI Unit AI Unit AI Execute Orders Building Placer Pathfinder

  9. Basic RTS AI Diagram Decision making is key at these Perception Unit Analysis Map Analysis levels Strategy Strategy Economy Logistics Attack Give Orders Arbiter Unit AI Unit AI Unit AI Execute Orders Building Placer Pathfinder

  10. Basic RTS AI Diagram Perception Unit Analysis Map Analysis And is most important at the high-level strategy level Strategy Strategy Economy Logistics Attack Give Orders Arbiter Unit AI Unit AI Unit AI Execute Orders Building Placer Pathfinder

  11. Example Basic RTS AI: Strategy • Finite-State Machine Resource spending: Resource spending: 80% Economy, After training 20% Economy, 4 footmen 20% Military 80% Military 2 workers wood 2 workers wood 1 worker metal 4 workers metal Army Composition: Army Composition: 100% footmen 100% knights If enemy has no more If enemy has flying units Flying units Army Composition: 50% knights 50% archers

  12. Outline • Student Presentation: “Near Optimal Hierarchical Pathfinding” • Student Presentation: “Intelligent Moving of Groups in Real-Time Strategy Games” • Decision Making • Basics: Hardcoded Methods • Decision Theory • Adversarial Search • Project Discussion

  13. Finite State Machines 4 SCVs barracks harvesting Train Harvest Build marines Minerals Barracks 4 marines & Less 4 marines Enemy 4 SCVs than & unseen No 4 SCVs Enemy seen marines Train SCVs Attack Explore Enemy Enemy seen

  14. Finite State Machines • Easy to implement: switch(state) { case START: if (numSCVs<4) state = TRAIN_SCVs; if (numHarvestingSCVs>=4) state = BUILD_BARRACKS; Unit *SCV = findIdleSCV(); Unit *mineral = findClosestMineral(SCV); SCV->harvest(mineral); break; case TRAIN_SCVs: if (numSCVs>=4) state = START; Unit *base = findIdleBase(); base->train(UnitType::SCV); break; case BUILD_BARRACKS: … }

  15. Basic RTS AI Diagram Perception Unit Analysis Map Analysis 4 SCVs barracks Train Harvest harvesting Build marines Minerals Barracks Strategy/ 4 marines & Less 4 marines Enemy 4 SCVs than & Give unseen No 4 SCVs Enemy seen marines Orders Train SCVs Attack Explore Enemy Enemy seen Unit AI Unit AI Unit AI Execute Orders Building Placer Pathfinder

  16. Basic RTS AI Diagram For Simple games or simple Perception Unit Analysis Map Analysis AIs, we could substitute both Strategy and “Give Orders” layers by a FSM 4 SCVs barracks Train Harvest harvesting Build marines Minerals Barracks Strategy/ 4 marines & Less 4 marines Enemy 4 SCVs than & Give unseen No 4 SCVs Enemy seen marines Orders Train SCVs Attack Explore Enemy Enemy seen Unit AI Unit AI Unit AI Execute Orders Building Placer Pathfinder

  17. Basic RTS AI Diagram For mode complex AIs, FMSs are too restrictive, and it’s Perception Unit Analysis Map Analysis better to use the architecture as we explained it in Week 2 of 4 SCVs class barracks Train Harvest harvesting Build marines Minerals Barracks Strategy/ 4 marines & Less 4 marines Enemy 4 SCVs than & Give unseen No 4 SCVs Enemy seen marines Orders Train SCVs Attack Explore Enemy Enemy seen Unit AI Unit AI Unit AI Execute Orders Building Placer Pathfinder

  18. Finite State Machines • Good for simple AIs • Become unmanageable for complex tasks • Hard to maintain, Example: • Imagine we want to add the behavior • if “enemy inside base” then “attack him with everything we have” • We will have to add a new state and transitions from every other state!

  19. Finite State Machines (Add a new state) 4 SCVs barracks harvesting Train Harvest Build 4 marines Minerals Barracks Enemy Less 4 marines unseen 4 SCVs than & No 4 SCVs Enemy seen marines Train Enemy 4 SCVs Inside Attack Explore Base Enemy Enemy seen Attack Inside Enemy

  20. Hierarchical Finite State Machines • FSM inside of the state of another FSM • As many levels as needed • Can alleviate complexity problem to some extent Enemy Inside Base Attack Standard Inside Strategy Enemy No Enemy Inside Base

  21. Hierarchical Finite State Machines • FSM inside of the state of another FSM • As many levels as needed • Can alleviate complexity problem to some extent Enemy 4 SCVs Inside barracks Train Harvest harvesting Build 4 marines Minerals Barracks Base Attack Enemy Less 4 marines unseen 4 SCVs than & Inside No 4 SCVs Enemy seen Enemy marines Train No Enemy 4 SCVs Attack Inside Explore Enemy Enemy Base seen

  22. Decision Trees • In the FSM examples before, decisions were quite simple: • If “4 SCVs” then “build barracks” • But those conditions can easily become complex • Decision trees offer a way to encode complex decisions in a easy and organized way

  23. Example of Complex Decision • Decide when to attack the enemy in a RTS game, and what kind of units to build • We could try to define a set of rules: • If we have not seen the enemy then build ground units • If we have seen the enemy and he has no air units and we have more units than him, then attack • If we have seen the enemy and he has air units and we do not have air units, then build air units • etc. • Problems: • complex to know if we are missing any scenario, • The conditions of the rules might grow very complex

  24. Example of Complex Decision: Decision Tree • The same decision, can yes be easily captured in a Attack! Do we have decision tree yes More units Than him Do we have no Build more Antiair units units no yes Build Antiair units yes Enemy Does he have Seen Air Units no no yes Attack! Do we have More units Build more Than him units no Build more units

  25. Decision Trees • Intuitive • Help us determine whether we are forgetting a case • Easy to implement: • Decision trees can be used as “paper and pencil” technique, to think about the problem, and then just use nested if-then-else statements • They can also be implemented in a generic way, and give graphical editors to game designers

  26. Finite State Machines with Decision Trees • In complex FSMs, conditions in arches might get complex • Each state could have a decision tree to determine which state to go next S2 C2 S1 C1 S3

  27. Example Basic RTS AI: Strategy Finite-State Machine used as an example in Week 2 of class Resource spending: Resource spending: 80% Economy, After training 20% Economy, 4 footmen 20% Military 80% Military 2 workers wood 2 workers wood 1 worker metal 4 workers metal Army Composition: Army Composition: 100% footmen 100% knights If enemy has no more If enemy has flying units Flying units Army Composition: 50% knights 50% archers

  28. Other Approaches • Rule-based systems: • Not extremely common in games, but very well studied in AI (expert systems) • Collection of rules plus an inference engine • Problems: hard to scale up (rules have complex interactions when there’s many of them) • Behavior Trees: • Combination of Hierarchical FSMs with planning and execution • Very popular in modern games (not so popular in RTS games) • Covered in Intro to Game AI (offered next quarter)

  29. Outline • Student Presentation: “Near Optimal Hierarchical Pathfinding” • Student Presentation: “Intelligent Moving of Groups in Real-Time Strategy Games” • Decision Making • Basics: Hardcoded Methods • Decision Theory • Adversarial Search • Project Discussion

Recommend


More recommend