public Move MakeMove(Gamestate gamestate) { LookAtLastRound(gamestate); Move move = GetMove(gamestate); while (!IsValidMove(move)) { move = MoveClass.GetRandomMove(); } if (move == Move.D) { MyDynamiteRemaining -= 1; } return(move); }
public Move GetMove(Gamestate gamestate) { Move move; if (gamestate.GetRounds().Length == 0) { return(Move.D); } var myLastMove = gamestate.GetRounds().Last().GetP1(); var allResponses = DictionaryLogic.GetResponsesToConditionalRounds(gamestate.GetRounds(), round => round.GetP1() == myLastMove); Move?sigMove = MoveClass.GetSignificantPickFrom(allResponses); if (sigMove != null) { return(MoveClass.GetOppositeMove((Move)sigMove)); } //todo: predicted patterns if (DrawLogic.WasDrawLastRound(gamestate)) { return(DrawLogic.GetMoveGivenDraw(gamestate)); } //Predicted play if (gamestate.GetRounds().Length > 50) { var dict = DictionaryLogic.GetFrequencyInRounds(gamestate.GetRounds()); Move predictedEnemyMove = MoveClass.GetWeightedPickFrom(dict); move = MoveClass.GetOppositeMove(predictedEnemyMove); return(move); } return(MoveClass.GetRandomMove()); }
public static Move GetMoveGivenDraw(Gamestate gamestate) { int numberDraws = GetNumberOfDraws(gamestate); int drawStreak = GetDrawStreak(gamestate); var allResponses = DictionaryLogic.GetResponsesToConditionalRounds(gamestate.GetRounds(), WasDrawOnRound); //See if the opponent has a strategy for this many points Move myLastMove = gamestate.GetRounds().Last().GetP1(); var streakResponses = DictionaryLogic.GetResponsesToConditionalRounds( GetRoundsAfterDrawStreak(gamestate, drawStreak), round => round.GetP1() == myLastMove); Move?sigMove = MoveClass.GetSignificantPickFrom(streakResponses); if (sigMove != null) { return(MoveClass.GetFinisherMove((Move)sigMove)); } Move move = MoveClass.GetWeightedPickFrom(allResponses); return(MoveClass.GetFinisherMove(move)); }