AI – Week 10 AI and Games (2) Lee McCluskey, room 3/10

Slides:



Advertisements
Similar presentations
Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Advertisements

Adversarial Search Chapter 6 Section 1 – 4.
Tic Tac Toe Architecture CSE 5290 – Artificial Intelligence 06/13/2011 Christopher Hepler.
Search Techniques MSc AI module. Search In order to build a system to solve a problem we need to: Define and analyse the problem Acquire the knowledge.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
AI – Week 11 AI and Games (3) Lee McCluskey, room 2/09
CPSC 322 Introduction to Artificial Intelligence October 25, 2004.
1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial.
Using Search in Problem Solving
Game Playing CSC361 AI CSC361: Game Playing.
1 search CS 331/531 Dr M M Awais A* Examples:. 2 search CS 331/531 Dr M M Awais 8-Puzzle f(N) = g(N) + h(N)
AI – Week 5 An Introduction to AI Planning Lee McCluskey, room 2/07
AI – Week 8 AI + 2 Player Games Lee McCluskey, room 3/10
Logical Agents Chapter 7 Feb 26, Knowledge and Reasoning Knowledge of action outcome enables problem solving –a reflex agent can only find way from.
Adversarial Search: Game Playing Reading: Chess paper.
AI – Week 12 AI and Games (4) Lee McCluskey, room 2/09
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
Ocober 10, 2012Introduction to Artificial Intelligence Lecture 9: Machine Evolution 1 The Alpha-Beta Procedure Example: max.
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Game Playing. Introduction Why is game playing so interesting from an AI point of view? –Game Playing is harder then common searching The search space.
Game Playing.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
Artificial Intelligence: Planning Lecture 6 Problems with state space search Planning Operators A Simple Planning Algorithm (Game Playing)
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
CHA2555 Week2: Knowledge Representation, Logic and Planning Lee McCluskey First term:
October 3, 2012Introduction to Artificial Intelligence Lecture 9: Two-Player Games 1 Iterative Deepening A* Algorithm A* has memory demands that increase.
Heuristic Search In addition to depth-first search, breadth-first search, bound depth-first search, and iterative deepening, we can also use informed or.
Traditional game playing 2 player adversarial (win => lose) based on search but... huge game trees can't be fully explored.
Lecture 5: Backtracking Depth-First Search N-Queens Problem Hamiltonian Circuits.
University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 1 Game Playing Search the action space of 2 players Russell.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Search exploring the consequences of possible actions.
Game Playing. Introduction One of the earliest areas in artificial intelligence is game playing. Two-person zero-sum game. Games for which the state space.
Cilk Pousse James Process CS534. Overview Introduction to Pousse Searching Evaluation Function Move Ordering Conclusion.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 9 of 42 Wednesday, 14.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
Game tree search Thanks to Andrew Moore and Faheim Bacchus for slides!
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Natural Language Processing AI Revision Lee McCluskey, room 2/07
CompSci Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the.
Graph Search II GAM 376 Robin Burke. Outline Homework #3 Graph search review DFS, BFS A* search Iterative beam search IA* search Search in turn-based.
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
CS-424 Gregory Dudek Lecture 10 Annealing (final comments) Adversary Search Genetic Algorithms (genetic search)
February 25, 2016Introduction to Artificial Intelligence Lecture 10: Two-Player Games II 1 The Alpha-Beta Procedure Can we estimate the efficiency benefit.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
AI – Week 3 An Introduction to AI Planning Lee McCluskey, room 3/10
Understanding AI of 2 Player Games. Motivation Not much experience in AI (first AI project) and no specific interests/passion that I wanted to explore.
Game playing Types of games Deterministic vs. chance
Game Playing Why do AI researchers study game playing?
Adversarial Search and Game-Playing
Depth-First Search N-Queens Problem Hamiltonian Circuits
Iterative Deepening A*
Adversarial Search.
Tutorial 5 Adversary Search
Kevin Mason Michael Suggs
NIM - a two person game n objects are in one pile
The Alpha-Beta Procedure
Introduction to Artificial Intelligence Lecture 9: Two-Player Games I
Search and Game Playing
CSE (c) S. Tanimoto, 2001 Search-Introduction
Artificial Intelligence
CSE (c) S. Tanimoto, 2002 State-Space Search
Search.
CSE (c) S. Tanimoto, 2004 State-Space Search
Search.
CS51A David Kauchak Spring 2019
Backtracking, Search, Heuristics
Presentation transcript:

AI – Week 10 AI and Games (2) Lee McCluskey, room 3/10

Recap Symbolic AI – Search Heuristics Knowledge Representation Experiment with appropriate language – Prolog Last Week: Introduction to AI in Games 2- player turn-based games Search – use “Minimax” through a “game tree” Heuristics - alpha beta pruning, static board evaluation This Week: A SIMPLE Game, how to implement it in Prolog

AI 2 Player Games – Knowledge Representation - knowledge about a “state” of a game – ie representation of a game “board” or “world”. - Could contain for example:  Strength Values of your Pieces / Forces / Resource  Position Value – how well your Pieces are positioned  Threat Value – what Pieces are being threatened - knowledge about moves tends to be represented procedurally ie encoded into the move generator

Fox and Goose goose fox Goose Goal: Get Goose home (column 4) Fox Goal: Any Fox eats Goose Rules: (i)If fox next (v/h/d) to goose and fox’s turn, then fox can eat goose. (ii)Fox/goose can move either v/h/d. (iii)Only ONE fox can move each turn. (iv)Fox can’t move onto HOME squares or eat the goose when HOME HOME

