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

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

Tic Tac Toe Architecture CSE 5290 – Artificial Intelligence 06/13/2011 Christopher Hepler.
AI – Week 5 Implementing your own AI Planner in Prolog – part II : HEURISTICS Lee McCluskey, room 2/09
CSC 423 ARTIFICIAL INTELLIGENCE
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Mahgul Gulzai Moomal Umer Rabail Hafeez
Problem Solving Using Search Reduce a problem to one of searching a graph. View problem solving as a process of moving through a sequence of problem states.
CPSC 322 Introduction to Artificial Intelligence October 25, 2004.
This time: Outline Game playing The minimax algorithm
Using Search in Problem Solving
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Game Playing CSC361 AI CSC361: Game Playing.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Ch.6: Adversarial Search Fall 2008 Marco Valtorta.
Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour.
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)
Game-Playing Read Chapter 6 Adversarial Search. Game Types Two-person games vs multi-person –chess vs monopoly Perfect Information vs Imperfect –checkers.
AI – Week 5 An Introduction to AI Planning Lee McCluskey, room 2/07
CIA2326 Week3: Prolog: List Processing Lee McCluskey First term:
AI – Week 8 AI + 2 Player Games Lee McCluskey, room 3/10
Adversarial Search: Game Playing Reading: Chess paper.
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN.
AI – Week 12 AI and Games (4) Lee McCluskey, room 2/09
AI – Week 10 AI and Games (2) Lee McCluskey, room 3/10
Game-Playing Read Chapter 6 Adversarial Search. State-Space Model Modified States the same Operators depend on whose turn Goal: As before: win or win.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
Game Playing State-of-the-Art  Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in Used an endgame database defining.
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.
CSC 412: AI Adversarial Search
CISC 235: Topic 6 Game Trees.
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.
Artificial Intelligence: Planning Lecture 6 Problems with state space search Planning Operators A Simple Planning Algorithm (Game Playing)
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.
Mark Dunlop, Computer and Information Sciences, Strathclyde University 1 Algorithms & Complexity 5 Games Mark D Dunlop.
Connect Four AI Robert Burns and Brett Crawford. Connect Four  A board with at least six rows and seven columns  Two players: one with red discs and.
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.
Quiz 4 : Minimax Minimax is a paranoid algorithm. True
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
1 5. Abstract Data Structures & Algorithms 5.1 Data Structure Fundamentals.
Game Playing Revision Mini-Max search Alpha-Beta pruning General concerns on games.
Today’s Topics Playing Deterministic (no Dice, etc) Games –Mini-max –  -  pruning –ML and games? 1997: Computer Chess Player (IBM’s Deep Blue) Beat Human.
AI – Week 5 More on HEURISTICS and domain modelling Lee McCluskey, room 2/09
Game tree search Chapter 6 (6.1 to 6.3 and 6.6) cover games. 6.6 covers state of the art game players in particular. 6.5 covers games that involve uncertainty.
Artificial Intelligence
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.
Artificial Intelligence Midterm 고려대학교 컴퓨터학과 자연어처리 연구실 임 해 창.
Adversarial Search 2 (Game Playing)
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
Luca Weibel Honors Track: Competitive Programming & Problem Solving Partisan game theory.
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.
Iterative Deepening A*
32: Games 3 Functional Data
Analysis and design of algorithm
CMSC 202 Trees.
Mini-Max search Alpha-Beta pruning General concerns on games
CS51A David Kauchak Spring 2019
Unit II Game Playing.
Presentation transcript:

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

Artform Research Group AI in Games: practical example Finish off implementation of a 2-player board game in Prolog. 1. Board (state) representation 2. Board (state) evaluation 3. Move application 4. Move generation 5. Best Move choice: Search (Mini-max) algorithm This week we will cover 4, but leave out alpha/beta pruning! LAST WEEK THIS WEEK

Artform Research Group Fox and Goose – recall from last week… goose fox Goal: Goose in last column HOME

Artform Research Group Last Week - Representation of Board b(1, [ x(1,1,w), x(1,2,w), x(1,3,w), x(1,4,0), x(2,1,w), x(2,2,0), x(2,3,w), x(2,4,0), x(3,1,0), x(3,2,f), x(3,3,0), x(3,4,0), x(4,1,0), x(4,2,0), x(4,3,f), x(4,4,0), x(5,1,g), x(5,2,0), x(5,3,0), x(5,4,0), x(6,1,0), x(6,2,w), x(6,3,w), x(6,4,0), x(7,1,0), x(7,2,0), x(7,3,0), x(7,4,0), ]). NB ORDER of co-ordinate data in list is NOT RELEVANT

