artificial intelligence decision making single agent
play

ARTIFICIAL INTELLIGENCE Decision making: single agent Lecturer: - PowerPoint PPT Presentation

Utrecht University INFOB2KI 20192020 The Netherlands ARTIFICIAL INTELLIGENCE Decision making: single agent Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html


  1. Utrecht University INFOB2KI 2019‐2020 The Netherlands ARTIFICIAL INTELLIGENCE Decision making: single agent Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html

  2. "Five frogs were sitting on a log. One decided to jump into the pond. How many were left?" 2

  3. Outline  Actions vs decisions  Decision making tools for reactive planning – Decision trees When conditions are true/false and actions succeed (or not); – Finite state machines decide on inputs, not desires/goals – Behavior trees  Rule‐based expert systems 3

  4. Action Something which results in changes internal or external to agent e.g. Precondition: in(house,fire) Action: extinguishFire Postcondition: not in(house,fire) 4

  5. Actions Precondition: in(house1,fire) and close(I, house1) and has(I, fireHose) and capability(I, extinguishFire) and available(water) and not in(house1,victim) and safeable(house) Action: extinguishFire(house1) Postcondition: not in(house1,fire) and soaked(house1) and charred(house1) 5

  6. Types of Action  World state changes – Instantaneous; not necessarily directly visible to player/user  ‘Cognitive’ changes (belief updates, …) – Instantaneous; not visible, only indirectly noticeable  In games also: animations, complex AI requests (e.g, pathfinder) – Duration, visible; might fail half way 6

  7. Decisions  Why? : object of decision (in general): – Action, strategy, goal, classification, …  Can we?: criteria for decision: – World state, belief about world state, cognitive state (of others),…  Will we?: commitment to decision: – Priorities for outcome, expiry time, achievement time,… 7

  8. Reactive planning  (More recently: dynamic planning)  Cope with dynamic and unpredictable environments  Compute just one next action every instant  Sometimes use stored info on agent’s priorities and behaviors 8

  9. Decision trees (handcrafted) 9

  10. Decision trees Decision tree interpretation: • (decide to) perform action in leaf if all conditions on the path from root to the leaf are fulfilled If‐then semantics: yes action1 B If A and B then action1 yes no action2 If A and not‐ B then action2 A If not‐ A and B then action3 yes If not‐ A and not‐ B then action4 action3 no B where A is short for “A=yes”, and no action4 not‐ A is short for “A=no”… 10

  11. Simplifying decision trees yes action1 yes action1 B yes B yes no action2 A no action2 A yes action2 no no B action2 no action2 yes action1 action1 yes B yes no action1 A A yes action1 yes action1 no no B B no action2 no action2 11

  12. Decision trees Interpretation in case multiple equivalent leaves : • (decide to) perform action in leaf if all conditions on one of the paths from root to the leaf are fulfilled yes action1 action1 yes B yes A no action2 A yes action1 no B no action2 no action2 If A and B then action1 If A or ( not‐A and B) then action1 If not‐ A or ( A and not‐B) then action2 If not‐ A and not‐B then action2 Note that this is equivalent to: Note that this is equivalent to: If A and B then action1 else action2 If A or B then action1 else action2 12

  13. Decision graphs yes action1 More compact B yes representation when no multiple equivalent A action2 leaves: no yes C no action4 If‐then semantics: If A and B then action1 If (A and not B) or ( not A and C) then action2 If not A and not C then action4 13

  14. Decision trees Conditions can also concern non‐binary events . If‐then semantics: action1 starving hungry action2 If A=starving then action1 A If A=hungry then action2 action3 fed If A=fed then action3 just fed If A=just fed then action4 action4 Example: an ant’s life 14

  15. Decision with randomness defend yes Under attack? patrol yes no Random > n ? no rest Example: an ant’s life 15

  16. Defining suitable conditions An ant in search of food…. Go(north) no Go(north) Go(south) no no yes D Go(east) yes B no yes yes Go(west) no C E yes A F yes yes Go(random) no no Go(north,east) no … E no yes Go(north,west) F A= food(north) B=food(west) or food(south) or food(east) yes C=food(south) Go(north) D=food(west) or food(east) E=food(west) Good model ? F=food(east) 16

  17. Using other criteria as conditions Go(north) yes A yes Go(west) no B Go(south) yes no C no Go(east) A=food_closest(north) B=food_closest(west) C=food_closest(south) D=food_closest(east) 17

  18. Conditions Good:  conditions are only used in the context of another condition  conditions are mutually exclusive Bad:  all conditions apply always and all combinations have to be checked  several conditions can be true at the same time 18

  19. Finite State Machines 19

  20. State machines in games  States: capture possible actions/behaviors of a system  Transitions: link states, based on conditions  The “machine” works as follows: – start in a state – perform the behavior of that state, if any (~ do action) – transition when the condition is true – until an end state is reached  If the number of states is finite we call the system a Finite State Machine. 20

  21. ‘traditional’ FSM: simple example 1 0 or 1 0  Machine starts ( ) in the left state; and may stop in right terminal state ( ); action ‘wait for input’ in states  As long as it ‘sees’ (=condition) a zero, it remains in left state  If it ‘sees’ a one, it transitions to right state  In right state it may stop if input from environment ceases ‐‐‐ ‘accepting’ the input seen What type of bit strings does this machine accept? (strings where the OR of all bits is True) 21

  22. Finite State Machines in games For woodcutter FSM see https://www.youtube.com/watch?v=FuvaehxklOA 22

  23. Game FSM See small enemy On guard fight See big enemy Loose fight escaped run Example: an ant’s life 23

  24. Implementation of FSM # current state myState = OnGuard while myState == OnGuard: if see(small_enemy) : myState = Fight if see(big_enemy) : myState = Run guard() # continue what you’re doing while myState == Fight: if loose() : myState = Run beat_enemy() while myState == Run: if escaped(): myState = OnGuard run_away() 24

  25. FSM: handling interrupts (?) Tea Drink tea finished See small enemy fight On guard Tea Teatime finished Teatime See big Loose fight enemy Drink tea escaped Not very efficient… Teatime run Drink tea Tea finished 25

  26. Hierarchical FSM A (super) state can be a whole FSM: fighting See small Tea finished enemy Drink tea fight On guard Teatime See big Top‐level transition: enemy Loose • ‘forced’ interrupt fight escaped • return to most recent state in run ‘fighting’ FSM (=non‐`alarm’ level) 26

  27. Hierarchical FSM fighting See no enemy See small enemy fight Tea finished On guard Drink tea Teatime See big enemy Loose cross‐hierarchy fight escaped transition • ‘chosen’ interrupt run • return to initial state in ‘fighting’ FSM 27

  28. Combination: FSM‐decision tree See enemy enemy small yes yes fight On guard no no Loose fight escaped run 28

  29. An ant’s life: the end See enemy enemy alone yes yes fight Find food Loose fight no no die yes no See more enemies Get caught run 29

  30. FSM States  States: should be disjunct cover of all possible situations  Activities: should be “evenly divided” over states  Activities: should be “naturally” divided over states  Difficulties when a character can be in more than one state at the time… 30

  31. Behavior Trees 31

  32. Behavior tree 32

  33. Behavior tree in firescenario 33

  34. Behavior Tree 1. Tasks as nodes which succeed or not 2. Links indicate sub‐tasks 3. Either select one of the sub‐tasks ? (choose first that is successful, then done; success if one sub‐task successful) or execute all sub‐tasks in sequence  (bail out if fail; success only if all sub‐tasks successful) 4. Conditions used to choose sub‐task 34

  35. The life of an ant live ? Normal danger activity ? fight run Find Bring food food to multiply hive 35

  36. Summary behavior trees  Simple form of (hierarchical) planning  Root of tree contains all behaviors of character  Reactive planning: when one action fails the next behavior is tried  All alternatives are preplanned  Order usually fixed, but can be influenced through conditions  Problems with interrupts 36

  37. Rule‐Based Systems  Recall: decision trees can be converted into rules  More general rule‐based systems let you write the rules explicitly  System consists of: – Knowledge: • A rule set ‐ the rules to evaluate • A database (working memory) ‐ stores initial and derived facts – Reasoning: • A matching scheme ‐ decides which rules are applicable • A conflict resolution scheme ‐ if more than one rule is applicable, decides how to proceed – Explanation facilities (not discussed) 37

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend