SlideShare a Scribd company logo
1 of 55
Download to read offline
Stavros Vassos, University of Athens, Greece   stavrosv@di.uoa.gr   May 2012




INTRODUCTION TO AI
STRIPS PLANNING
.. and Applications to Video-games!
Course overview
2


       Lecture 1: Game-inspired competitions for AI research,
        AI decision making for non-player characters in games
       Lecture 2: STRIPS planning, state-space search
       Lecture 3: Planning Domain Definition Language (PDDL),
        using an award winning planner to solve Sokoban
       Lecture 4: Planning graphs, domain independent
        heuristics for STRIPS planning
       Lecture 5: Employing STRIPS planning in games:
        SimpleFPS, iThinkUnity3D, SmartWorkersRTS
       Lecture 6: Planning beyond STRIPS
Artificial Intelligence and Video Games
3


       Video Games:
         Finite State Machines
         Decision Diagrams

         Behavior Trees

         Goal Oriented Action Planning

       Academic AI on agents:
         Knowledge representation, First-order logic,
          Classical planning, Planning with preferences, …
         Belief-Desire-Intention architecture, Agent-based
          programming, …
         Probabilistic reasoning, Bayesian networks,
          Utility theory, Markov Decision Processes, …
Artificial Intelligence and Video Games
4


       Game engine:
         C++

         Creates   game-world objects with (x,y,z) coordinates and
          calculates what happens to them on every frame
         E.g., a crate is up in the air on frame1. On frame 2 the
          game engine will calculate the new position, etc
Artificial Intelligence and Video Games
5


       Game engine:
         C++

         Creates   game-world objects with (x,y,z) coordinates and
          calculates what happens to them on every frame
         E.g., a crate is up in the air on frame1. On frame 2 the
          game engine will calculate the new position, etc
         Same for non-player characters (NPCs)!
Finite State Machines (FSMs)
6


       Video Games:
         Finite State Machines
         Decision Diagrams

         Behavior Trees

         Goal Oriented Action Planning

       Academic AI on agents:
         Knowledge representation, First-order logic,
          Classical planning, Planning with preferences, …
         Belief-Desire-Intention architecture, Agent-based
          programming, …
         Probabilistic reasoning, Bayesian networks,
          Utility theory, Markov Decision Processes, …
Finite State Machines (FSMs)
7


       Recognize a formal language
Finite State Machines (FSMs)
8


       NPC behavior based on high-level states

                                                     Energy OK
                     See small enemy
        On Guard                          Fight



                                              Losing fight




                                        Run away
Finite State Machines (FSMs)
9


       Traditionally one of the first techniques for NPC
        behavior
       Very simple to understand
       Very simple to implement
         E.g.,   directly using if-then-else statements
Finite State Machines (FSMs)
10




     int NPC::think(){
       if (state==ONGUARD && seeSmallEnemy()){
         state=FIGHT;
         makeScarySound();
       }
       else if (state==FIGHT && energy>30){
         ...
       }
       else if ...
     }
Finite State Machines (FSMs)
11


        Let’s see some code from a commercial game
                             HL2-SDK, npc_BaseZombie.cpp
                             lines 1828-1870

                              switch ( m_NPCState )
                              {
                              case NPC_STATE_COMBAT:
                              …
                              case NPC_STATE_ALERT:
                              …
                              }
Finite State Machines (FSMs)
12


        Traditionally one of the first techniques for NPC
         behavior
        Very simple to understand
        Very simple to implement
          E.g.,   directly using if-then-else statements
        Separation between the work of the programmer
         and the game designers
        But also simplistic in the behaviors that can be
         expressed…
Behavior Trees (BTs)
13


        Video Games:
          Finite State Machines
          Decision Diagrams

          Behavior Trees

          Goal Oriented Action Planning

        Academic AI on agents:
          Knowledge representation, First-order logic,
           Classical planning, Planning with preferences, …
          Belief-Desire-Intention architecture, Agent-based
           programming, …
          Probabilistic reasoning, Bayesian networks,
           Utility theory, Markov Decision Processes, …
