Exemple #1
0
        private static void Main(string[] args)
        {
            var reader    = new StateReader();
            var initData  = reader.ReadInitData();
            var persister = new StatePersister();
            var evaluator = new StateEvaluator();
            var fastAi    = new FastAi();
            var ai        = new SingleTargetAi(10, evaluator, fastAi);

            while (true)
            {
                var state     = reader.ReadState(initData, persister.IsInitialState);
                var countdown = new Countdown(140);
                persister.FillState(state);
                Console.Error.WriteLine("my checkpoints taken:  " + state.MyPods[0].CheckpointsTaken + " " + state.MyPods[1].CheckpointsTaken);
                Console.Error.WriteLine("his checkpoints taken: " + state.HisPods[0].CheckpointsTaken + " " + state.HisPods[1].CheckpointsTaken);
                var bestMoves = ai.GetMoves(state, countdown);
                persister.RegisterMoves(bestMoves);
                Console.Error.WriteLine(countdown);
                foreach (var t in bestMoves)
                {
                    Console.WriteLine(t);
                }
            }
        }
Exemple #2
0
        public void RotatePodOnPlaceToTarget([Range(1, 15, 1)] int simulationTime)
        {
            var state = StateReader.Read("3|2|10000 2000|16000 9000",
                                         "8000 2000 0 0 180 0|0 200 0 0 0 1|0 400 0 0 0 1|0 6000 0 0 0 1");
            var fastAi    = new FastAi();
            var evaluator = new TestStateEvaluator();
            var moves     = new SingleTargetAi(simulationTime, evaluator, fastAi).GetMoves(state, 40);

            state.Tick(moves, fastAi.GetMoves(state, 1));
            double podHeading = state.MyPods[0].HeadingInRadians.NormAngleInRadians();

            Console.WriteLine($"MOVE [{moves[0]}] turn pod0 to {podHeading}");
            Assert.That(Math.Abs(podHeading), Is.LessThan(3));
            Assert.That(state.MyPods[0].V, Is.EqualTo(VecD.Zero));
        }
Exemple #3
0
        public void MovePodToTarget([Range(1, 15, 1)] int simulationTime)
        {
            var state = StateReader.Read("3|2|10 000 2000|16000 9000",
                                         "8000 2000 0 0 0 0|0 200 0 0 0 1|0 400 0 0 0 1|0 6000 0 0 0 1");
            var fastAi       = new FastAi();
            var evaluator    = new TestStateEvaluator();
            var initialScore = evaluator.Evaluate(state);
            var moves        = new SingleTargetAi(simulationTime, evaluator, fastAi).GetMoves(state, 40);

            state.Tick(moves, fastAi.GetMoves(state, 1));
            var finalScore = evaluator.Evaluate(state);

            Console.WriteLine($"MOVE [{moves[0]}] change score from {initialScore} to {finalScore}");
            Assert.That(finalScore, Is.GreaterThan(initialScore));
        }