public void testOptimalToString()
 {
     OptimalAIStrategy optimal = new OptimalAIStrategy();
     Assert.AreEqual(" - Optimal", optimal.ToString());
 }
        public void testOptimalSampleGame2()
        {
            OptimalAIStrategy optimal = new OptimalAIStrategy();
            ScoreSheet scoreSheet = new ScoreSheet();
            scoreSheet.setupGame("Yahtzee");
            DieSet dieSet;

            // Sample Game #2 from _Advantage Yahtzee_
            // Hand 1
            dieSet = new DieSet(1, 1, 2, 3, 6);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsFalse(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[1].Value = 3;
            dieSet.Dice[2].Value = 3;
            dieSet.Dice[3].Value = 6;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[1].Value = 2;
            dieSet.Dice[2].Value = 4;
            Assert.AreEqual("Aces", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Aces", dieSet);
            Assert.AreEqual(1, scoreSheet.CurrentScore());

            // Hand 2
            dieSet = new DieSet(1, 2, 2, 2, 3);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 6;
            dieSet.Dice[4].Value = 6;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsTrue(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            Assert.AreEqual("Full House", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Full House", dieSet);
            Assert.AreEqual(26, scoreSheet.CurrentScore());

            // Hand 3
            dieSet = new DieSet(2, 3, 5, 6, 6);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[1].Value = 2;
            dieSet.Dice[2].Value = 6;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[1].Value = 1;
            Assert.AreEqual("Sixes", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Sixes", dieSet);
            Assert.AreEqual(44, scoreSheet.CurrentScore());

            // Hand 4
            dieSet = new DieSet(3, 3, 4, 4, 5);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[1].Value = 5;
            dieSet.Dice[4].Value = 5;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsFalse(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 2;
            dieSet.Dice[2].Value = 5;
            dieSet.Dice[3].Value = 6;
            Assert.AreEqual("Fives", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Fives", dieSet);
            Assert.AreEqual(59, scoreSheet.CurrentScore());

            // Hand 5
            dieSet = new DieSet(1, 2, 3, 6, 6);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 3;
            dieSet.Dice[1].Value = 3;
            dieSet.Dice[2].Value = 5;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 2;
            dieSet.Dice[1].Value = 5;
            Assert.AreEqual("Chance", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Chance", dieSet);
            Assert.AreEqual(83, scoreSheet.CurrentScore());

            // Hand 6
            dieSet = new DieSet(1, 2, 3, 5, 6);
            optimal.reroll(dieSet, 2, scoreSheet);
            //Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            //Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            //Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            //Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            //Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 2;
            dieSet.Dice[4].Value = 6;
            optimal.reroll(dieSet, 1, scoreSheet);
            //Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            //Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            //Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            //Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            //Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 4;
            dieSet.Dice[4].Value = 6;
            Assert.AreEqual("Large Straight", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Large Straight", dieSet);
            Assert.AreEqual(123, scoreSheet.CurrentScore());

            // Hand 7
            dieSet = new DieSet(1, 2, 2, 4, 5);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsFalse(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[3].Value = 1;
            dieSet.Dice[4].Value = 2;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsFalse(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 4;
            dieSet.Dice[3].Value = 5;
            Assert.AreEqual("Twos", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Twos", dieSet);
            Assert.AreEqual(129, scoreSheet.CurrentScore());

            // Hand 8
            dieSet = new DieSet(5, 5, 6, 6, 6);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 2;
            dieSet.Dice[1].Value = 4;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 2;
            dieSet.Dice[1].Value = 4;
            Assert.AreEqual("Three of a Kind", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Three of a Kind", dieSet);
            Assert.AreEqual(153, scoreSheet.CurrentScore());

            // Hand 9
            dieSet = new DieSet(1, 3, 4, 5, 5);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsFalse(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[3].Value = 3;
            dieSet.Dice[4].Value = 6;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[2].Value = 4;
            dieSet.Dice[4].Value = 5;
            Assert.AreEqual("Yahtzee", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Yahtzee", dieSet);
            Assert.AreEqual(153, scoreSheet.CurrentScore());

            // Hand 10
            dieSet = new DieSet(1, 2, 2, 3, 5);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 1;
            dieSet.Dice[1].Value = 1;
            dieSet.Dice[2].Value = 4;
            dieSet.Dice[4].Value = 6;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 2;
            dieSet.Dice[1].Value = 4;
            dieSet.Dice[4].Value = 6;
            Assert.AreEqual("Fours", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Fours", dieSet);
            Assert.AreEqual(161, scoreSheet.CurrentScore());

            // Hand 11
            dieSet = new DieSet(2, 3, 4, 5, 6);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsTrue(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsTrue(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            Assert.AreEqual("Small Straight", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Small Straight", dieSet);
            Assert.AreEqual(191, scoreSheet.CurrentScore());

            // Hand 12
            dieSet = new DieSet(1, 1, 2, 3, 5);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsFalse(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 2;
            dieSet.Dice[1].Value = 3;
            dieSet.Dice[2].Value = 4;
            dieSet.Dice[4].Value = 5;
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsFalse(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsFalse(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsFalse(dieSet.Dice[4].IsFrozen);
            dieSet.Dice[0].Value = 4;
            dieSet.Dice[2].Value = 5;
            dieSet.Dice[4].Value = 6;
            Assert.AreEqual("Threes", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Threes", dieSet);
            Assert.AreEqual(197, scoreSheet.CurrentScore());

            // Hand 13
            dieSet = new DieSet(2, 2, 2, 2, 5);
            optimal.reroll(dieSet, 2, scoreSheet);
            Assert.IsTrue(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            optimal.reroll(dieSet, 1, scoreSheet);
            Assert.IsTrue(dieSet.Dice[0].IsFrozen);
            Assert.IsTrue(dieSet.Dice[1].IsFrozen);
            Assert.IsTrue(dieSet.Dice[2].IsFrozen);
            Assert.IsTrue(dieSet.Dice[3].IsFrozen);
            Assert.IsTrue(dieSet.Dice[4].IsFrozen);
            Assert.AreEqual("Four of a Kind", optimal.chooseCategory(dieSet, scoreSheet));
            scoreSheet.Score("Four of a Kind", dieSet);
            Assert.AreEqual(210, scoreSheet.CurrentScore());
        }