示例#1
0
        private static void Test()
        {
            new System.Threading.Thread(StartServer).Start();

            System.Threading.Thread.Sleep(100);
            var client = new Client(IPAddress.Loopback);
            var white = new NetworkPlayer(client);
            var board = new Board(white, new ComputerPlayer(), white.StartingFEN);
            board.Start();

            Console.ReadLine();
        }
示例#2
0
        private static Player GetPlayer(PlayerType playerType, string config)
        {
            switch (playerType)
            {
                case PlayerType.Human: return new HumanPlayer();
                case PlayerType.Computer: return new ComputerPlayer((AILevel)Enum.Parse(typeof(AILevel), config));
                case PlayerType.Network:
                    ChessConnection cnn;
                    if (string.IsNullOrEmpty(config))
                        cnn = new Server();
                    else
                        cnn = new Client(System.Net.IPAddress.Parse(config));

                    return new NetworkPlayer(cnn);
            }

            throw new NotSupportedException(playerType.ToString());
        }