Exemple #1
0
        public void testSpeed()
        {
            var output = new StringWriter();

            Console.SetOut(output);

            var input = new StreamReader("../../../example-input-start.txt");

            Console.SetIn(input);

            var gameState = Bot.InitGameState();

            var input1 = new StreamReader("../../../example-input-turn1.txt");

            Console.SetIn(input1);

            var planets = Bot.ReadPlanets();
            var ships   = Bot.ReadShips();
            var turn    = 1;

            Bot.AdjustGamestateForTurn(turn, gameState, planets, ships);

            var moves = TheMoleStrategy.PlayTurn(gameState, turn, new Stopwatch());

            var input2 = new StreamReader("../../../example-input-turn2.txt");

            Console.SetIn(input2);

            planets = Bot.ReadPlanets();
            ships   = Bot.ReadShips();
            turn++;
            Bot.AdjustGamestateForTurn(turn, gameState, planets, ships);

            moves = TheMoleStrategy.PlayTurn(gameState, turn, new Stopwatch());



            var input3 = new StreamReader("../../../example-input-speed2.txt");

            Console.SetIn(input3);
            var watch = System.Diagnostics.Stopwatch.StartNew();

            planets = Bot.ReadPlanets();
            ships   = Bot.ReadShips();
            var x1 = watch.ElapsedTicks;

            turn++;
            Bot.AdjustGamestateForTurn(turn, gameState, planets, ships);
            var x2 = watch.ElapsedTicks;

            moves = TheMoleStrategy.PlayTurn(gameState, turn, new Stopwatch());
            watch.Stop();
            var x3 = watch.ElapsedTicks;
            var x4 = watch.ElapsedTicks;
        }
Exemple #2
0
        public void testTurnInit()
        {
            var output = new StringWriter();

            Console.SetOut(output);

            var input = new StreamReader("../../../example-input-start.txt");

            Console.SetIn(input);

            var gameState = Bot.InitGameState();

            var input1 = new StreamReader("../../../example-input-turn1.txt");

            Console.SetIn(input1);

            var planets = Bot.ReadPlanets();
            var ships   = Bot.ReadShips();
            var turn    = 1;

            Bot.AdjustGamestateForTurn(turn, gameState, planets, ships);

            var moves = TheMoleStrategy.PlayTurn(gameState, turn, new Stopwatch());

            var input2 = new StreamReader("../../../example-input-turn2.txt");

            Console.SetIn(input2);

            planets = Bot.ReadPlanets();
            ships   = Bot.ReadShips();
            turn++;
            Bot.AdjustGamestateForTurn(turn, gameState, planets, ships);

            moves = TheMoleStrategy.PlayTurn(gameState, turn, new Stopwatch());

            Assert.AreEqual(1, gameState.Ships.Count);// is al niet meer 1 omdat PlayTurn er ook 1 toevoegd...
            Assert.AreEqual(1, gameState.PlanetsById[4].InboundShips.Count);
        }