コード例 #1
0
ファイル: SmartBot.java プロジェクト: ricksmt/LiarsDice
 private Decision makeDecision(GameInfo currentGameInfo) {
   int[] myDiceFrequencies = getMyDiceFrequencies(currentGameInfo);
   int totalDice = currentGameInfo.getTotalDice();
   int othersDice = totalDice - currentGameInfo.getMyDice().size();
   Bid currentBid = currentGameInfo.getCurrentBid();
   int onesGuess = othersDice / 6 + myDiceFrequencies[0];
   int bidFrequencyGuess = myDiceFrequencies[currentBid.getFaceValue() - 1] + othersDice / 6;
   if (currentBid.getFrequency()
       > (onesGuess + bidFrequencyGuess)) { // I don't think there are that many in the game
     return new Challenge();
   } else if (currentBid.getFrequency() < (onesGuess + bidFrequencyGuess)) {
     return new Bid(currentBid.getFrequency() + 1, currentBid.getFaceValue());
   } else { // currentBid is spot on with my guess
     int myDiceOfCurrentBid = myDiceFrequencies[currentBid.getFaceValue() - 1];
     for (int i = currentBid.getFaceValue(); i < myDiceFrequencies.length; i++) {
       if (myDiceFrequencies[i] >= myDiceOfCurrentBid) {
         return new Bid(currentBid.getFrequency(), i + 1);
       }
     }
     for (int i = 1; i < currentBid.getFaceValue(); i++) {
       if (myDiceFrequencies[i] > myDiceOfCurrentBid) {
         return new Bid(currentBid.getFrequency() + 1, i + 1);
       }
     }
     return new Challenge();
   }
 }
コード例 #2
0
ファイル: SmartBot.java プロジェクト: ricksmt/LiarsDice
 public Decision getDecision(GameInfo currentGameInfo) {
   Bid currentBid = currentGameInfo.getCurrentBid();
   if (currentBid == null) return calculateFirstBid(currentGameInfo);
   else {
     Decision d = makeDecision(currentGameInfo);
     return checkValidDecision(d, currentGameInfo) ? d : new Challenge();
   }
 }
コード例 #3
0
ファイル: SmartBot.java プロジェクト: ricksmt/LiarsDice
 private int[] getMyDiceFrequencies(GameInfo currentGameInfo) {
   int[] myDiceFrequencies = new int[6];
   for (Die d : currentGameInfo.getMyDice()) myDiceFrequencies[d.getValue() - 1]++;
   return myDiceFrequencies;
 }