Package _misc

Examples of _misc.Combinations


      // for each legal hand card combo
      // ------------------------------------------------------------
       
      byte[] boardCards = new byte[5];
      byte[] holeArray;
      Combinations boardCardsIterator = new Combinations(Card.ALLCARDSINDEX, 5);
      int handScore;
      int opponentScore;
      double timer1 = System.currentTimeMillis();
      double progressCounter = 0;

      while (boardCardsIterator.hasMoreElements()) {
        progressCounter++;
        if (progressCounter % 12995 == 0) {
          System.out.println ((System.currentTimeMillis() - timer1) + ": " + (progressCounter / 2598960) + "% done");
        }
       
        // get 5 board cards
        boardCards = boardCardsIterator.nextElement();
       
              // figure out possible hole cards
        Combinations holeCards = new Combinations(
            Helper.getRemainingCards(boardCards), 2);

        int scores[][] = new int[Card.NUM_CARDS][Card.NUM_CARDS];
        short winCount[][] = new short[Card.NUM_CARDS][Card.NUM_CARDS];
        short tieCount[][] = new short[Card.NUM_CARDS][Card.NUM_CARDS];
        short loseCount[][] = new short[Card.NUM_CARDS][Card.NUM_CARDS];
        byte doneCard1[] = new byte[NUM_HOLE_HANDS];
        byte doneCard2[] = new byte[NUM_HOLE_HANDS];
        byte b1[] = new byte[NUM_HOLE_HANDS];
        byte b2[] = new byte[NUM_HOLE_HANDS];
        byte b3[] = new byte[NUM_HOLE_HANDS];
        byte b4[] = new byte[NUM_HOLE_HANDS];
        byte b5[] = new byte[NUM_HOLE_HANDS];
        int doneCardPointer = 0;
       
        // iterate over each possible hole card combo,
        // assign score, winCount, tieCount, and loseCount
        while(holeCards.hasMoreElements()) {
          holeArray = holeCards.nextElement();
          handScore = HandEvaluator.rankHand_Java(Helper.mergeByteArrays(boardCards, holeArray));
         
          for(int i = 0; i < doneCardPointer; i++) {
            if(
                (doneCard1[i] != holeArray[0]) &&
View Full Code Here


    System.out.println("All possible backtracking completed in time: " + (System.currentTimeMillis() - tTotal));
   
  }
   
    private static byte[] getNextTask() throws IOException {
      Combinations combo = new Combinations(Card.ALLCARDSINDEX, 2);
      byte[] holeCards;
     
      while(combo.hasMoreElements()) {
        holeCards = combo.nextElement();
       
        // disqualified if it's already been done
        if(new File(getOneOutputFileName(holeCards)).exists()) {
          continue;
        }
View Full Code Here

 
  public void addScore(HandRecord cardsToMatch, short x) {
    Short score = new Short(x);
   
    // bcc = Board Card Combinations
    Combinations bcc = new Combinations(cardsToMatch.boardCards, numBoardCards);
   
    while(bcc.hasMoreElements()) {
      byte[] cards = bcc.nextElement();
      Map scoreMap = maps[getIndex(cards)];
     
      if(scoreMap.containsKey(score)) {
        Integer oldCount = (Integer) scoreMap.get(score);
        scoreMap.put(score, new Integer(oldCount.intValue() + 1));
View Full Code Here

    }
  }
 
  private static void testIndexMethods() {
    Map ind = new HashMap();
    Combinations combo = new Combinations(Card.ALLCARDSINDEX, 4);
    int[][][][] direct = new int[52][52][52][52];

    double timer1 = System.currentTimeMillis();

    List trials = new ArrayList();
    while(combo.hasMoreElements()) {
      byte[] yo = combo.nextElement();
      byte[] yo2 = new byte[] { 0, yo[0], yo[1], yo[2], yo[3] };
      ind.put(new Integer(Helper.hashByteArray(yo2)), new Integer(Helper.getComboArrayIndex((byte)52, (byte)4, yo2)));
      direct[yo[0]][yo[1]][yo[2]][yo[3]] = Helper.getComboArrayIndex((byte)52, (byte)4, yo);
      if(Math.random() < .3) {
        trials.add(yo2);
View Full Code Here

    // strictly upper triangular matrix where higher values are in favor of the row-player
    long[][] winCount = new long[numClusters][numClusters];
    long[][] normalizeCount = new long[numClusters][numClusters];
   

    Combinations rootCombo = new Combinations(Card.ALLCARDSINDEX, numBoardCards);
    byte[] rootBoardCards;
    int numLegalHoleCards = Constants.choose(Card.NUM_CARDS - numBoardCards, 2);

    System.out.println("Entering phase 1 -- computing expected values...");
    double tPhase = System.currentTimeMillis();
    int progressCounter = 0;
    int fiveThousands = (int) Math.floor(Constants.choose(Card.NUM_CARDS, numBoardCards) / 200);
   
    while(rootCombo.hasMoreElements()) {
      progressCounter++;
      if (progressCounter % fiveThousands == 0) {
        System.out.println("  " +
            (System.currentTimeMillis() - tPhase) +
            ": " + (new Double((double)progressCounter /
            Constants.choose(Card.NUM_CARDS, numBoardCards))).toString() + "% done");
      }
     
      rootBoardCards = rootCombo.nextElement();

      int[] score = new int[numLegalHoleCards];
      byte[] clusterId = new byte[numLegalHoleCards];
     
      int pointer = 0;
View Full Code Here

  public HandRecord(int numBoardCards, byte[] holeCards) {
    this.numBoardCards = (byte) numBoardCards;
    this.holeCards = new byte[] {holeCards[0], holeCards[1]};
    this.boardCards = new byte[numBoardCards];
   
    combo = new Combinations(
        Helper.getRemainingCards(holeCards), numBoardCards);
    this.hasMoreElements = combo.hasMoreElements();
  }
View Full Code Here

       
        while((hr1 = in1.readRecord()) != null) {
          // first print the master clusterId for numBoardCards1
          out.putClusterId(hr1.clusterId);
         
          Combinations nextHandAddCards = new Combinations(
              Helper.getRemainingCards(hr1.boardCards),
              (numBoardCards2 - numBoardCards1)); //hot spot?
         
          byte[] addCards;
         
          while(nextHandAddCards.hasMoreElements()) {
            addCards = nextHandAddCards.nextElement();
           
            boolean legalGivenHCs = true;
            for(int i = 0; i < addCards.length; i++) {
              if(addCards[i] == holeCards[0] ||
                  addCards[i] == holeCards[1]) {
View Full Code Here

    System.out.println("All TPDT Step1'ing completed in time: " + (System.currentTimeMillis() - tTotal));
  }
 
  private static byte[] getNextTask(int numBoardCards1) throws IOException {
    Combinations combo = new Combinations(Card.ALLCARDSINDEX, 2);
    byte[] holeCards;
   
    while(combo.hasMoreElements()) {
      holeCards = combo.nextElement();
     
      // disqualified if it's already been done
      if(new File(getOutputFileName(numBoardCards1, holeCards)).exists()) {
        continue;
      }
View Full Code Here

TOP

Related Classes of _misc.Combinations

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.