AI – Week 12 AI and Games (4) Lee McCluskey, room 2/09

Slides:



Advertisements
Similar presentations
Adversarial Search Chapter 6 Sections 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Advertisements

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.
Adversarial Search Chapter 6 Section 1 – 4.
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
Computer Chess By Thomas Wiest and Rusty Howell. Step 1: Source Code Control We prefer Can.
Application of Artificial intelligence to Chess Playing Capstone Design Project 2004 Jason Cook Bitboards  Bitboards are 64 bit unsigned integers, with.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
AI – Week 11 AI and Games (3) Lee McCluskey, room 2/09
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 Heuristic Search 4 4.0Introduction 4.1An Algorithm for Heuristic Search 4.2Admissibility, Monotonicity, and Informedness 4.3Using Heuristics in Games.
AI – Week 8 AI + 2 Player Games Lee McCluskey, room 3/10
MAE 552 – Heuristic Optimization Lecture 28 April 5, 2002 Topic:Chess Programs Utilizing Tree Searches.
Game Tree Search based on Russ Greiner and Jean-Claude Latombe’s notes.
Adversarial Search: Game Playing Reading: Chess paper.
THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN.
AI – Week 10 AI and Games (2) Lee McCluskey, room 3/10
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
Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
CISC 235: Topic 6 Game Trees.
Minimax.
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.
Prepared by : Walaa Maqdasawi Razan Jararah Supervised by: Dr. Aladdin Masri.
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.
Traditional game playing 2 player adversarial (win => lose) based on search but... huge game trees can't be fully explored.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 9 of 14 Friday, 10 September.
Othello Playing AI Matt Smith. Othello 8x8 Board game 8x8 Board game Try to outflank opponents pieces Try to outflank opponents pieces Winner ends up.
Game Playing. Towards Intelligence? Many researchers attacked “intelligent behavior” by looking to strategy games involving deep thought. Many researchers.
Problems, Problem Spaces and Search
Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search.
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.
Deep Blue. background chess: “the touchstone of the intellect” machine would model thinking, some say chess problem “sharply defined” First chess-playing.
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.
Chess and AI Group Members Abhishek Sugandhi Sanjeet Khaitan Gautam Solanki
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
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 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.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Natural Language Processing AI Revision Lee McCluskey, room 2/07
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
Adversarial Search Chapter 6 Section 1 – 4. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time.
Adversarial Search 2 (Game Playing)
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!)
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
Adversarial Search Chapter 5 Sections 1 – 4. AI & Expert Systems© Dr. Khalid Kaabneh, AAU Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
ADVERSARIAL SEARCH Chapter 6 Section 1 – 4. OUTLINE Optimal decisions α-β pruning Imperfect, real-time decisions.
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.
Search: Games & Adversarial Search Artificial Intelligence CMSC January 28, 2003.
Artificial Intelligence AIMA §5: Adversarial Search
Game Playing Why do AI researchers study game playing?
Optimizing Minmax Alpha-Beta Pruning Real Time Decisions
Adversarial Search.
Kevin Mason Michael Suggs
The Alpha-Beta Procedure
Search and Game Playing
Game Playing Fifth Lecture 2019/4/11.
Mini-Max search Alpha-Beta pruning General concerns on games
CSE (c) S. Tanimoto, 2007 Search 2: AlphaBeta Pruning
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

AI – Week 12 AI and Games (4) Lee McCluskey, room 2/09

AI in 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 Minimax Design – WITH a-b pruning 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 Fox move u If it is better than current stored move then change current stored best move u check whether it is worth going on - If it is not worth it then end procedure, otherwise backtrack (generate next fox move) n Layer with Goose to move - same

Minimax Design – WITH a-b pruning % 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) :- Depth1 is Depth+1, apply(x(SX,SY,f), x(FX,FY,V), Board,Board1), assert(level(Depth1,-10000,_)), 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 new value ValBoard1 < ValBoard, retract(level(Depth,ValBoard,Move)), assert(level(Depth,ValBoard1, [x(SX,SY,f), x(FX,FY,V)])), % check whether it is worth going on by checking ValBoard1 % against the current Depth-1 value if there is one. If this is the % case then make sure minimax does not continue searching. Depth2 is Depth-1, level(Depth2,ValueAbove,_), ifthenelse(ValBoard1 =< ValueAbove,true,fail),!. Goose to go Fox to go Board ValBoard Board1 ValBoard1 Move x(SX,SY,f) TO x(FX,FY,V) Depth Depth+1

Another Example of AI in Games: Chess Same architecture as the Fox and Goose 1. Board (state) representation 2. Board (state) evaluation 3. Move application 4. Move generation 5. Move choice

