Пример #1
0
    void ReceiveTurn(ITurn turn)
    {
        //Apply the turn and redraw the board
        board = turn.ApplyTurn(board) as ConnectKBoard;
        DrawBoard();
        //check to see if the game is over
        if (board.IsTerminal())
        {
            ConnectKPiece winner;
            if (board.player == ConnectKPiece.P1)
            {
                winner = ConnectKPiece.P2;
            }
            else
            {
                winner = ConnectKPiece.P1;
            }
            Line winLine = board.GetWinningLine();
            if (winLine != null)
            {
                DrawVictory(winLine, winner);
            }
            Debug.Log("Game over");
            gameEnd = true;

            p1.TurnReadyEvent -= ReceiveTurn;
            p2.TurnReadyEvent -= ReceiveTurn;
        }
        else
        {
            PlayTurn();
        }
    }
Пример #2
0
        public void EvaluateState(object threadState)
        {
            IGameState state = firstTurn.ApplyTurn(rootState.Clone());

            stopped = false;
            Value   = AlphaBeta(state, eval, maxDepth, eval.GetMinValue(), eval.GetMaxValue(), ourTurn);
            waitHandle.Set();
        }