Behavior Trees (BTs)
14


        NPC behavior based on more refined conditions and
         strategies
          Tasks have a common basic structure: they are given
           CPU time to do something and return success or failure
          Leaf tasks: check a condition or execute some code

          Composite tasks: return value depend on child tasks
Behavior Trees (BTs)
15


         NPC behavior based on more refined conditions and
          strategies
           Tasks have a common basic structure: they are given
            CPU time to do something and return success or failure
           Leaf tasks: check a condition or execute some code

           Composite tasks: return value depend on child tasks

     E.g., succeed if the
     door in front of the
        NPC is open
      E.g., kick the door
     in front of the NPC
Behavior Trees (BTs)
16


        NPC behavior based on more refined conditions and
         strategies
          Tasks have a common basic structure: they are given
           CPU time to do something and return success or failure
          Leaf tasks: check a condition or execute some code

          Composite tasks: return value depend on child tasks


                                  ?
                                                E.g., succeed if any
                                                 of the child tasks
                                                       succeed
Behavior Trees (BTs)
17


        NPC behavior based on more refined conditions and
         strategies
          Tasks have a common basic structure: they are given
           CPU time to do something and return success or failure
          Leaf tasks: check a condition or execute some code

          Composite tasks: return value depend on child tasks




                                                E.g., succeed if all
                                                of the child tasks
                                                      succeed
Behavior Trees (BTs)
18


        NPC behavior based on more refined conditions
         and strategies
        Sequence task and Selector task

              →                                ?

                              ?

                                  
Behavior Trees (BTs)
19


        NPC behavior based on more refined conditions
         and strategies


             →

     Door          Move
     open?       into room
Behavior Trees (BTs)
20


        NPC behavior based on more refined conditions
         and strategies
                             ?
             →                             →

     Door          Move           Move           Move
     open?       into room       to door
                                           ?   into room
Behavior Trees (BTs)
21


        NPC behavior based on more refined conditions
         and strategies
                                  ?
             →                                    →

     Door          Move                Move              Move
     open?       into room            to door
                                                  ?    into room

                                           →          →

                          Door           Unlock       Kick         Door
                        locked?           door        door         open?
Behavior Trees (BTs)
22


       NPC behavior based on more refined conditions
     Notethat no search is involved in this paradigm: the behavior
       andtree is traversed as a kind of pre-defined program
            strategies
                                  ?
             →                                    →

     Door          Move                Move              Move
     open?       into room            to door
                                                  ?    into room

                                           →          →

                          Door           Unlock       Kick         Door
                        locked?           door        door         open?
Behavior Trees (BTs)
23


       NPC behaviorisbased ondepends on the implementation,
      Theway the tree traversed more refined conditions
       and strategies over, keep track of the current node, etc
        e.g., always start

                                  ?
             →                                    →

     Door          Move                Move              Move
     open?       into room            to door
                                                  ?    into room

                                           →          →

                          Door           Unlock       Kick         Door
                        locked?           door        door         open?
Behavior Trees (BTs)
24


        NPC behavior based on more refined conditions
         and strategies
        Non-deterministic sequence task and selector task

             ~→                                ~?

                              ~?

                                   ~
Behavior Trees (BTs)
25


        NPC behavior based on more refined conditions
         and strategies
                                  ?
             →                                    →

     Door          Move                Move               Move
     open?       into room            to door
                                                  ~?    into room

                                           →           →

                          Door           Unlock        Kick         Door
                        locked?           door         door         open?
Behavior Trees (BTs)
26


        NPC behavior based on more refined conditions
         and strategies
        Parallel sequence task (similar to sequence)

                               E.g., perform move actions
                               while also shooting at target

                                   Also used to simulate
                                 “state-like” behavior by
                              ensuring that a condition holds
Behavior Trees (BTs)
27


        NPC behavior based on more refined conditions
         and strategies
        Decorator tasks (wrap objects with same interface)




         Until
                                       Invert
         fail
Behavior Trees (BTs)
28


        NPC behavior based on more refined conditions
         and strategies
                             ?
                                             
            Until         Attack    Until          Look
            fail          enemy     fail          around


           Enemy                    Invert
           in sight

                                   Enemy
                                   in sight
