/** * @author Tina * */ //This AI player never tries to cheat. If he doesn't have the card to play, he plays the first available card. public class NoBluffAI { public static void main(String[] args){ //Integer[] computerPlayerCardsArray = {21, 38, 48, 34, 22, 30, 26, 44, 25, 20, 31, 7, 43}; //int[] currentCardtoPlay = {0,13,26,39}; int verdict = findCardsToPlay(computerPlayerCardsArray, currentCardtoPlay); System.out.println("Currrent card to play: " +verdict); } /** * @param computerPlayerCardsArray2 * @param currentCardtoPlay2 * @return */ public static int findCardsToPlay(Integer[] computerPlayerCardsArray, int[] currentCardtoPlay) { // TODO Auto-generated method stub boolean contains = false; int retVal, card = 0; for(int j = 0; j < computerPlayerCardsArray.length; j++){ for (int i : currentCardtoPlay) { if (i == computerPlayerCardsArray[j]) { contains = true; card = computerPlayerCardsArray[j]; break; } } } if(!contains) retVal = computerPlayerCardsArray[0]; else retVal = card; return retVal; } }