コード例 #1
0
    void MakeMove()
    {
        int playerID = (turn % 3) + 1;

        if (sm.CanPlay())
        {
            int move = 0;
            if (isHumanTurn(playerID))
            {
                move = HumanMove();
            }
            else
            {
                //Debug.Log("AI check was entered");
                if (Input.GetKeyDown(KeyCode.Return))
                {
                    //Debug.Log("Enter was hit");
                    move = AIMove(playerID);
                }
            }
            if (gm.MoveLegal(move))
            {
                sm.SpawnSequence(playerID, move);
                //Debug.Log(gm.calculateAttackScore(move, playerID));
                gm.RegisterMove(move, playerID);
                winner = gm.CheckForWin();
                turn++;
                int newPlayerID = (turn % 3) + 1;
                wm.TurnChange(newPlayerID);
                if (winner != 0)
                {
                    wm.WinSequence(winner);
                }
            }
        }
    }