Algorithms & Data Structures for Games Minor Games Programming Algorithms & Data Structures for Games Lecture 5
Algorithms and Data Structures Feedback previous lectures Theory: Boards Game Algorithms Jan Verhoeven j.verhoeven@windesheim.nl
Theory: Some Board Game Algorithms Static Evaluation function Alpha-beta pruning Move ordering Iterative deepening Killer heuristic Transposition table Zobrist hashing
Static Evaluation function http://en.wikipedia.org/wiki/Evaluation_function Not done at leave nodes! But what is a stable situation? Horizon effect?
Alpha-beta pruning http://en.wikipedia.org/wiki/Alpha-beta_pruning Greatest effect when the moves are ordered! Best move first …. Move ordering
Move ordering Best moves first (more pruning!): Defend against direct winning opponent’s moves (“mate”-moves) Capture moves Killer moves (see later)
Iterative deepening -1- Iterative deepening means repeatedly calling a fixed depth search routine with increasing depth until a time limit is exceeded or maximum search depth has been reached. http://www.xs4all.nl/~verhelst/chess/search .html
Iterative deepening -2- The advantage of doing this is that you do not have to choose a search depth in advance; you can always use the result of the last completed search.
Iterative deepening -3- Also because many position evaluations and best moves are stored in the transposition table, the deeper search trees can have a much better move ordering than when starting immediately searching at a deep level.
Killer heuristic The killer heuristic is used to improve the move ordering. The idea is that a good move in one branch of the tree is also good at another branch at the same depth. For this purpose at each ply we maintain one or two killer moves that are searched before other moves are searched. A successful cutoff by a non-killer move overwrites one of the killer moves for that ply.
Transposition table The transposition table is a hashing scheme to detect positions in different branches of the search tree that are identical. http://en.wikipedia.org/wiki/Transposition_table
Zobrist hashing http://en.wikipedia.org/wiki/Zobrist_hashing A smart way to construct hash keys for a transposition table, depending on the board position.
Transposition Tables Presentation See and study blackboard: Transposition Tables.ppt And if you are really interested: http://chessprogramming.wikispaces.com/Albert+Zobrist
Exercise: -give the transposition table (size=8) - randoms are in octal 1 0123 0456 2 0172 0263 3 0314 0557 4 0662 0527 5 0116 0374 6 0252 0153 7 0771 0722 8 0742 0275 9 0337 0142 Situation 1: Situation 2:
Extra Presentation, please read and don’t study … On blackboard: Game programming workshop Japan By prof.dr. Jaap van den Herik
Homework This Chapter 10.5.2 Articles, Presentations and the Internet Homework, study/read: This Chapter 10.5.2 Articles, Presentations and the Internet
Practice (next THURSDAY !!!) Practice, be prepared for: Implement a Transposition Table class using Zobrist hashing for a given board game. Make a test program to demonstrate this class.