Beispiel #1
0
    IEnumerator moveBlack(float Count)
    {
        yield return(new WaitForSeconds(Count));

        Othello ttt = new Othello(gameState);

        tn = new TreeNode(ttt);

        test();

        TreeNode BC    = tn.bestChild();
        int      index = BC.lastMove;
        int      col   = index / 8;
        int      row   = index % 8;

        if (gameState.Board[col, row] == 0 && gameState.CheckClosed(gameState.Board, col, row, false))
        {
            gameState.Board[col, row] = gameState.whoseMove();
        }

        if (gameState.whoseMove() == 1)
        {
            m_Buttons[index].image.color = Color.black;
        }
        else if (gameState.whoseMove() == 2)
        {
            m_Buttons[index].image.color = Color.white;
        }

        drawBoard(gameState);
        gameState.NextTurn();

        if (gameState.CanMove(gameState.Board) == false)
        {
            gameState.NextTurn();

            if (gameState.CanMove(gameState.Board) == false)
            {
                End();
            }
            else
            {
                StartCoroutine("moveBlack", bwaitTime);
            }
        }
        else
        {
            StartCoroutine("moveWhite", waitTime);
        }
        yield return(null);
    }
Beispiel #2
0
    public void Move(string buttonName)
    {
        int index = 0;

        for (int i = 0; i < m_Buttons.Length; i++)
        {
            if (m_Buttons[i].name.Equals(buttonName))
            {
                index = i;
                break;
            }
        }

        int col = index / 8;
        int row = index % 8;

        if (gameState.Board[col, row] == 0 && gameState.CheckClosed(gameState.Board, col, row, false))
        {
            gameState.Board[col, row] = gameState.player;
            if (gameState.player == 1)
            {
                m_Buttons[index].image.color = Color.black;
            }
            else if (gameState.player == 2)
            {
                m_Buttons[index].image.color = Color.white;
            }
            //StartCoroutine("ChangeCells", waitTime);
            drawBoard(gameState);
            gameState.NextTurn();
            if (gameState.CanMove(gameState.Board) == true)
            {
                StartCoroutine("moveBlack", bwaitTime);
            }
            else
            {
                gameState.NextTurn();
                if (gameState.CanMove(gameState.Board) == false)
                {
                    End();
                }
            }
        }
    }