Behavior Trees (BTs)
29


        One of the first commercial
         video games that used BTs
         is Halo2 (2004)
        Simple to understand
        Simple to implement
         …

        Separation between the work of the programmer
         and the game designers
        Offers the specification of fine-grained behaviors
Reactive Behavior
30


        Both FSMs and BTs are reactive techniques

          The NPC follows a pre-programmed strategy that
           specifies how the NPC should react in the game
           depending on the current state/node and conditions
           that currently hold in the game-world

         A  sequence of actions that may be executed in the
           game, e.g., [move to door, kick door, move into room],
           need to be represented explicitly in the structure of
           the FSMs or BTs
Reactive Behavior
31


        Historically, the vast amount of video games with
         NPCs use FSMs and BTs for NPC decision making

          Simpleto understand/implement
          Separation between programmers and game designers



          Any  extensions needed can be handled effectively
           using programming tricks
          The behavior is strengthened by extra information in
           the game world that is carefully prepared for NPCs
Reactive Behavior
32


        A game level from the eyes of an NPC
Reactive Behavior
33


        A game level from the eyes of an NPC
Reactive Behavior
34


        The situation today
          Open   worlds with increasing available interactions
          NPCs need to be autonomous, with their own agenda,
           goals, personality
Reactive Behavior
35


        The situation today
Reactive Behavior
36


        The situation today
          Under these circumstances, maintaining the possible and
           applicable interactions using reactive techniques
           becomes complex and difficult
          The need for more flexible techniques arises
Reactive Behavior
37


        The situation today

                               youtube link
Goal Oriented Action Planning (GOAP)
38


        Video Games:
          Finite State Machines
          Decision Diagrams

          Behavior Trees

          Goal Oriented Action Planning

        Academic AI on agents:
          Knowledge representation, First-order logic,
           Classical planning, Planning with preferences, …
          Belief-Desire-Intention architecture, Agent-based
           programming, …
          Probabilistic reasoning, Bayesian networks,
           Utility theory, Markov Decision Processes, …
Goal Oriented Action Planning (GOAP)
39


        Replace the pre-defined strategies with a
         description of goals and available actions
                                   ?
              →                                    →

     Door           Move                Move              Move
     open?        into room            to door
                                                   ?    into room

                                            →          →

                           Door           Unlock       Kick         Door
                         locked?           door        door         open?
Goal Oriented Action Planning (GOAP)
40


        Replace the pre-defined strategies with a
         description of goals and available actions




                 Move        Move            Move
               into room    to door        into room




                               Unlock     Kick
                                door      door
Goal Oriented Action Planning (GOAP)
41


        Replace the pre-defined strategies with a
         description of goals and available actions

       Move      Preconditions: Door open
     into room   Effects: In room

      Move       Preconditions: -
     to door     Effects: At door

      Unlock     Preconditions: Hold key
       door      Effects: Door open

         Kick    Preconditions: -
         door    Effects: Door open
Goal Oriented Action Planning (GOAP)
42


        Replace the pre-defined strategies with a
         description of goals and available actions

       Move      Preconditions: Door open      In room
     into room   Effects: In room

      Move       Preconditions: -
     to door     Effects: At door

      Unlock     Preconditions: Hold key
       door      Effects: Door open

         Kick    Preconditions: -
         door    Effects: Door open
Goal Oriented Action Planning (GOAP)
43


        Search in real-time for a strategy that achieves the
         goal in the current state

       Move      Preconditions: Door open      In room
     into room   Effects: In room

      Move       Preconditions: -
     to door     Effects: At door

      Unlock     Preconditions: Hold key
       door      Effects: Door open

         Kick    Preconditions: -
         door    Effects: Door open
Goal Oriented Action Planning (GOAP)
44


        Advantages
          Easy to manage a large number of generated
           behaviors
          Able to achieve different behaviors that satisfy the
           given requirements under different conditions without
           explicitly listing the resulting strategies


        But it needs to solve planning problems in a few
         frames!
Behavior Trees (BTs)
45


        One of the first commercial
         video games that used BTs
         is Halo2 (2004)
        Simple to understand
        Simple to implement
         …

        Separation between the work of the programmer
         and the game designers
        Offers the specification of fine-grained behaviors
