nn
that creates and trains
a neural network for playing solitaire Yahtzee. This module must define
train
that reads your training
examples from standard inputa and returns a trained neural network;
and
NNStrategy
that has an initializer
that can take the object returned from train
as its parameter
and has two methods choose_dice
and choose_category
that meet the requirements of the yahtzee.evaluate_strategy
function.
There are four steps to creating the neural network.
query_optimal.sh
program in /c/cs474/hw6
.
That program reads positions from standard input where each position
is given as a comma-separated list of the state of the scoresheet
(as returned by YahtzeeScoresheet.as_state_string
),
the current roll, and the number of rerolls, and outputs the positions
with either the dice chosen to keep or the string representation of
the category to score in.
[jrg94@scorpion Yahtzee]$ /c/cs474/hw6/query_optimal.sh UP0,11223,2 UP0,11223,2,[22] 2 3 4 5 6 3K 4K FH SS LS C UP50,11166,2 2 3 4 5 6 3K 4K FH SS LS C UP50,11166,2,[111] 2 3 4 5 6 3K 4K FH SS LS UP60,11666,2 2 3 4 5 6 3K 4K FH SS LS UP60,11666,2,[11] 2 3 4 5 6 3K 4K FH SS LS UP60,11666,1 2 3 4 5 6 3K 4K FH SS LS UP60,11666,1,[11] 2 3 4 5 6 3K 4K FH SS LS UP60,11666,0 2 3 4 5 6 3K 4K FH SS LS UP60,11666,0,C 2 3 4 5 6 3K 4K FH SS LS C Y UP60,16666,2 2 3 4 5 6 3K 4K FH SS LS C Y UP60,16666,2,[1] 2 3 4 5 6 3K 4K FH SS LS C Y+ UP60,16666,2 2 3 4 5 6 3K 4K FH SS LS C Y+ UP60,16666,2,[6666]
yahtzee.YahtzeeRoll.select_for_xxx
methods.
You will have to write code that determines which of these classes
best matches the output of the optimal player for each position.
Dropout
layers) but the architecture may be whatever
you wish. The nn.train
function should read your
training examples from standard input, train your neural network,
and return it.
NNStrategy
that defines
train
;
choose_dice
that takes a YahtzeeScoresheet
, a YahtzeeRoll
, and the number of rerolls,
encodes that position as input suitable for your neural network,
computes the output of your neural network, and returns a subroll
of the given roll as indicated by the output of the neural network; and
choose_category
that takes a YahtzeeScoresheet
and a YahtzeeRoll
,
encodes that position as input suitable for your neural network,
computes the output of your neural network, and returns an unused
category as indicated by the output of the neural network.
/c/cs474/hw6
are three Python 3 modules:
yahtzee.py
that defines classes that implement the rules of Yahtzee;
multiset.py
that defines classes required by the yahtzee
module; and
test_yahtzee.py
that implements the test driver
yahtzee.jar
that contains the compiled Java implementation
bonusyahtzeestate.dat
a data file required by that implementation
query_optimal.sh
a shell script that reads solitaire Yahtzee positions and outputs those positions with the optimal choice
nn.py
module along with any other supporting modules, your training data as training.dat
, and your log.
Submissions may use no more than 100,000 examples for training and
may not use more than 300 neurons in hidden layers in the neural network (not
including anything in Dropout
layers).