Fox and Goose goose fox HOME Goose Goal: Get Goose home (column 4) Fox Goal: Any Fox eats Goose Rules: (i)If fox next (v/h/d) to goose and fox’s turn, then fox can eat goose. (ii)Fox/goose can move either v/h/d. (iii)Only ONE fox can move each turn. (iv)Fox can’t move onto HOME squares or eat the goose when HOME

Fox and Goose goose fox HOME Goose Goal: Get Goose home (column 4) Fox Goal: Any Fox eats Goose Rules: (i)If fox next (v/h/d) to goose and fox’s turn, then fox can eat goose. (ii)Fox/goose can move either v/h/d. (iii)Only ONE fox can move each turn. (iv)Fox can’t move onto HOME squares or eat the goose when HOME

Fox and Goose – more elaborate game.. goose fox + Obstacles to reduce movement HOME Goose Goal: Get Goose home (column 4) Fox Goal: Any Fox eats Goose Rules: (i)If fox next (v/h/d) to goose and fox’s turn, then fox can eat goose. (ii)Fox/goose can move either v/h/d. (iii)Only ONE fox can move each turn. (iv)Fox can’t move onto HOME squares or eat the goose when HOME

2 Player Game Implementation 1. Board (state/world) representation 2. Board evaluation function – this is a heuristic function which applies “static” evaluation to each board giving an estimate of how close it is to the goal (called “board evaluation function”) 3. Move generation – which moves can I make? 4. Move application – simulate making a move 5. Choose Best Move – use search (Minimax algorithm) to find best move

Keep it Simple: Fox and Goose Board Representation square denoted by co-ordinate, move specified by pair of co-ordinates square value denotes fox/goose/obstacle/free/ board is a set of squares Operations: Board evaluation function: board -> value Move generation: board -> set of moves

Prolog Representation Square = s(,, ) Board = b(, ) Squares values f = fox, g = goose, 0= free e.g. b(1, [s(1,1,0), s(1,2,0), s(1,3,f), s(1,4,0), s(2,1,0), s(2,2,0), s(2,3,0), s(2,4,0), s(3,1,0), s(3,2,0), s(3,3,0), s(3,4,0), s(4,1,g), s(4,2,0), s(4,3,0), s(4,4,0), s(5,1,0), s(5,2,0), s(5,3,0), s(5,4,0), s(6,1,0), s(6,2,0), s(6,3,f), s(6,4,0)]). N.B. ORDER OF ELEMENTS IN LIST IS IRRELEVANT.

Board Evaluation Function Positive good for Goose, Negative good for Fox % Goose at home (goose won) board_eval(Board, 10000) :- member(s(_,4,g), Board),!. % No Goose (eaten) board_eval(Board, ) :- \+ member(s(_,_,g), Board),!. % Otherwise 0 (don’t know) board_eval(Board, 0 ) :- !.

Move Application AND Generation apply( FROM, TO, BOARD_IN, BOARD_OUT) Move Generation: Precondition: BOARD_IN are instantiated. Postcondition: FROM,TO and BOARD_OUT get values. Move Application: Precondition: FROM, TO, and BOARD_IN are instantiated. Postcondition: BOARD_OUT gets a value.

Move Generation using Generate and Test 1.Generate a possible move from any (X,Y) to (X1,Y1) 2.Test to see if move satisfies necessary constraints, if no fail and backtrack to 1 3. Use the move, then fail and backtrack to 1 Generate possible move in Fox and Goose: select any 2 squares from Board Test in Fox and Goose: (X,Y) next to (X1,Y1) Z = g then Z1 =0 Z = f then Z1 = 0 or Z1 = g X,Y Value Z X1,Y1 Value Z1

Move Application AND Generation % Assume Z is either f or g apply( s(X,Y,Z), s(X1,Y1,Z1), B_IN, B_OUT) :- % move to empty square OR fox eats goose.. (Z1 = 0 ; (Z=f, Z1=g)), member(s(X,Y,Z), B_IN), member(s(X1,Y1,Z1),B_IN), % FOX can't go into the fourth column... \+ (Z=f, Y1=4), % two squares must be next to each other next(X,Y,X1,Y1), % checks over – now make the move remove(s(X,Y,Z), B_IN, B1), remove(s(X1,Y1,Z1), B1, B2), B_OUT = [s(X1,Y1,Z),s(X,Y,0)|B2]. Generate and Test Fixes Z1 Tests parameters Generates Deterministic procedures – only one possible output

Examples | ?- test(7,5,goose). Move goose from 4,1 to 5,1 Estimated value of Board is -5 unclear who wins Number of leaf boards evaluated is Move fox from 3,3 to 4,2 Move goose from 5,1 to 6,1 Move fox from 4,2 to 5,1 Move goose from 6,1 to 7,2 Move fox from 5,1 to 6,1 Move goose from 7,2 to 7,3 yes - not enough search space to see who wins so fox chases goose Initial call to minimax Finds best move Subsequent calls to Minimax from “finish_game” procedure Search depth Identifier of the starting board Who goes first

Examples | ?- test(8,5,goose). Move goose from 4,1 to 5,1 Estimated value of Board is goose wins Number of leaf boards evaluated is Move fox from 3,3 to 2,2 Move goose from 5,1 to 4,2 Move fox from 2,2 to 3,3 Move goose from 4,2 to 5,3 Move fox from 3,3 to 4,2 Move goose from 5,3 to 4,4 Move fox from 4,2 to 5,3 yes | ?- - This time enough search space to see that the goose wins - - Note the fox wanders about as it knows that no win is possible!