Exemplo n.º 1
0
        public void StartGame()
        {
            CurrentTurn = new Turn();

            // Have the initial arrangement rendered.
            if (MoveMade != null)
            {
                MoveMade(this, EventArgs.Empty);
            }

            HookTurnEvents();
            CurrentTurn.GenerateMoves();

            PlayerType playerType = _playerTypes[CurrentTurn.PlayingColour];

            switch (playerType)
            {
            case PlayerType.Chimp:
                CurrentTurn.MakeRandomMove();
                return;

            case PlayerType.Computer:
                MakeBestMove();
                return;

            default:
                return;
            }
        }
Exemplo n.º 2
0
        private void StartNextTurn()
        {
            // Unsubscribe to the current turn's events.
            UnHookTurnEvents();

            // Add a new turn with the current state of the board.
            PieceColour nextPlayingColour   = CurrentTurn.PlayingColour == PieceColour.White ? PieceColour.Black : PieceColour.White;
            Board       nextSquares         = CurrentTurn.CurrentBoard;
            ISquare     nextEnPassantSquare = CurrentTurn.NextEnPassantSquare;

            CurrentTurn = new Turn(nextSquares, nextPlayingColour, nextEnPassantSquare);
            _turns.Add(CurrentTurn);

            // Subscribe to the new turn's events.
            HookTurnEvents();

            CurrentTurn.GenerateMoves();

            PlayerType playerType = _playerTypes[CurrentTurn.PlayingColour];

            if (CurrentTurn.AvailableMoves.Count == 0)
            {
                return;
            }

            switch (playerType)
            {
            case PlayerType.Chimp:
                CurrentTurn.MakeRandomMove();
                return;

            case PlayerType.Computer:
                MakeBestMove();
                return;

            default:
                return;
            }
        }