예제 #1
0
        private static void StartNewGameCore()
        {
            var board = new Board(new ComputerPlayer(AILevel.Easy), new ComputerPlayer(AILevel.Easy));
            //board.Check += p => Console.WriteLine("Check");
            board.Checkmate += p => { Console.WriteLine("Checkmate: {0} wins", p == PlayerColor.Black ? PlayerColor.White : p); StartNewGame(); };
            board.Stalemate += (reason) => { Console.WriteLine("Stalemate: " + reason); StartNewGame(); };
            board.Start();

            var server = new SpectatorServer(board);

            while (board.IsActive)
                System.Threading.Thread.Sleep(1);
        }
예제 #2
0
파일: ChessForm.cs 프로젝트: hcesar/Chess
        private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var config = NewGameForm.Show(this);
            if (config == null)
                return;

            if (spectatorServer != null)
                ((IDisposable)spectatorServer).Dispose();

            var board = this.boardControl.StartNew(config.White, config.Black);

            var mouseSensor = new Sensors.MouseSensor(this.boardControl);
            var eyeTrackerSensor = new Sensors.TobiiEyeTracker.EyeTrackerSensor(this.boardControl);
            var sensorContainer = new Sensors.SensorContainer(mouseSensor, eyeTrackerSensor);

            var output = new ProxiedMemoryStream(File.Create(DateTime.Now.ToString("yyyMMddmmss") + ".chess"));
            spectatorServer = new SpectatorServer(board, sensorContainer);
            var writer = new IO.ChessStreamWriter(board, sensorContainer, output);

            if (config.White.IsReady && config.Black.IsReady)
                board.Start();
            else
                this.boardControl.ShowMessage("Waiting for remote player", board.Start, () => config.White.IsReady && config.Black.IsReady);
        }