public void onClick(int num) { myBoard.getTile(num).setType(currType); if (isThereWinner()) { StatusText.text = "WIN!!!"; ButtonNext.gameObject.SetActive(true); myBoard.changeState(false); } else if (myBoard.allFilled()) { StatusText.text = "TIE"; ButtonNext.gameObject.SetActive(true); } else { playerSwitch(); if (menuTic.mode > 0) { StartCoroutine("makePCmove"); } } }
public static int getAImove(TileTic.TileType pcType, TileTic.TileType playerType, BoardTic board) { player2 = createPlayer(pcType); player1 = createPlayer(playerType); if (menuTic.mode == 1) { choice = Random.Range(0, 8); while (!board.getTile(choice).isEmpty()) { choice = Random.Range(0, 8); } } else if (menuTic.mode == 2) { int randomOrNot = Random.Range(0, 10); if (randomOrNot <= 7) { if (!board.allFilled()) { miniMax(createPlayer(pcType), createBoard(board), 0); } else { int[] squares = new int[4] { 0, 2, 6, 8 }; int index = Random.Range(1, 4); // creates a number between 1 and 12 choice = squares[index]; } } else //random choice { choice = Random.Range(0, 8); while (!board.getTile(choice).isEmpty()) { choice = Random.Range(0, 8); } } } else { if (!board.allFilled()) { miniMax(createPlayer(pcType), createBoard(board), 0); } else { int[] squares = new int[4] { 0, 2, 6, 8 }; int index = Random.Range(1, 4); // creates a number between 1 and 12 choice = squares[index]; } } return(choice); }