Пример #1
0
        public Move DrawScenario(int sticksODynamite, int enemyDynSticks)
        {
            DrawStreak++;
            if (FirstDraw)
            {
                FirstDraw = false;
            }
            string highestChanceMove = DrawCounter.Aggregate((x,
                                                              y) => x.Value > y.Value ? x : y).Key;
            bool counterValid = (DrawCounter.Values.Count(x => x.Equals
                                                              (DrawCounter.Values.Max())) != 5);

            if (sticksODynamite == 0)
            {
                return(NoDynamiteLeft(highestChanceMove, counterValid, enemyDynSticks));
            }
            if (DrawStreak == 4)
            {
                return(RandomInstance.DynamiteChanceMove(RandomInstance.RandomMove(), 2, 3));
            }
            if (!counterValid | enemyDynSticks == 0)
            {
                return(RandomInstance.DynamiteChanceMove(RandomInstance.RandomMove(IncludeWater), 1, 6));
            }
            if ("Water" == highestChanceMove)
            {
                return(RandomInstance.DynamiteChanceMove(RandomInstance.RandomMove(), 1, 15));
            }
            if ("Dynamite" == highestChanceMove)
            {
                return(RandomInstance.DynamiteChanceMove(RandomInstance.RandomMove(includeWater: true), 1, 4));
            }
            return(RandomInstance.DynamiteChanceMove(RandomInstance.RandomMove(), 1, 5));
        }
Пример #2
0
        public Move MakeMove(Gamestate gamestate)
        {
            if (gamestate.GetRounds().Length == 0)
            {
                return(Move.R);
            }
            List <Round> allRounds = gamestate.GetRounds().ToList();

            UpdateLastNMoves(allRounds);
            if (allRounds.Last().GetP2() == Move.D)
            {
                EnemyDynSticks--;
            }
            if (LastNMoves.All(o => o == LastNMoves[0]) & LastNMoves.Count >= N)
            {
                return(CounterMove(LastNMoves[0]));
            }
            if (RandomInstance.RandomInstance.Next(100) == 0)
            {
                N = RandomInstance.RandomInstance.Next(3, 6);
            }
            if (allRounds.Count > 1 & !DrawTools.FirstDraw)
            {
                if (allRounds[allRounds.Count - 2].GetP1() == allRounds[allRounds.Count - 2].GetP2())
                {
                    DrawTools.UpdateDrawCounter(allRounds, EnemyDynSticks);
                }
            }
            Move nextMove;

            if (allRounds.Last().GetP1() == allRounds.Last().GetP2())
            {
                nextMove = DrawTools.DrawScenario(SticksODynamite, EnemyDynSticks);
            }
            else
            {
                DrawTools.DrawStreak = 0;
                DrawTools.FirstDraw  = true;
                if (SticksODynamite > 0)
                {
                    nextMove = RandomInstance.DynamiteChanceMove(RandomInstance.RandomMove(), 1, 100);
                }
                else
                {
                    nextMove = RandomInstance.RandomMove();
                }
            }
            if (nextMove == Move.D)
            {
                SticksODynamite--;
            }
            return(nextMove);
        }