Exemplo n.º 1
0
    /// <summary>
    /// Called when it's the AI's move
    /// </summary>
    /// <remarks>INVOKED BY: State_Move_AI::OnStateEnter()
    /// This method calls whichever AI computing method has been chosen in the inspector
    /// (See AIMethodName and AIBrain::_AIMethod)
    /// </remarks>
    ///
    public void OnAIMove()
    {
        List <Command.GameMove> validMoves = m_brain.BuildMoveList(CurrentPlayer.Color);

        // If no legal moves, AI removes itself from game play
        //
        if (validMoves.Count == 0)
        {
            AIResign();

            return;
        }
        else if (RemoveAIPenguin())
        {
            return;                           // Remove a lone penguin and claim its tiles
        }
        //
        else                           // Find a move and play it
        {
            m_brain.IsThinking = true; // This flag is turned off by AIBrain::StoreMove() at end of computation

            // Send valid moves to AIBrain for evaluation --
            //   Chosen move is returned as first element in validMoves (Other moves are discarded)
            //
            SendMessage(AIMethodName, validMoves);

            // Wait for AI to finish, then fetch move found (stored in validMoves[0]) and execute it
            //
            StartCoroutine(WaitExecuteAIMove(validMoves));
        }
    }