// Use this for initialization
 void Start()
 {
     if (gameLogic == null)
     {
         gameLogic = gameBoardGO.GetComponent <GomokuGameLogic>();
     }
 }
Exemple #2
0
    internal IComparable EstimateForStageTwo(Point location, CellState color)
    {
        GomokuGameLogic gameLogic = gameBoard.GetComponent <GomokuGameLogic>();
        int             cx        = location.x;
        int             cy        = location.y;

        int selfCount     = 0;
        int opponentCount = 0;

        for (int x = cx - 1; x <= cx + 1; x++)
        {
            for (int y = cy - 1; y <= cy + 1; y++)
            {
                if (gameBoard.getBlock(x, y) == color)
                {
                    selfCount++;
                }
                if (gameBoard.getBlock(x, y) == gameLogic.getOpponentColor(color))
                {
                    opponentCount++;
                }
            }
        }
        return(2 * selfCount + opponentCount);
    }
Exemple #3
0
    internal IComparable EstimateForStageOne(Point location, CellState color)
    {
        GomokuGameLogic gameLogic     = gameBoard.GetComponent <GomokuGameLogic>();
        int             selfScore     = 1 + gameLogic.countBlockAtPosition(location, color);
        CellState       opponentColor = gameLogic.getOpponentColor(color);
        int             opponentScore = 1 + gameLogic.countBlockAtPosition(location, opponentColor);

        if (selfScore > GameConstants.GAME_WIN_POINT)
        {
            selfScore = int.MaxValue;
        }
        return(Math.Max(selfScore, opponentScore));
    }
Exemple #4
0
    void Start()
    {
        if (gameBoard == null)
        {
            gameBoardGO = GameObject.FindGameObjectWithTag("game_board") as GameObject;
            gameBoard   = gameBoardGO.GetComponent <GameBoard>();
        }

        if (gameLogic == null)
        {
            gameLogic = gameBoardGO.GetComponent <GomokuGameLogic> ();
        }

        if (gameLogic.fightWithAI)
        {
            arrayObjects = gameLogic.arrayObjects;
            GameObject clickedGO = arrayObjects[7, 7];

            Point pos = clickedGO.GetComponent <BlockPosition> ().position;
            gameLogic.changeBlockSpriteAtLocation(clickedGO, pos);
        }
    }