예제 #1
0
        public void Iteration(TextReader input)
        {
            currentTurn += 2;
            var turnState = TurnState.ReadFrom(input);

            Console.Error.WriteLine("Current turn: " + currentTurn);
            if (currentTurn == Settings.DUMP_TURN || Settings.DUMP_ALL)
            {
                turnState.WriteTo(Console.Error);
                Console.Error.WriteLine("===");
                Dump();
            }

            turnState.stopwatch.Restart();

            int decisionCounter = 0;

            while (true)
            {
                var newStrategy = robotStrategy.Process(turnState);
                if (newStrategy == null)
                {
                    break;
                }
                if (++decisionCounter > 20)
                {
                    Console.Error.WriteLine("Couldn't decide!");
                    turnState.robot.Wait("Couldn't decide!");
                    break;
                }
                Console.Error.WriteLine($"New strategy: {newStrategy.GetType().Name}");
                robotStrategy = newStrategy;
            }

            turnState.stopwatch.Stop();
            Console.Error.WriteLine($"Decision made in {turnState.stopwatch.ElapsedMilliseconds} ms");
        }
예제 #2
0
 public GameState()
 {
     robotStrategy = new InitialStrategy(this);
 }