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));
        }
Exemple #4
0
        public void DoesNotEliminatePlayer_WhenOnlyOneHisPodCantTakeCheckpointsTooLongTime()
        {
            var state = StateReader.Read(
                "3|4|8024 7881|13301 5550|9567 1403|3663 4439|",
                "7822 7424 0 0 -1 1|8226 8338 0 0 -1 1|7418 6509 0 0 -1 1|8630 9253 0 0 -1 1|");
            var ai = new FastAi();

            for (int time = 0; time < 200; time++)
            {
                var myMoves  = ai.GetMoves(state, 0);
                var hisMoves = ai.GetMoves(state.WithSwappedPlayers(), 0);
                hisMoves[0] = new PodMove(VecD.Zero, 0);
                state.Tick(myMoves, hisMoves);
            }
            Assert.That(state.HisPods[0].TimeWithoutCheckpoint, Is.GreaterThan(100));
            Assert.That(state.IsDead, Is.All.EqualTo(false));
        }
Exemple #5
0
        public void EliminatePlayer_WhenHeCantTakeCheckpointsTooLongTime()
        {
            var state = StateReader.Read(
                "3|4|8024 7881|13301 5550|9567 1403|3663 4439|",
                "7822 7424 0 0 -1 1|8226 8338 0 0 -1 1|7418 6509 0 0 -1 1|8630 9253 0 0 -1 1|");
            var ai = new FastAi();

            for (int time = 0; time < 101; time++)
            {
                Assert.That(state.IsDead, Does.Not.Contains(true));
                var moves = ai.GetMoves(state, 0);
                state.Tick(moves, new[] { new PodMove(VecD.Zero, 0), new PodMove(VecD.Zero, 0) });
            }
            Assert.That(state.HisPods[0].TimeWithoutCheckpoint, Is.GreaterThan(100));
            Assert.That(state.HisPods[1].TimeWithoutCheckpoint, Is.GreaterThan(100));
            Assert.That(state.IsDead[1], Is.True);
        }