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()); }