Goal Oriented Action Planning (GOAP)
46


        One of the first commercial
         video games that used GOAP
         is FEAR (2005)
        Not so simple to understand
        Not so simple to implement
         …

        Not so clear separation between the work of the
         programmer and the game designers
        The specification of fine-grained behaviors is
         actually tricky
Goal Oriented Action Planning (GOAP)
47


        Some details about GOAP in
         FEAR:
          One  AI programmer
           responsible for NPC behavior

          Idea: Different behaviors can
           be achieved among characters
           by using GOAP and providing
           each character with same goals
           but a different set of available
           actions
Goal Oriented Action Planning (GOAP)
48
Goal Oriented Action Planning (GOAP)
49


        Simplifying STRIPS planning:
          Literalsare stored as variables
           (essentially having one argument)
          The state is stored as an array of
           a fixed size
          Search goes up to depth …3



        A* for path finding…
        A* also for planning!
Reactive Planning Vs. Classical Planning
50




        HALO2 (2004)             FEAR (2005)
        Since then BTs have      Since then GOAP has
         become a standard         not picked up much
         for NPC behavior          speed
Reactive Planning Vs. Classical Planning
51




     Behavior Trees              Goal Oriented
                                 Action Planning
Reactive Planning Vs. Classical Planning
52




     Behavior Trees                         Goal Oriented
                                            Action Planning
         A combination of these techniques?
           BTs
              for reactive decision making
           GOAP for tactical decision making
Artificial Intelligence and Video Games
53


        Amazing tools available for (indie) game developers!
Artificial Intelligence and Video Games
54


        Source available!
Bibliography
55


      Material
        Artificial
                  Intelligence for Games, Second Edition. Ian Millington,
         John Funge. Morgan Kaufmann Publishers Inc., 2009.
        Sections 5.3, 5.4

More Related Content

Viewers also liked

Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1Stavros Vassos
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2
Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2
Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2Stavros Vassos
 
Pathfinding - Part 3: Beyond the basics
Pathfinding - Part 3: Beyond the basicsPathfinding - Part 3: Beyond the basics
Pathfinding - Part 3: Beyond the basicsStavros Vassos
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1Stavros Vassos
 
Beyond believable agents - employing AI for improving game like simulations f...
Beyond believable agents - employing AI for improving game like simulations f...Beyond believable agents - employing AI for improving game like simulations f...
Beyond believable agents - employing AI for improving game like simulations f...Mirjam Eladhari
 
Artificial intelligence in gaming.
Artificial intelligence in gaming.Artificial intelligence in gaming.
Artificial intelligence in gaming.Rishikese MR
 
Game playing in artificial intelligent technique
Game playing in artificial intelligent technique Game playing in artificial intelligent technique
Game playing in artificial intelligent technique syeda zoya mehdi
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligencelordmwesh
 

Viewers also liked (10)

Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2
Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2
Intro to AI STRIPS Planning & Applications in Video-games Lecture2-Part2
 
Pathfinding - Part 3: Beyond the basics
Pathfinding - Part 3: Beyond the basicsPathfinding - Part 3: Beyond the basics
Pathfinding - Part 3: Beyond the basics
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
 
Practical AI in Games
Practical AI in GamesPractical AI in Games
Practical AI in Games
 
Beyond believable agents - employing AI for improving game like simulations f...
Beyond believable agents - employing AI for improving game like simulations f...Beyond believable agents - employing AI for improving game like simulations f...
Beyond believable agents - employing AI for improving game like simulations f...
 
Artificial intelligence in gaming.
Artificial intelligence in gaming.Artificial intelligence in gaming.
Artificial intelligence in gaming.
 
Planning
PlanningPlanning
Planning
 