Artform Research Group Last Week-Move Application/ Generation % Assume Z is either f or g apply( x(X,Y,Z), x(X1,Y1,Z1), B_IN, B_OUT) :- % move to empty square OR fox eats goose.. (Z1 = 0 ; (Z=f, Z1=g)), member(x(X,Y,Z), B_IN), member(x(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(x(X,Y,Z), B_IN, B1), remove(x(X1,Y1,Z1), B1, B2), B_OUT = [x(X1,Y1,Z),x(X,Y,0)|B2]. Generate and Test Fixes parameters Tests parameters Generates Deterministic procedures – only one possible output

Artform Research Group More ‘intelligent’ board evaluation board_eval(B, _, 10000) :- % if Goose is in column 4 then member(x(_,4,g), B),!. board_eval(B, goose, 10000) :- % if Goose to move in col 3 then member(x(_,3,g), B),!. board_eval(B, goose, -10) :- % if fox next to goose and goose to move then -10 member(x(X,Y,g), B), member(x(X1,Y1,f), B), next(X,Y,X1,Y1),!. board_eval(B, _, ) :- % if no Goose then \+ member(x(_,_,g), B),!. board_eval(B, fox, ) :- % if fox next to goose and fox to move then member(x(X,Y,g), B), member(x(X1,Y1,f), B), next(X,Y,X1,Y1),!. board_eval(B, fox, -5) :- % if fox one away from goose and fox to move then -5 member(x(X,Y,g), B), member(x(X1,Y1,f), B), member(x(X2,Y2,0), B), next(X,Y,X2,Y2), next(X2,Y2,X1,Y1),!. % default board_eval(B,_, 0 ) :- !. We let the board evaluation function have extra information “next to move”

Artform Research Group MiniMax: Initialisation and I/O Spec *** minimax(B,F_OR_G,0) *** INPUTS: PARAMETERS: BOARD (B), who is move (F_OR_G), start ply = 0 GLOBAL DATA: - Leaf count (leaf_count(0) – a fact), - Search Depth( limit(D) – a fact) - Initiative data structure attached to the route node – level( LEVEL OF NODE, VALUE OF BOARD, BEST MOVE) – initially level(0,worst value, don’t know) OUTPUTS: The best move attached to the root node and its value – line retract(level(0,Val,[x(A1,B1,Z1),x(A2,B2,Z2)])), …. % minimax initialisation - assert_start_information(fox,D) :- assert(level(0, ,_)), % starts with worst value for fox assert(leaf_count(0)), % for statistics assert(limit(D)), !. % asserts the SEARCH DEPTH as a fact

Artform Research Group MiniMax: outline spec n Bottom Layer -Base Case - we have reached the limit (depth) of the Game Tree u Use static evaluation to get a value for the board n Layer with Fox to move: u Generate Next Fox Move u Initialise Level Value to Worst u Minimax with goose to move u Eventually get value for move u If it is better than current stored move then change current stored best move n Layer with Goose to move - same

Artform Research Group Minimax Design – Bottom Layer % BASE case - we are at the bottom of the search tree % Player = who's turn, Depth = depth of search minimax(Board,Player,Depth) :- limit(Depthlimit), Depthlimit = Depth, % we are at the bottom of the search tree board_eval(Board,Player,Boardval), retract(level(Depth,_,_)), assert(level(Depth,Boardval,_)), The level(Depth,Boardval,M) predicate is like a global variable – it stores: Depth – current depth of search Boardval – estimated value of board M – current best move LEADING FROM current board

Artform Research Group Minimax Design – Part 2 % RECURSIVE case - we are NOT at the bottom of the search tree % Board = BOARD, fox's turn, Depth = current depth of search minimax(Board,fox,Depth) :- % generate the next fox move and new board Board1 apply(x(SX,SY,f), x(FX,FY,V), Board,Board1), % initialise new level Depth1, and dummy val Depth1 is Depth+1, assert(level(Depth1,-10000,_)), % find the best value of Board1 - goose to go minimax(Board1,goose,Depth1), retract(level(Depth1,ValBoard1,_)), level(Depth,ValBoard,Move), % if the new value recorded is better (less) that the % current value of this node then % record the new value ValBoard1 < ValBoard, retract(level(Depth,ValBoard,Move)), assert(level(Depth,ValBoard1,[x(SX,SY,f), x(FX,FY,V)])), % now backtrack to “apply” to get the next move fail. Goose to go Fox to go Board ValBoard Board1 ValBoard1 Move x(SX,SY,f) TO x(FX,FY,V) Depth Depth+1

Artform Research Group Minimax Design – Part 3 % Fox to move, non base case minimax(Board,goose,Depth) :- % generate the next fox move and new board Board1 apply(x(SX,SY,g), x(FX,FY,0), Board,Board1), % initialise new level Depth1, and dummy valuation Depth1 is Depth+1, assert(level(Depth1,10000,_)), % find the best value of Board1 - fox to go minimax(Board1,fox,Depth1), retract(level(Depth1,ValBoard1,_)), level(Depth,ValBoard,Move), % if the new value recorded is better (more) that the % current value of this node then % record the new value ValBoard1 > ValBoard, retract(level(Depth,ValBoard,Move)), assert(level(Depth,ValBoard1,[x(SX,SY,g), x(FX,FY,0)])), fail. minimax(_,_,_) :- !.

Artform Research Group Conclusions (AI and Games) To build AI into a game one method is to: u Design a representation of the world (game) state u Design a static state evaluation function u Design Move application and Move generation simulation functions (possibly use an explicit representation for moves) u Design a search algorithm that searches through states to find the optimum move For two player/turns/perfect info games, a good search techniques is Minimax

Artform Research Group Conclusions (Prolog) Prolog is a good implementation platform for AI because: u Very expressive state/action representations can be written as Prolog facts – even containing parameters u It has a form of Depth First search built into it, and its backtracking technique allows the implementation of any type of search strategy u Its parameter matching techniques allows procedures to be used for more than one function (eg move application AND generation) u Its procedures can be interpreted as rules u Its interpreted nature is flexible to allow easy experimentation BUT – Its slow It can be dirty (assert and retract) It is possible but not always easy to hook it up to other systems (eg graphics, robots, …)