示例#1
0
  @Test
  public void fuzzTest() {
    Hand hand = null;
    Card upCard = null;

    try {
      for (int i = 0; i < RUN_NUMBER; i++) {
        hand = new Hand(new Hid(Seat.YOU));
        hand.hit(RandomCardGenerator.getRandomCard());
        hand.hit(RandomCardGenerator.getRandomCard());
        upCard = RandomCardGenerator.getRandomCard();
        advisor.advise(hand, upCard);

        hand.hit(RandomCardGenerator.getRandomCard());
        while (hand.getValue() < 21) {
          advisor.advise(hand, upCard);
          hand.hit(RandomCardGenerator.getRandomCard());
        }

        System.out.println("Hand: " + hand);
        System.out.println("Up Card: " + upCard);
      }

    } catch (Exception e) {
      System.out.println("Hand: " + hand);
      System.out.println("Up Card: " + upCard);
      fail("The method threw an exception: \n" + e);
    }

    assertTrue(true);
  }
  @Test
  public void Test00_Hand_12_Up_2() {
    Hid hid = new Hid(Seat.YOU, 1.0, 1.5);
    Hand hand = new Hand(hid);

    // Hand total = 18
    hand.hit(new Card(10, Card.Suit.HEARTS));
    hand.hit(new Card(8, Card.Suit.HEARTS));

    // Up card = 5
    Play result = advisor.advise(hand, new Card(13, Card.Suit.HEARTS));
    Play expectedPlay = Play.STAY;

    assertEquals(expectedPlay, result);
  }
示例#3
0
 // TODO add test methods here.
 // The methods must be annotated with annotation @Test. For example:
 //
 @Test
 public void test1() {
   BasicStrategy bs = new BasicStrategy();
   Hid hid = new Hid(Seat.YOU, 125.0, 25.0);
   Hand newHand = new Hand(hid);
   Card card1 = new Card(5, Card.Suit.DIAMONDS);
   Card card2 = new Card(5, Card.Suit.CLUBS);
   newHand.hit(card1);
   newHand.hit(card2);
   Card card3 = new Card(9, Card.Suit.SPADES);
   assertEquals(Play.DOUBLE_DOWN, bs.advise(newHand, card3));
 }
  @Test
  public void Test00_Hand_22_Up_7() {
    Hid hid = new Hid(Seat.YOU, 1.0, 1.5);
    Hand hand = new Hand(hid);

    // Hand comp = 7, 7
    hand.hit(new Card(7, Card.Suit.HEARTS));
    hand.hit(new Card(7, Card.Suit.SPADES));

    // Up card = A
    Play result = advisor.advise(hand, new Card(1, Card.Suit.HEARTS));
    Play expectedPlay = Play.HIT;

    assertEquals(expectedPlay, result);
  }