Package org.cspoker.common.elements.hand

Examples of org.cspoker.common.elements.hand.Hand$UniqueHandHash


  protected void tearDown(){
    BasicConfigurator.resetConfiguration();
  }
 
  public void testHighCardHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.NINE, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.THREE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.HIGH_CARD.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.NINE, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    assertTrue(hand2.getShortDescription().equals(
        HandType.HIGH_CARD.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());

  }
View Full Code Here


    TestHandQuality.logger.info(hand2.getShortDescription());

  }

  public void testPairHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.PAIR.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    assertTrue(hand2.getShortDescription().equals(
        HandType.PAIR.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }
View Full Code Here

        HandType.PAIR.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }

  public void testDoublePairHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.TWO_PAIR.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.FIVE, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FIVE, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    assertTrue(hand2.getShortDescription().equals(
        HandType.TWO_PAIR.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }
View Full Code Here

        HandType.TWO_PAIR.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }

  public void testThreeOfAKindHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.THREE_OF_A_KIND.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    assertTrue(hand2.getShortDescription().equals(
        HandType.THREE_OF_A_KIND.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }
View Full Code Here

        HandType.THREE_OF_A_KIND.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }

  public void testFourOfAKindHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.FOUR_OF_A_KIND.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    assertTrue(hand2.getShortDescription().equals(
        HandType.FOUR_OF_A_KIND.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }
View Full Code Here

        HandType.FOUR_OF_A_KIND.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }

  public void testFlushHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.THREE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TWO, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.FLUSH.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SEVEN, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.DIAMONDS));
    assertTrue(hand2.getShortDescription().equals(
        HandType.FLUSH.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }
View Full Code Here

        HandType.FLUSH.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }

  public void testStraightHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.THREE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TWO, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.STRAIGHT.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.NINE, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FIVE, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SEVEN, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.DIAMONDS));
    assertTrue(hand2.getShortDescription().equals(
        HandType.STRAIGHT.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }
View Full Code Here

        HandType.STRAIGHT.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }

  public void testFullHouseHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.SPADES));
    assertTrue(hand1.getShortDescription().equals(
        HandType.FULL_HOUSE.getDescription()));
    TestHandQuality.logger.info(hand1.getShortDescription());

    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.CLUBS));
    assertTrue(hand2.getShortDescription().equals(
        HandType.FULL_HOUSE.getDescription()));
    TestHandQuality.logger.info(hand2.getShortDescription());
  }
View Full Code Here

    int quality1, quality2;
    Map<String, Integer> rankMap = new HashMap<String, Integer>();
    double totalTests = 10000.0;
    for (int j = 0; j < totalTests; j++) {
      Deck deck = Deck.createTruelyRandomDeck();
      Hand hand1 = new Hand(deck.deal(5));
      Hand hand2 = new Hand(deck.deal(5));

      compare = hand1.compareTo(hand2);
      qualityGreater = (compare == 1);
      qualitySmaller = (compare == -1);
      qualityEqual = (compare == 0);
      quality1 = hand1.getRank();
      quality2 = hand2.getRank();

      String rank = hand1.getShortDescription();
      if (!rankMap.containsKey(rank)) {
        rankMap.put(rank, Integer.valueOf(1));
      }
      rankMap
          .put(rank, Integer
              .valueOf(rankMap.get(rank).intValue() + 1));

      if (qualityGreater != (quality1 < quality2)
          || qualitySmaller != (quality1 > quality2)
          || qualityEqual != (quality1 == quality2)) {
        TestHandQuality.logger.info("compareTo "
            + hand1.compareTo(hand2));
        TestHandQuality.logger.info(hand1.toString());
        TestHandQuality.logger.info(hand1.getShortDescription());
        TestHandQuality.logger.info("quality 1 " + quality1);
        TestHandQuality.logger.info(hand2.toString());
        TestHandQuality.logger.info(hand2.getShortDescription());
        TestHandQuality.logger.info("quality 2 " + quality2);
        fail("error");
      }
      if (j % (totalTests / 10) == 0) {
        TestHandQuality.logger.info(Integer.valueOf(j));
View Full Code Here

  private static TestExactCard testExactCard = new TestExactCard();

  protected Hand hand1;

  public void test() {
    hand1 = new Hand();
    hand1 = hand1.add(testExactCard.getExactCard(Rank.THREE, Suit.HEARTS));
    assertTrue(hand1.size() == 1);
    assertTrue(hand1.contains(testExactCard.getExactCard(Rank.THREE,
        Suit.HEARTS)));
View Full Code Here

TOP

Related Classes of org.cspoker.common.elements.hand.Hand$UniqueHandHash

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.