160 likes | 306 Views
Advanced Game Play. Prepare for 4x4x4 tic-tac-toe. Checkers is Solved!. Checkers has approximately 500 billion positions Jonathan Schaeffer Retrograde analysis All combinations of 1-10 pieces (endgame positions) Standard openings (first ~10 moves)
E N D
Advanced Game Play Prepare for 4x4x4 tic-tac-toe
Checkers is Solved! • Checkers has approximately 500 billion positions • Jonathan Schaeffer • Retrograde analysis • All combinations of 1-10 pieces (endgame positions) • Standard openings (first ~10 moves) • “middle game” solved using search with heuristics
Transposition Tables - Hash Tables • After a position is analyzed, an entry is made in a hash table so that if that position is encountered again, its value can be immediately reported • Often the limiting factor is the size of the available hash table • The same moves made in a different order will often generate the same positions • Hash tables should usually contain the position, the evaluation, and the level of that evaluation
Zobrist Hashing Source: http://research.cs.wisc.edu/techreports/1970/TR88.pdf • ZobristHashing was developed specifically for games in which game states differ slightly from move to move. • Utilizes properties of XOR (riuniform random) • ri XOR (rj XOR rk) = (riXOR rj) XOR rk • ri XOR rj = rj XOR ri • ri XOR ri = 0 • If (si = r1 XOR r2 XOR r3 XOR r4… XOR ri) then • si is a random sequence • {si} is uniformly distributed
Step 1 – Create a bit string for every possible combination of piece and square • Example – tic-tac-toe (standard game) • There are nine squares • Each square can be in one of three states • Empty • Contain an “X” • Contain an “O” • There are 9*3 = 27 piece-square combinations • Create 27 bit strings, one for each piece-square combination.
Step 1 (continued) • BitStringsquarePiece[N_Squares][N_Pieces]; • For(int square=0;square<N_Squares;square++) • For(int piece=0;piece<N_Pieces;pieces++) • squarePiece[square][piece] = randomBitString()
Step 2 • Initialize the board to empty • zorbristHash = 0; • For every square on the board zorbristHash = zorbristHash XOR squarePiece[square][EMPTY_SQUARE];
Step 3 • Each time a player makes a move • Remove the old state for that square • zorbristHash = zorbristHash XOR squarePiece[square][currentOccupant]; • Add the new state for that square • zorbristHash = zorbristHash XOR squarePiece[square][newOccupant]; • Example – x moves in the center • zorbristHash =zorbristHash XOR squarePiece[4][Empty]; • zorbristHash = zorbristHash XOR squarePiece[4][X];
4x4x4 Tic-Tac-Toe • 64 Squares • 3 states/Square • 3*64 unique bit strings
Symmetry in simple tic-tac-toe • 4 rotations • 2 reflection
4x4x4 tic-tac-toe • Number of positions • 64 squares • Each square can be empty, have a white stone, or a black stone • 364 is approximately 1030! • Lots of symmetry – but only the 4 rotations are obvious.
Exploiting Equivalence • Convert all positions to a “normalized” form • For example: • When a position is encountered • Find the equivalent position with the smallest hash value • All equivalent positions use the same representation
Killer Move Heuristic • Moves that are strong in one position tend to be strong in other positions too. • Remember the moves that are strong at each depth • Try these moves first, as they are likely to cause alpha-beta pruning
Null-move Heuristic • Used in alpha-beta search • Player to move “forfeits” a move and continues search to a shallow depth to see if the position is “so good” that alpha-beta will still cut it off. • Extra time is spent doing the shallow search if it does not provide a cut-off. • When it does provide a cut-off, the branch can be abandoned without deeper search.
Aspiration Window Search • Alpha-beta search with a guess at the range of the value of the position • Make the range as narrow as you can with a high probability that the true value is inside that range. • Typically, center the range on the expected value • If the returned value is within the range • The value is the same as what you would have achieved with normal alpha-beta, but there was probably better pruning • If the value is at or above beta • The position is better than expected • If the value is at or below alpha • We were too optimistic – another search is needed.