public void testSetupYatzy()
 {
     ScoreSheet scoreSheet = new ScoreSheet();
     //scoreSheet.SetupYatzy();
     scoreSheet.setupGame("Yatzy");
     // confirm 0 score
     Assert.IsTrue(scoreSheet.CurrentScore() == 0);
     // confirm nothing is scored
     List<String> scored = scoreSheet.GetScored();
     Assert.IsEmpty(scored);
     // confirm what is available
     List<String> available = scoreSheet.GetAvailable();
     Assert.Contains("Ones", available);
     Assert.Contains("Twos", available);
     Assert.Contains("Threes", available);
     Assert.Contains("Fours", available);
     Assert.Contains("Fives", available);
     Assert.Contains("Sixes", available);
     Assert.Contains("One Pair", available);
     Assert.Contains("Two Pairs", available);
     Assert.Contains("Three of a Kind", available);
     Assert.Contains("Four of a Kind", available);
     Assert.Contains("Full House", available);
     Assert.Contains("Small Straight", available);
     Assert.Contains("Large Straight", available);
     Assert.Contains("Yahtzee", available);
     Assert.Contains("Chance", available);
     Assert.IsTrue(available.Count == 15);
     // confirm available + score
     available = scoreSheet.GetAvailable(new DieSet(1, 2, 3, 4, 5));
     Assert.Contains("Ones:1", available);
     Assert.Contains("Twos:2", available);
     Assert.Contains("Threes:3", available);
     Assert.Contains("Fours:4", available);
     Assert.Contains("Fives:5", available);
     Assert.Contains("Sixes:0", available);
     Assert.Contains("One Pair:0", available);
     Assert.Contains("Two Pairs:0", available);
     Assert.Contains("Three of a Kind:0", available);
     Assert.Contains("Four of a Kind:0", available);
     Assert.Contains("Full House:0", available);
     Assert.Contains("Small Straight:30", available);
     Assert.Contains("Large Straight:40", available);
     Assert.Contains("Yahtzee:0", available);
     Assert.Contains("Chance:15", available);
     Assert.IsTrue(available.Count == 15);
 }
        protected override string getBest(DieSet dieSet, ScoreSheet scoreSheet)
        {
            string maxCat = "";
            double maxScore = -1;
            int scoreForCat = 0;
            string[] tokens;
            string cat;
            int score;
            int myState = convertScoredToKey(scoreSheet.GetScored());
            int upperScore = scoreSheet.getUpperScore();
            int newUpperScore;
            int newState;
            double futureExp;

            Hashtable tableToUse;
            if (scoreSheet.isYahtzeeScored() & scoreSheet.getYahtzeeScore() > 0)
                tableToUse = allStatesWithYahtzee;
            else
                tableToUse = allStatesNoYahtzee;

            Hashtable tempTableToUse;

            List<String> avail = scoreSheet.GetAvailable(dieSet);

            foreach (string str in avail)
            {
                tokens = str.Split(':');
                cat = tokens[0];
                score = Int32.Parse(tokens[1]);

                if (cat == "Yahtzee" & score > 0)
                    tempTableToUse = allStatesWithYahtzee;
                else
                    tempTableToUse = tableToUse;

                newState = myState + (int)catConversion[cat];
                newUpperScore = upperScore;
                if (scoreSheet.isUpper(cat))
                    newUpperScore += score;

                newUpperScore = Math.Min(63, newUpperScore);

                if (scoreSheet.getYahtzeeScore() > 0 & scoreSheet.isYahtzee(dieSet.getCount()))
                    score += 100;

                futureExp = (double)((Hashtable)tempTableToUse[newUpperScore])[newState];
                if (futureExp + score > maxScore)
                {
                    maxScore = futureExp + score;
                    maxCat = cat;
                    scoreForCat = score;
                }
            }

            return maxCat+":"+scoreForCat.ToString()+":"+maxScore;
        }
        public void testScore()
        {
            ScoreSheet scoreSheet = new ScoreSheet();
            scoreSheet.setupGame("Yahtzee");
            int score;

            // score ones
            DieSet dieSet = new DieSet(1, 1, 1, 1, 1);
            score = scoreSheet.Score("Aces", dieSet);
            Assert.IsTrue(score == 5);
            Assert.IsTrue(scoreSheet.CurrentScore() == 5);
            // confirm Ones are scored
            List<String> scored = scoreSheet.GetScored();
            Assert.IsTrue(scored.Count == 1);
            Assert.Contains("Aces:5", scored);
            // confirm Ones are no longer available
            List<String> available = scoreSheet.GetAvailable();
            Assert.IsTrue(available.Count == 12);
            Assert.IsFalse(available.Contains("Aces"));

            // score twos
            dieSet = new DieSet(2, 2, 2, 2, 2);
            score = scoreSheet.Score("Twos", dieSet);
            Assert.IsTrue(score == 10);
            Assert.IsTrue(scoreSheet.CurrentScore() == 15);
            // confirm Ones, Twos are scored
            scored = scoreSheet.GetScored();
            Assert.IsTrue(scored.Count == 2);
            Assert.Contains("Aces:5", scored);
            Assert.Contains("Twos:10", scored);
            // confirm Ones, Twos are no longer available
            available = scoreSheet.GetAvailable();
            Assert.IsTrue(available.Count == 11);
            Assert.IsFalse(available.Contains("Aces"));
            Assert.IsFalse(available.Contains("Twos"));

            // score threes
            dieSet = new DieSet(3, 3, 3, 3, 3);
            score = scoreSheet.Score("Threes", dieSet);
            Assert.IsTrue(score == 15);
            Assert.IsTrue(scoreSheet.CurrentScore() == 30);
            // confirm Ones, Twos, Threes are scored
            scored = scoreSheet.GetScored();
            Assert.IsTrue(scored.Count == 3);
            Assert.Contains("Aces:5", scored);
            Assert.Contains("Twos:10", scored);
            Assert.Contains("Threes:15", scored);
            // confirm Ones, Twos, Thress are no longer available
            available = scoreSheet.GetAvailable();
            Assert.IsTrue(available.Count == 10);
            Assert.IsFalse(available.Contains("Aces"));
            Assert.IsFalse(available.Contains("Twos"));
            Assert.IsFalse(available.Contains("Threes"));
        }