示例#1
0
    // @return  True if the specified color can play in the given Point
    public bool IsValidPlay(Vector2 point, GoColor colorStone)
    {
        int x = (int)point.x;
        int y = (int)point.y;

        // Check: If Point is empty. If not, we cannot play there
        if (!IsPointEmpty(point))
        {
            Debug.Log("[GB] Could not create @ ( " + x + ", " + y + "); already occupied");
            return(false);
        }

        // Check: If new Stone would be immediately be captured
        if (IsGroupCaptured(point, colorStone))
        {
            // If a Stone would immediately be captured, we can play it
            // IFF that move would capture enemy Stone(s)
            // AND we aren't violating the rule of Ko
            List <Vector2> list_blocked = new List <Vector2>();
            list_blocked.Add(point);

            // Check adjacent spots to see if we can capture enemy Stone(s)
            List <Vector2> list_adjacent      = GetAdjacentPoints(point);
            bool           b_capture_detected = false;
            foreach (Vector2 point_adj in list_adjacent)
            {
                GoPoint gp_adj = gridPoints[(int)point_adj.x, (int)point_adj.y];
                // We only care about checking against enemy stones

                GoStone stone_adj = gp_adj.GetStone();
                if (stone_adj.Color != colorStone)
                {
                    b_capture_detected |= IsGroupCaptured(point_adj, stone_adj.Color, list_blocked);
                }
            }

            // If no captured were found, play is illegal
            if (!b_capture_detected)
            {
                Debug.Log("[GB] Could not create @ ( " + x + ", " + y + "); illegal move (surrounded)");
                return(false);
            }
            // Check for Ko
            else
            {
                GoTurn turn_prev = gameStateManager.GetTurnPrev();
                if (turn_prev.piecesCaptured == 1 && IsGroupCaptured(turn_prev.pointPlay, turn_prev.turnColor, list_blocked))
                {
                    Debug.Log("[GB] Could not create @ ( " + x + ", " + y + "); illegal move (Ko)");
                    return(false);
                }
            }
        }

        return(true);
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        // Tell our Board about our existence
        gameBoard.SetGameManager(this);

        // Initialize score
        ResetScore();

        // Create initial turn data
        m_turnDataCurr = new GoTurn(m_turnNumber, CurrentColor);
    }
示例#3
0
    //
    void EndTurn()
    {
        // Store turn data
        m_listPlayHistory.Add(m_turnDataCurr);

        // Change Turn
        mb_blacksTurn = !mb_blacksTurn;
        m_turnNumber++;
        m_turnDataCurr = new GoTurn(m_turnNumber, CurrentColor);

        // Update HUD
        UpdateHud();
    }