コード例 #1
0
ファイル: Runner.cs プロジェクト: whereismyguts/ai2017
        public void Run()
        {
            try {
                remoteProcessClient.WriteTokenMessage(token);
                remoteProcessClient.WriteProtocolVersionMessage();
                remoteProcessClient.ReadTeamSizeMessage();
                Game game = remoteProcessClient.ReadGameContextMessage();

                IStrategy strategy = new MyStrategy();

                PlayerContext playerContext;

                while ((playerContext = remoteProcessClient.ReadPlayerContextMessage()) != null)
                {
                    Player player = playerContext.Player;
                    if (player == null)
                    {
                        break;
                    }

                    Move move = new Move();
                    strategy.Move(player, playerContext.World, game, move);

                    remoteProcessClient.WriteMoveMessage(move);
                }
            } finally {
                remoteProcessClient.Close();
            }
        }
コード例 #2
0
ファイル: Runner.cs プロジェクト: MelnikovIG/CodeWars2017
        public void Run()
        {
            try {
                remoteProcessClient.WriteTokenMessage(token);
                remoteProcessClient.WriteProtocolVersionMessage();
                remoteProcessClient.ReadTeamSizeMessage();
                Game game = remoteProcessClient.ReadGameContextMessage();

                IStrategy strategy = new MyStrategy();

                PlayerContext playerContext;

                try
                {
                    while ((playerContext = remoteProcessClient.ReadPlayerContextMessage()) != null)
                    {
                        Player player = playerContext.Player;
                        if (player == null)
                        {
                            break;
                        }

                        Move move = new Move();
                        strategy.Move(player, playerContext.World, game, move);

                        remoteProcessClient.WriteMoveMessage(move);
                    }
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("Ошибка... Выход через 3 сек");
                    System.Console.WriteLine(ex);
                    System.Threading.Thread.Sleep(3000);
                }
            } finally {
                remoteProcessClient.Close();
            }
        }