Exemple #1
0
        public GameMove[] GetMoves(Pod[] pod, Pod[] opp)
        {
            GameMove[] moves = new GameMove[4];
            //moves = GetMoves(pod, opp, Depth);
            int runner = (pod[0].Utility() > pod[1].Utility()) ? 0 : 1;
            moves[runner] = (new SimpleStrategy()).GetMove(pod[runner]);
            moves[runner ^ 1] = (new SimpleStrategy()).GetMoveHit(pod, opp, runner ^ 1);

            List<GameMove[]> altMoves = GameMove.GenerateMoves(moves, runner);

            Simulator sim = new Simulator();
            double maxU = Double.MinValue;
            int maxInd = 0;
            for (int i = 0; i < altMoves.Count; i++)
            {
                Situation situation = sim.SimulateHR(pod[0], pod[1], opp[0], opp[1], altMoves[i], runner);

                //Console.Error.WriteLine("thrust1: {0}, thrust2: {1}", altMoves[i][0].Thrust, altMoves[i][1].Thrust);
                //situation.Print();
                double utility = situation.UtilityHR();
                //Console.Error.WriteLine("Utility {0} = {1}", i, utility);
                if (utility > maxU)
                {
                    maxU = utility; maxInd = i;
                }
            }
            GameMove moveWithShield = GameMove.MoveWithShield(altMoves[maxInd][0]);
            if (runner == 0)
            {
                Situation sit = sim.Simulate(pod[0], pod[1], opp[0], opp[1], new GameMove[] {
                moveWithShield, altMoves[maxInd][1], altMoves[maxInd][2], altMoves[maxInd][3]});
                if (sit.UtilityHR() > maxU + 30 && !(pod[0].Lap == laps && pod[0].NextCP == 0))
                {
                    //moveWithShield.Print();
                    altMoves[maxInd][0] = moveWithShield;
                }
            }
            else
            {
                moveWithShield = GameMove.MoveWithShield(altMoves[maxInd][1]);
                Situation sit = sim.Simulate(pod[0], pod[1], opp[0], opp[1], new GameMove[] {
                altMoves[maxInd][0], moveWithShield, altMoves[maxInd][2], altMoves[maxInd][3]});
                if (sit.UtilityHR() > maxU + 40 && !(pod[1].Lap == laps && pod[1].NextCP == 0))
                {
                    //moveWithShield.Print();
                    altMoves[maxInd][1] = moveWithShield;
                }
            }

            

            return altMoves[maxInd];
        }