예제 #1
0
        public List <Move> Stage1(FeaturesState s0, int nTroops)
        {
            List <Country> OwnedCountries = new List <Country>();

            FeaturesState currentSate = s0;
            FeaturesState movingState = s0;
            List <Move>   Moves       = new List <Move>();
            int           FreeTroops  = nTroops;

            for (int i = 0; i < nTroops; i++)
            {
                Move   bestMove = null;
                double maxScore = 0;
                foreach (Country c in OwnedCountries)
                {
                    Move m = new Move(null, c, 1);
                    currentSate = movingState;
                    FeaturesState tmpState = currentSate.Excecute(m);
                    if (NeuralNetwork.Score(tmpState) > maxScore)
                    {
                        maxScore = NeuralNetwork.Score(tmpState);
                        bestMove = m;
                    }
                }
                Moves.Add(bestMove);
                movingState.Excecute(bestMove);
            }
            return(Moves);
        }
예제 #2
0
        public List <Move> AIStage23(FeaturesState s0, int stage)
        {
            // These come in some way
            List <Country> ownedCountries = new List <Country>();

            FeaturesState currentState = s0;
            FeaturesState movingState  = s0;

            bool        changed  = false;
            List <Move> Moves    = new List <Move>();
            double      maxScore = NeuralNetwork.Score(s0);

            do
            {
                Move bestMove = null;
                changed = false;
                foreach (Country c in ownedCountries)
                {
                    foreach (Country n in c.Vecinos)
                    {
                        bool condition = (stage == 2) ? (c.Owner != n.Owner) : (c.Owner == n.Owner);
                        if (condition)
                        {
                            for (int i = 1; i < c.Troops; i++)
                            {
                                Move m = new Move(c, n, i);
                                currentState = movingState;
                                FeaturesState tmpStat = currentState.Excecute(m);
                                if (NeuralNetwork.Score(tmpStat) > maxScore)
                                {
                                    maxScore = NeuralNetwork.Score(tmpStat);
                                    bestMove = m;
                                    changed  = true;
                                }
                            }
                        }
                    }
                }
                if (changed)
                {
                    if (bestMove != null)
                    {
                        Moves.Add(bestMove);
                        movingState.Excecute(bestMove);
                    }
                }
            } while (changed);

            return(Moves);
        }