public void TakeTurn() /// TakeTurn is used in the main loop. It is different for Human v AI because the Human player will choose which dice /// to hold and which slot to set the score by different conventions than the AI. This method rolls the dice three times, /// asks where to put the score, makes sure that slot is open, then sets the score the open slot. { int[] dice = new int[5]; Console.WriteLine("{0}'s turn!\n", name); Console.WriteLine("{0} roll 1: ", name); RollDice(dice); Console.WriteLine(""); Console.WriteLine("{0} roll 2: ", name); ReRoll(dice); Console.WriteLine(""); Console.WriteLine("{0} roll 3: ", name); ReRoll(dice); Console.WriteLine(""); Console.WriteLine("Please enter 0 to quit!"); Console.WriteLine("Please enter which slot you would like to put your score: "); int slot = UI.PromptInt("Please enter which slot you would like to put your score: "); while (score.SlotOpen(slot) == false) { if (slot == 0) { Quit(); } else { slot = UI.PromptInt("Please enter a valid slot number: "); } } score.SetScore(dice, slot); Console.WriteLine("\n"); }
private int EvaluateMaximumScore(int[] dice) /// EvaluateMaximumScore is not used in this AI, but was used for an earlier AI that only got one roll. May use this /// for an "easy mode". Also known as pessimistic AI, RIP Bill. Simpler version of BestSlotValue which returns a dictionary. { int ones = score.ScoreUpper(dice, 1); int twos = score.ScoreUpper(dice, 2); int threes = score.ScoreUpper(dice, 3); int fours = score.ScoreUpper(dice, 4); int fives = score.ScoreUpper(dice, 5); int sixes = score.ScoreUpper(dice, 6); int threeOfAKind = score.ScoreThreeOfAKind(dice); int fourOfAKind = score.ScoreFourOfAKind(dice); int fullHouse = score.ScoreFullHouse(dice); int smallStraight = score.ScoreSmallStraight(dice); int largeStraight = score.ScoreLargeStraight(dice); int chance = score.ScoreChance(dice); int yahtzee = score.ScoreYahtzee(dice); int max = 0; int slot = 0; if (ones >= max && score.SlotOpen(1)) { max = ones; slot = 1; } if (twos >= max && score.SlotOpen(2)) { max = twos; slot = 2; } if (threes >= max && score.SlotOpen(3)) { max = threes; slot = 3; } if (fours >= max && score.SlotOpen(4)) { max = fours; slot = 4; } if (fives >= max && score.SlotOpen(5)) { max = fives; slot = 5; } if (sixes >= max && score.SlotOpen(6)) { max = sixes; slot = 6; } if (threeOfAKind >= max && score.SlotOpen(7)) { max = threeOfAKind; slot = 7; } if (fourOfAKind >= max && score.SlotOpen(8)) { max = fourOfAKind; slot = 8; } if (fullHouse >= max && score.SlotOpen(9)) { max = fullHouse; slot = 9; } if (smallStraight >= max && score.SlotOpen(10)) { max = smallStraight; slot = 10; } if (largeStraight >= max && score.SlotOpen(11)) { max = largeStraight; slot = 11; } if (chance >= max && score.SlotOpen(12)) { max = chance; slot = 12; } if (yahtzee >= max && score.SlotOpen(13)) { max = yahtzee; slot = 13; } return(slot); }