Пример #1
0
        public override PlayerTask GetMove(SabberStoneCoreAi.POGame.POGame poGame)
        {
            CurrentPoGame = poGame;
            List <PlayerTask> actions = poGame.CurrentPlayer.Options();
            Dictionary <PlayerTask, POGame.POGame> resultedictionary = poGame.Simulate(actions);
            //LinkedList<PlayerTask> minionAttacks = new LinkedList<PlayerTask>();

            /*foreach (PlayerTask task in options)
             * {
             *      if (task.PlayerTaskType == PlayerTaskType.MINION_ATTACK && task.Target == poGame.CurrentOpponent.Hero)
             *      {
             *              minionAttacks.AddLast(task);
             *      }
             * }
             * return options[1];
             */
            List <int> rewards = GetActionsRewards(actions, resultedictionary);

            return(actions[pickAction(rewards)]);
        }
Пример #2
0
        public override PlayerTask GetMove(SabberStoneCoreAi.POGame.POGame poGame)
        {
            Score.Score s = null;
            switch (poGame.CurrentPlayer.HeroClass)
            {
            case SabberStoneCore.Enums.CardClass.SHAMAN:
                s = midrScore;
                break;

            case SabberStoneCore.Enums.CardClass.WARRIOR:
                s = myScore;
                break;

            case SabberStoneCore.Enums.CardClass.MAGE:
                s = contrScore;
                break;

            default:
                s = myScore;
                break;
            }

            List <PlayerTask> options  = poGame.CurrentPlayer.Options();
            float             maxScore = Single.MinValue;
            PlayerTask        best     = options[0];

            foreach (PlayerTask task in options)
            {
                //for each task, that is not giving up or ending the turn
                if (task.PlayerTaskType != PlayerTaskType.CONCEDE && task.PlayerTaskType != PlayerTaskType.END_TURN)
                {
                    //simulate the choice of that task numSim times
                    try
                    {
                        Dictionary <PlayerTask, POGame.POGame> dic = poGame.Simulate(new List <PlayerTask> {
                            task
                        });
                        //set controller for the Scores
                        s.Controller = dic[task].CurrentPlayer;
                        //get the score with the rate function

                        if (s.Rate() > maxScore)
                        {
                            maxScore = s.Rate();
                            best     = task;
                        }
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                }
            }

            //Console.WriteLine(best.FullPrint());
            if (best == null)
            {
                best = options[0];
            }
            return(best);
        }