Apr 9
Discuss the search techniques for
two player alternating complete information games,
i.e. tic-tac-toe, chess, checkers, ....
This is usually thought of as another search tree,
with the edges as possible moves and the root
of the tree the starting position.
If we assign a value to each game position, with
positive being good for one player and negative
meaning bad, then successive players will choose
moves that maximize or minimize among the branches.
Thus searching for the best move by considering
what your opponent will do requires a "min-max" search
algorithm.
This can be coded as
- explicitly one search_min() and one search_max(), typically with value(game) returning positive for 1st player and negagive for 2nd, or
- in one negamax_search() routine which combines both, typically with value(game) returning positive for whosever move is next,
- using an alpha-beta pruning technique to eliminate branches where a better alternative is already known
Discuss all these ideas, using
- game_search.py (Nim - takeaway stones - search_min & search_max)
- game_engine_template.py (negamax, alphabeta)
- tic_tac_toe_alpha_beta.py
This
bag game
article explains the alpha-beta behind alpha-beta pretty well.
So to implement a board game, you need
- a representation of the board data
- a representation of "a move"
- functions to display and/or print
- moves(game) # (ideally sorted) list of possible moves
- value(game) # (possibly approximate) value of position
... and then you plug it into the game engine.
Coding possibilities in class and/or for Thursday :
---