Representation of Game State / Board [x(1,8,-60), x(2,8,-40), x(3,8,-50), x(4,8,-90), x(5,8,-1000), x(6,8,-50), x(7,8,-40), x(8,8,-60), x(1,7,-10), x(2,7,-10), x(3,7,-10), x(4,7,-10), x(5,7,-10), x(6,7,-10), x(7,7,-10), x(8,7,-10), x(1,6,0), x(2,6,0), x(3,6,0), x(4,6,0), x(5,6,0), x(6,6,0), x(7,6,0), x(8,6,0), x(1,5,0), x(2,5,0), x(3,5,0), x(4,5,0), x(5,5,0), x(6,5,0), x(7,5,0), x(8,5,0), x(1,4,0), x(2,4,0), x(3,4,0), x(4,4,0), x(5,4,0), x(6,4,0), x(7,4,0), x(8,4,0), x(1,3,0), x(2,3,0), x(3,3,0), x(4,3,0), x(5,3,0), x(6,3,0), x(7,3,0), x(8,3,0), x(1,2,10), x(2,2,10), x(3,2,10), x(4,2,10), x(5,2,10), x(6,2,10), x(7,2,10), x(8,2,10), x(1,1,60), x(2,1,40), x(3,1,50), x(4,1,90), x(5,1,1000), x(6,1,50), x(7,1,40), x(8,1,60) ] NB ORDER of co-ordinate data in list is NOT RELEVANT

Board Evaluation % Add up values of pieces. Take into account advanced pawns. % EXAMPLE OF HOW TO TAKE INTO ACCOUNT FEATURES ---- board_evalX([x(X,6,10)|R],S,VAL,white) :- VALA is VAL+ 20, board_evalX(R,S,VALA,white),!. board_evalX([x(X,7,10)|R],S,VAL,white) :- VALA is VAL+ 30, board_evalX(R,S,VALA,white),!. % THIS IS THE MAIN PART board_evalX([x(X,Y,W)|R],S,VAL,white) :- VALA is VAL+W, board_evalX(R,S,VALA,white),!. board_evalX([],S,S,_) :- !.

Chess: Move Generation n Chess Move generator **outline** apply_white( x(X,Y,Z), x(X1,Y1,Z1), B_IN, B_OUT) :- member(x(X,Y,Z), B_IN), member(x(X1,Y1,Z1),B_IN), check_geometry_white(Z,X,Y,X1,Y1), \+ something_in_way_white(Z,X,Y,X1,Y1,B_IN), % make 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].

Example of Geometry check For a white knight.. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X+1, Y1 is Y+2. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X+1, Y1 is Y-2. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X-1, Y1 is Y+2. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X-1, Y1 is Y-2. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X+2, Y1 is Y+1. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X+2, Y1 is Y-1. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X-2, Y1 is Y+1. check_geometry_white(40,X,Y,X1,Y1) :- X1 is X-2, Y1 is Y-1.

Another Game – Connect 3 Use x-y co-ordinates again.. [ x(1,6,0), x(2,6,0), x(3,6,0), x(4,6,0), x(1,5,0), x(2,5,0), x(3,5,0), x(4,5,0), x(1,4,0), x(2,4,0), x(3,4,0), x(4,4,0), x(1,3,0), x(2,3,0), x(3,3,0), x(4,3,0), x(1,2,0), x(2,2,0), x(3,2,0), x(4,2,0), x(1,1,0), x(2,1,0), x(3,1,0), x(4,1,0), ]).

Connect 3 (or Connect N): Move Generation n Move generator **outline** apply_red( x(X,Y,0), B_IN, B_OUT) :- member(x(X,Y,0), B_IN), check_geometry(X,Y,B_IN), % make move remove(x(X,Y,0), B_IN, B1), B_OUT = [x(X,Y,red)|B1].

Connect 3 Geometry Check check_geometry(X,Y,B_IN) :- Y = 1. check_geometry(X,Y,B_IN) :- Y = 2, member(x(X,1,Piece), B_IN), \+ (Piece = 0). check_geometry(X,Y,B_IN) :- Y = 3, member(x(X,1,Piece), B_IN), member(x(X,2,Piece2), B_IN), \+ (Piece = 0), \+ (Piece2 = 0). check_geometry(X,Y,B_IN) :- Y = 4, member(x(X,1,Piece), B_IN), member(x(X,2,Piece2), B_IN), member(x(X,3,Piece3), B_IN), \+ (Piece = 0), \+ (Piece2 = 0). \+ (Piece3 = 0).

Chess: Minimax with alpha-beta pruning minimax(BD,black,D,LIMIT) :- D1 is D+1, getpiece(PIECE), apply_black(x(SX,SY,PIECE), x(FX,FY,V), BD,BD1), assert(level(D1,-10000,_)), minimax(BD1,white,D1,LIMIT), retract(level(D1,ValBD1,_)), level(D,ValBD,Move), ValBD1 < ValBD, retract(level(D,ValBD,Move)), assert(level(D,ValBD1,[x(SX,SY,PIECE), x(FX,FY,V)])), D2 is D-1, level(D2,Above,_), ifthenelse(ValBD1 =< Above,true,fail),!. % for Alpha-Beta, check whether it is worth going on by checking ValDB1 % against the current D-1 value if there is one. If this is the % case then make sure minimax does not continue searching.

Conclusions (AI and Games) Using the basic structure: n board representation, n move generation / application, n board evaluation and n best move search (minimax), you can encode many turn-based games very efficiently. The best move search algorithm makes the computer appear intelligent.