static char[] createBoard(BoardTic myBoard) { char[] newBoard = new char[9]; for (int i = 0; i < 9; i++) { newBoard[i] = myBoard.getChar(i); } return(newBoard); }
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); }