コード例 #1
0
        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());
        }
コード例 #2
0
        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));
        }