public void testIsUpperBadCategory()
 {
     ScoreSheet scoreSheet = new ScoreSheet();
     scoreSheet.setupGame("Yahtzee");
     scoreSheet.isUpper("Bad Name");
 }
        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 testIsUpper()
        {
            ScoreSheet scoreSheet = new ScoreSheet();
            scoreSheet.setupGame("Yahtzee");

            Assert.IsTrue(scoreSheet.isUpper("Aces"));
            Assert.IsTrue(scoreSheet.isUpper("Twos"));
            Assert.IsTrue(scoreSheet.isUpper("Threes"));
            Assert.IsTrue(scoreSheet.isUpper("Fours"));
            Assert.IsTrue(scoreSheet.isUpper("Fives"));
            Assert.IsTrue(scoreSheet.isUpper("Sixes"));
            Assert.IsFalse(scoreSheet.isUpper("Three of a Kind"));
            Assert.IsFalse(scoreSheet.isUpper("Four of a Kind"));
            Assert.IsFalse(scoreSheet.isUpper("Full House"));
            Assert.IsFalse(scoreSheet.isUpper("Small Straight"));
            Assert.IsFalse(scoreSheet.isUpper("Large Straight"));
            Assert.IsFalse(scoreSheet.isUpper("Chance"));
            Assert.IsFalse(scoreSheet.isUpper("Yahtzee"));
        }