Game playing in artificial intelligent technique
Game playing in artificial intelligent technique Game playing in artificial intelligent technique
Game playing in artificial intelligent technique
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Intro to AI STRIPS Planning & Applications in Video-games Lecture1-Part2

  • 1. Stavros Vassos, University of Athens, Greece stavrosv@di.uoa.gr May 2012 INTRODUCTION TO AI STRIPS PLANNING .. and Applications to Video-games!
  • 2. Course overview 2  Lecture 1: Game-inspired competitions for AI research, AI decision making for non-player characters in games  Lecture 2: STRIPS planning, state-space search  Lecture 3: Planning Domain Definition Language (PDDL), using an award winning planner to solve Sokoban  Lecture 4: Planning graphs, domain independent heuristics for STRIPS planning  Lecture 5: Employing STRIPS planning in games: SimpleFPS, iThinkUnity3D, SmartWorkersRTS  Lecture 6: Planning beyond STRIPS
  • 3. Artificial Intelligence and Video Games 3  Video Games:  Finite State Machines  Decision Diagrams  Behavior Trees  Goal Oriented Action Planning  Academic AI on agents:  Knowledge representation, First-order logic, Classical planning, Planning with preferences, …  Belief-Desire-Intention architecture, Agent-based programming, …  Probabilistic reasoning, Bayesian networks, Utility theory, Markov Decision Processes, …
  • 4. Artificial Intelligence and Video Games 4  Game engine:  C++  Creates game-world objects with (x,y,z) coordinates and calculates what happens to them on every frame  E.g., a crate is up in the air on frame1. On frame 2 the game engine will calculate the new position, etc
  • 5. Artificial Intelligence and Video Games 5  Game engine:  C++  Creates game-world objects with (x,y,z) coordinates and calculates what happens to them on every frame  E.g., a crate is up in the air on frame1. On frame 2 the game engine will calculate the new position, etc  Same for non-player characters (NPCs)!
  • 6. Finite State Machines (FSMs) 6  Video Games:  Finite State Machines  Decision Diagrams  Behavior Trees  Goal Oriented Action Planning  Academic AI on agents:  Knowledge representation, First-order logic, Classical planning, Planning with preferences, …  Belief-Desire-Intention architecture, Agent-based programming, …  Probabilistic reasoning, Bayesian networks, Utility theory, Markov Decision Processes, …
  • 7. Finite State Machines (FSMs) 7  Recognize a formal language
  • 8. Finite State Machines (FSMs) 8  NPC behavior based on high-level states Energy OK See small enemy On Guard Fight Losing fight Run away
  • 9. Finite State Machines (FSMs) 9  Traditionally one of the first techniques for NPC behavior  Very simple to understand  Very simple to implement  E.g., directly using if-then-else statements
  • 10. Finite State Machines (FSMs) 10 int NPC::think(){ if (state==ONGUARD && seeSmallEnemy()){ state=FIGHT; makeScarySound(); } else if (state==FIGHT && energy>30){ ... } else if ... }
  • 11. Finite State Machines (FSMs) 11  Let’s see some code from a commercial game  HL2-SDK, npc_BaseZombie.cpp  lines 1828-1870 switch ( m_NPCState ) { case NPC_STATE_COMBAT: … case NPC_STATE_ALERT: … }
  • 12. Finite State Machines (FSMs) 12  Traditionally one of the first techniques for NPC behavior  Very simple to understand  Very simple to implement  E.g., directly using if-then-else statements  Separation between the work of the programmer and the game designers  But also simplistic in the behaviors that can be expressed…
  • 13. Behavior Trees (BTs) 13  Video Games:  Finite State Machines  Decision Diagrams  Behavior Trees  Goal Oriented Action Planning  Academic AI on agents:  Knowledge representation, First-order logic, Classical planning, Planning with preferences, …  Belief-Desire-Intention architecture, Agent-based programming, …  Probabilistic reasoning, Bayesian networks, Utility theory, Markov Decision Processes, …
  • 14. Behavior Trees (BTs) 14  NPC behavior based on more refined conditions and strategies  Tasks have a common basic structure: they are given CPU time to do something and return success or failure  Leaf tasks: check a condition or execute some code  Composite tasks: return value depend on child tasks
  • 15. Behavior Trees (BTs) 15  NPC behavior based on more refined conditions and strategies  Tasks have a common basic structure: they are given CPU time to do something and return success or failure  Leaf tasks: check a condition or execute some code  Composite tasks: return value depend on child tasks E.g., succeed if the door in front of the NPC is open E.g., kick the door in front of the NPC
  • 16. Behavior Trees (BTs) 16  NPC behavior based on more refined conditions and strategies  Tasks have a common basic structure: they are given CPU time to do something and return success or failure  Leaf tasks: check a condition or execute some code  Composite tasks: return value depend on child tasks ? E.g., succeed if any of the child tasks succeed
  • 17. Behavior Trees (BTs) 17  NPC behavior based on more refined conditions and strategies  Tasks have a common basic structure: they are given CPU time to do something and return success or failure  Leaf tasks: check a condition or execute some code  Composite tasks: return value depend on child tasks E.g., succeed if all  of the child tasks succeed
  • 18. Behavior Trees (BTs) 18  NPC behavior based on more refined conditions and strategies  Sequence task and Selector task → ? ? 
  • 19. Behavior Trees (BTs) 19  NPC behavior based on more refined conditions and strategies → Door Move open? into room
  • 20. Behavior Trees (BTs) 20  NPC behavior based on more refined conditions and strategies ? → → Door Move Move Move open? into room to door ? into room
  • 21. Behavior Trees (BTs) 21  NPC behavior based on more refined conditions and strategies ? → → Door Move Move Move open? into room to door ? into room → → Door Unlock Kick Door locked? door door open?
  • 22. Behavior Trees (BTs) 22 NPC behavior based on more refined conditions Notethat no search is involved in this paradigm: the behavior andtree is traversed as a kind of pre-defined program strategies ? → → Door Move Move Move open? into room to door ? into room → → Door Unlock Kick Door locked? door door open?
  • 23. Behavior Trees (BTs) 23 NPC behaviorisbased ondepends on the implementation,  Theway the tree traversed more refined conditions and strategies over, keep track of the current node, etc e.g., always start ? → → Door Move Move Move open? into room to door ? into room → → Door Unlock Kick Door locked? door door open?
  • 24. Behavior Trees (BTs) 24  NPC behavior based on more refined conditions and strategies  Non-deterministic sequence task and selector task ~→ ~? ~? ~
  • 25. Behavior Trees (BTs) 25  NPC behavior based on more refined conditions and strategies ? → → Door Move Move Move open? into room to door ~? into room → → Door Unlock Kick Door locked? door door open?
  • 26. Behavior Trees (BTs) 26  NPC behavior based on more refined conditions and strategies  Parallel sequence task (similar to sequence)  E.g., perform move actions while also shooting at target Also used to simulate “state-like” behavior by ensuring that a condition holds
  • 27. Behavior Trees (BTs) 27  NPC behavior based on more refined conditions and strategies  Decorator tasks (wrap objects with same interface) Until Invert fail
  • 28. Behavior Trees (BTs) 28  NPC behavior based on more refined conditions and strategies ?   Until Attack Until Look fail enemy fail around Enemy Invert in sight Enemy in sight
  • 29. Behavior Trees (BTs) 29  One of the first commercial video games that used BTs is Halo2 (2004)  Simple to understand  Simple to implement …  Separation between the work of the programmer and the game designers  Offers the specification of fine-grained behaviors
  • 30. Reactive Behavior 30  Both FSMs and BTs are reactive techniques  The NPC follows a pre-programmed strategy that specifies how the NPC should react in the game depending on the current state/node and conditions that currently hold in the game-world A sequence of actions that may be executed in the game, e.g., [move to door, kick door, move into room], need to be represented explicitly in the structure of the FSMs or BTs
  • 31. Reactive Behavior 31  Historically, the vast amount of video games with NPCs use FSMs and BTs for NPC decision making  Simpleto understand/implement  Separation between programmers and game designers  Any extensions needed can be handled effectively using programming tricks  The behavior is strengthened by extra information in the game world that is carefully prepared for NPCs
  • 32. Reactive Behavior 32  A game level from the eyes of an NPC
  • 33. Reactive Behavior 33  A game level from the eyes of an NPC
  • 34. Reactive Behavior 34  The situation today  Open worlds with increasing available interactions  NPCs need to be autonomous, with their own agenda, goals, personality
  • 35. Reactive Behavior 35  The situation today
  • 36. Reactive Behavior 36  The situation today  Under these circumstances, maintaining the possible and applicable interactions using reactive techniques becomes complex and difficult  The need for more flexible techniques arises
  • 37. Reactive Behavior 37  The situation today youtube link
  • 38. Goal Oriented Action Planning (GOAP) 38  Video Games:  Finite State Machines  Decision Diagrams  Behavior Trees  Goal Oriented Action Planning  Academic AI on agents:  Knowledge representation, First-order logic, Classical planning, Planning with preferences, …  Belief-Desire-Intention architecture, Agent-based programming, …  Probabilistic reasoning, Bayesian networks, Utility theory, Markov Decision Processes, …
  • 39. Goal Oriented Action Planning (GOAP) 39  Replace the pre-defined strategies with a description of goals and available actions ? → → Door Move Move Move open? into room to door ? into room → → Door Unlock Kick Door locked? door door open?
  • 40. Goal Oriented Action Planning (GOAP) 40  Replace the pre-defined strategies with a description of goals and available actions Move Move Move into room to door into room Unlock Kick door door
  • 41. Goal Oriented Action Planning (GOAP) 41  Replace the pre-defined strategies with a description of goals and available actions Move Preconditions: Door open into room Effects: In room Move Preconditions: - to door Effects: At door Unlock Preconditions: Hold key door Effects: Door open Kick Preconditions: - door Effects: Door open
  • 42. Goal Oriented Action Planning (GOAP) 42  Replace the pre-defined strategies with a description of goals and available actions Move Preconditions: Door open In room into room Effects: In room Move Preconditions: - to door Effects: At door Unlock Preconditions: Hold key door Effects: Door open Kick Preconditions: - door Effects: Door open
  • 43. Goal Oriented Action Planning (GOAP) 43  Search in real-time for a strategy that achieves the goal in the current state Move Preconditions: Door open In room into room Effects: In room Move Preconditions: - to door Effects: At door Unlock Preconditions: Hold key door Effects: Door open Kick Preconditions: - door Effects: Door open
  • 44. Goal Oriented Action Planning (GOAP) 44  Advantages  Easy to manage a large number of generated behaviors  Able to achieve different behaviors that satisfy the given requirements under different conditions without explicitly listing the resulting strategies  But it needs to solve planning problems in a few frames!
  • 45. Behavior Trees (BTs) 45  One of the first commercial video games that used BTs is Halo2 (2004)  Simple to understand  Simple to implement …  Separation between the work of the programmer and the game designers  Offers the specification of fine-grained behaviors
  • 46. Goal Oriented Action Planning (GOAP) 46  One of the first commercial video games that used GOAP is FEAR (2005)  Not so simple to understand  Not so simple to implement …  Not so clear separation between the work of the programmer and the game designers  The specification of fine-grained behaviors is actually tricky
  • 47. Goal Oriented Action Planning (GOAP) 47  Some details about GOAP in FEAR:  One AI programmer responsible for NPC behavior  Idea: Different behaviors can be achieved among characters by using GOAP and providing each character with same goals but a different set of available actions
  • 48. Goal Oriented Action Planning (GOAP) 48
  • 49. Goal Oriented Action Planning (GOAP) 49  Simplifying STRIPS planning:  Literalsare stored as variables (essentially having one argument)  The state is stored as an array of a fixed size  Search goes up to depth …3  A* for path finding…  A* also for planning!
  • 50. Reactive Planning Vs. Classical Planning 50  HALO2 (2004)  FEAR (2005)  Since then BTs have  Since then GOAP has become a standard not picked up much for NPC behavior speed
  • 51. Reactive Planning Vs. Classical Planning 51 Behavior Trees Goal Oriented Action Planning
  • 52. Reactive Planning Vs. Classical Planning 52 Behavior Trees Goal Oriented Action Planning  A combination of these techniques?  BTs for reactive decision making  GOAP for tactical decision making
  • 53. Artificial Intelligence and Video Games 53  Amazing tools available for (indie) game developers!
  • 54. Artificial Intelligence and Video Games 54  Source available!
  • 55. Bibliography 55  Material  Artificial Intelligence for Games, Second Edition. Ian Millington, John Funge. Morgan Kaufmann Publishers Inc., 2009.  Sections 5.3, 5.4