static char createPlayer(TileTic.TileType myPlayer) { return(myPlayer == TileTic.TileType.X ? 'X' : 'O'); }
public void playerSwitch() { currType = currType == firstPlayerType ? secondPlayerType : firstPlayerType; notCurrType = notCurrType == firstPlayerType ? secondPlayerType : firstPlayerType; }
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); }