CS241: Implementing a game tree for a prototype game
- Administrivia -
- What's next if you want more CS: Simulation &&/|| Topics (depending)
- No lab Friday!
- What game? Connect 4? Gomoku?
- Silly stuff (er... exotic operators). | vs || and... 1 << 24 means what in Java?
- n-ary trees (reprise)
- definition - has a root and n subtrees (each an n-ary tree)
- thus, may be implemented as a root and a list of n-ary trees (its children)
- as a representation for a game tree --
The root of the tree is the beginning (or current) situation in the game.
The children of the root are all the possible positions after one move.
- Groups! Prototype a game tree generator for a very simple game:
- A ridiculous game: Two players, a pile of tokens, on your turn you may take either 1 or 2 -- whoever gets the last one loses.
- Assume you have a Board class (that contains the current state of the game, i.e. how many tokens are left and whose turn it is). Assume it has these methods:
boolean gameOver()
BoardList generateNextLegalBoards()
- Write and test an NaryTree class with
NaryTree(Board)
constructor (which stores the Board as the root)
addKids()
method (which recursively builds the entire tree from this root)
public String toString()
that outputs the tree textually (assume Board has toString())
- Tell me/demo when you are done!
- Demo of same?