- - - - - - - -
\ · · · · · · · · \
\ · · · · · · · · \
\ · · · · · · · · \
\ · · · · · · · · \
\ · · · · · · · · \
\ · · · · · · · · \
\ · · · · · · · · \
\ · · · · · · · · \
- - - - - - - -
- - - - - - - -
\ · · · · · · ● ● \
\ · · · · · · ● ● \
\ · · · · · · ● · \
\ · · · · · ● · · \
\ · · · · · · · · \
\ · ● · · · · · · \
\ · · · ● · · · · \
\ · · · · · · · · \
- - - - - - - -
- - - - - - - -
\ · · · · · · ● ● \
\ · · · · · · ● ● \
\ · · · · · · ● ● \
\ · · · · · ● ● ● \
\ · · · ● ● ● ● · \
\ ● ● ● ● ● · ● · \
\ ● ● ● ● · · · · \
\ · · · · · · · · \
- - - - - - - -
General game players are systems able to accept descriptions of arbitrary games at runtime and able to use such descriptions to play those games effectively without human intervention. In other words, they do not know the rules until the games start. Unlike specialized game players, general game players cannot rely on algorithms designed in advance for specific games.
As in the previous lab, use Teammaker to form your team. You can log in to that site to indicate your partner preference. Once you and your partner have specified each other, a GitHub repository will be created for your team.
Before you begin, copy over your MinMaxPlayers.py, Heuristics.py, and (if you implemented it) TournamentPlayers.py from last week. If you did not implement TournamentPlayers.py, a basic version has been provided for you. You'll need to edit this to make it viable for game play. This will allow you to play your MCTS agent (once you have implemented it) against last week's alpha/beta pruning agents, for the games Mancala and Breakthrough.
In this lab you will use Monte Carlo tree search to implement a general game playing agent. The primary Python file you will be modifying is MonteCarloTreeSearch.py. You have also been provided several files that should look familiar from lab 3:
There are also two new python programs:
And finally, you should have one "compiled" python program:
Just like last week, all games are played using PlayGame.py. The interface has been updated slightly; you can use the -h option for more information.
To get started, try playing hex against your partner. This game has a large branching factor, so you'll likely have to scroll up to see the game board between turns. The game is played on a grid where (0,0) is a the top left corner and (7,7) is the bottom right corner.
./PlayGame.py hex human human
function MCTS(root_node)
loop for number of rollouts
node = root_node
initialize path with node
# selection
while all children of node are expanded and node not terminal
node = choose child with max UCB value
(based on parent player's perspective)
add node to path
# expansion
if node not terminal
pick random unexplored move
apply move to the node's state to get a next_state
if str(next_state) in tree's nodes
find next_node in tree's nodes using key str(next_state)
else
create a next_node for the next_state
add next_node to graph's nodes using key str(next_state)
add the next_node to the node's children using move as key
add the next_node to the path
# simulation
outcome = random_playout(next_node's state)
else
outcome = node's state winner
# backpropagation
update values for all nodes in path based on outcome
For any extension that you try, describe what you did and the outcome in a file called extensions.txt.