//difficulty input - integer - stores the difficulty that the AI players are to be //creates an array of players with the size of the constant "SIZEOFQUEUE", sets the first player in the array to be the human player, and creates the remaining players as AI players according to the difficulty input public Queue(int difficultyInput) { players = new Player[SIZEOFQUEUE]; players[0] = new HumanPlayer(); //human player if (difficultyInput == 0) { for (int x = 1; x < SIZEOFQUEUE; x++) { players[x] = new EasyPlayer(); //add 3 Easy AI players } } else if (difficultyInput == 1) { for (int x = 1; x < SIZEOFQUEUE; x++) { players[x] = new MediumPlayer(); //add 3 Medium AI players } } else { for (int x = 1; x < SIZEOFQUEUE; x++) { players[x] = new DifficultPlayer(); //add 3 Difficult AI players } } SetCurrentPlayerIndex(0); }
//getNextAIPlayer takes the board which holds the current position of the game, including the queue of players //returns the next AI player in the queue //finds the next AI player by getting the next player, and if this player is a human Player then getting the next player after that //the currentPlayerMinsOne is called the same number of times as getNextPlayer has been called to cancel out the incrememntations to the currentPlayerIndex, such that the same player remains as the current player public Player GetNextAIPlayer(Board board) { Player temp = new DifficultPlayer(); temp = board.GetQueue().GetNextPlayer(); if (board.GetQueue().GetCurrentPlayer().GetType().ToString() == "HumanPlayer") { temp = board.GetQueue().GetNextPlayer(); board.GetQueue().CurrentPlayerMinusOne(); } board.GetQueue().CurrentPlayerMinusOne(); return(temp); }