Package org.gnubridge.core

Examples of org.gnubridge.core.Deal


    assertFalse(node.children.get(2).isPruned());
  }

  public void testDoNotCountCurrentTrickAsPlayedCardWhenPruningPlayedSequence() {
    Node node = new Node(null);
    Deal game = new Deal(NoTrump.i());
    game.getPlayer(Direction.NORTH_DEPRECATED).init(new Hand("10,6", "", "", ""));
    game.getPlayer(Direction.EAST_DEPRECATED).init(new Hand("9,J", "", "", ""));
    game.setNextToPlay(Direction.NORTH_DEPRECATED);
    game.play(Ten.of(Spades.i()));
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.examinePosition(node);
    assertEquals(2, s.getStack().size());
    assertTrue(s.getStack().contains(node.children.get(0)));
    assertTrue(s.getStack().contains(node.children.get(1)));
View Full Code Here


  }

  // this pruning disabled for now
  public void _testOnlyExpandFirstCardInSequenceCardPlayedBetweenTwoUnplayedCards() {
    Node node = new Node(null);
    Deal game = new Deal(NoTrump.i());
    game.getPlayer(Direction.WEST_DEPRECATED).init(new Hand("", "", "4,3,2", ""));
    game.getPlayer(Direction.NORTH_DEPRECATED).init(new Hand("K,10,3", "", "", ""));
    game.getPlayer(Direction.EAST_DEPRECATED).init(new Hand("Q,A,2", "", "", ""));
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new Hand("", "4,3,2", "", ""));
    game.setNextToPlay(Direction.NORTH_DEPRECATED);
    game.play(King.of(Spades.i()));
    game.play(Two.of(Spades.i()));
    game.play(Two.of(Hearts.i()));
    game.play(Two.of(Diamonds.i())); //north takes trick
    game.play(Ten.of(Spades.i()));
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.examinePosition(node);
    assertEquals(2, s.getStack().size());
    assertTrue(s.getStack().contains(node.children.get(0)));
    assertEquals(Ace.of(Spades.i()), node.children.get(1).getCardPlayed());
View Full Code Here

  public void testNoExceptionsGetThrown() {
    for (int i = 0; i < 10000; i++) {
      System.out.println(i + " auction: ******************************************");
      Auctioneer a = new Auctioneer(West.i());
      Deal g = new Deal(null);
      GameUtils.initializeRandom(g, 13);
      g.printHandsDebug();
      while (!a.biddingFinished()) {
        Hand hand = new Hand(g.getPlayer(a.getNextToBid()).getHand());
        BiddingAgent baUnderTest = new BiddingAgent(a, hand);
        System.out.println(" for player: " + a.getNextToBid());
        System.out.println(" the recommended bid is: " + baUnderTest.getBid());
        List<Bid> validBids = getValidBids(a);
        assertTrue("no valid bids, but auction not finished", validBids.size() > 0);
View Full Code Here

    //assertEquals(1000 + 20 * 7, mainController.getRunningHumanScore());
    //assertEquals(50 * 13, mainController.getRunningComputerScore());
  }

  private void playGameToTheEnd(MainController mainController) throws InterruptedException {
    Deal game = mainController.getGameController().getGame();
    int cardsPlayed = -1;
    while (!game.isDone()) {
      int previousCardsPlayed = cardsPlayed;
      cardsPlayed = game.getPlayedCards().getCardsHighToLow().size();
      assertTrue("Expecting to play at least one card each time through the main loop",
          previousCardsPlayed < cardsPlayed);
      assertTrue("Game not done, but played cards " + cardsPlayed, cardsPlayed < 52);
      if (mainController.getGameController().humanHasMove()) {
        List<Card> possibleMoves = game.getNextToPlay().getPossibleMoves(game.getCurrentTrick());
        mainController.getGameController().playCard(possibleMoves.get(0));
        continue;
      } else {
        boolean cardPlayed = false;
        for (int i = 0; i < 8000; i++) {
          Thread.sleep(100);
          if (i % 10 == 0) {
            System.out.println("// tick...");
          }
          if (game.getPlayedCards().getCardsHighToLow().size() > cardsPlayed) {
            cardPlayed = true;
            break;
          }

        }
View Full Code Here

    }
    System.out.println("");
  }

  private void preInitializeGame13Tricks() {
    Deal g = new Deal(null);
    GameUtils.initializeSingleColorSuits(g, 13);
    g.setHumanPlayer(g.getSouth());
    System.out.println("Human's hand: " + g.getSouth().getHand());
    Deal.setPreInitializedGame(g);
  }
View Full Code Here

    System.out.println("Human's hand: " + g.getSouth().getHand());
    Deal.setPreInitializedGame(g);
  }

  private void preInitializeGameWithSingleColorSuits() {
    Deal g = new Deal(null);
    GameUtils.initializeSingleColorSuits(g, TRICKS_PER_DEAL);
    g.setHumanPlayer(g.getWest());
    System.out.println("Human's hand: " + g.getWest().getHand());
    Deal.setPreInitializedGame(g);
  }
View Full Code Here

    System.out.println("Human's hand: " + g.getWest().getHand());
    Deal.setPreInitializedGame(g);
  }

  private void preInitializeRandomGame() {
    Deal g = new Deal(null);
    GameUtils.initializeRandom(g, TRICKS_PER_DEAL);
    g.setHumanPlayer(g.getNorth());
    System.out.println("West's hand: " + g.getWest().getHand());
    System.out.println("Human's hand: " + g.getNorth().getHand());
    System.out.println("East's hand: " + g.getEast().getHand());
    System.out.println("South's hand: " + g.getSouth().getHand());
    Deal.setPreInitializedGame(g);
  }
View Full Code Here

    assertEquals("3 passes should follow 7NT bid", 4, auction.getCalls().size());
    assertTrue("Auction not complete even though highest bid was placed", auction.biddingFinished());
  }

  private void preInitializeGameWithHumanToBidFirst() {
    Deal g = new Deal(null);
    GameUtils.initializeRandom(g, TRICKS_PER_DEAL);
    g.setHumanPlayer(g.getWest());
    Deal.setPreInitializedGame(g);
  }
View Full Code Here

  }

  private void givenDeal() {
    if (deal == null) {
      deal = new Deal(NOTRUMP);
      solver = null;
    }

  }
View Full Code Here

import org.gnubridge.core.deck.Three;
import org.gnubridge.core.deck.Two;

public class DoubleDummySolverScenarioAcceptanceTest extends TestCase {
  public void test13cards3deep() {
    Deal game = new Deal(NoTrump.i());
    game.getPlayer(West.i()).init(King.of(Clubs.i()), King.of(Hearts.i()), Two.of(Diamonds.i()),
        Seven.of(Clubs.i()), Jack.of(Diamonds.i()), Eight.of(Clubs.i()), Four.of(Diamonds.i()),
        Ten.of(Hearts.i()), Three.of(Clubs.i()), Ten.of(Spades.i()), Eight.of(Hearts.i()), Five.of(Spades.i()),
        Ten.of(Diamonds.i()));
    game.getPlayer(North.i()).init(Four.of(Spades.i()), Ace.of(Clubs.i()), Five.of(Hearts.i()),
        Four.of(Hearts.i()), Nine.of(Spades.i()), Two.of(Spades.i()), Two.of(Hearts.i()), Nine.of(Clubs.i()),
        Jack.of(Clubs.i()), Nine.of(Diamonds.i()), Jack.of(Hearts.i()), Nine.of(Hearts.i()),
        Three.of(Spades.i()));
    game.getPlayer(East.i())
        .init(Two.of(Clubs.i()), Five.of(Clubs.i()), Queen.of(Clubs.i()), Three.of(Hearts.i()),
            Seven.of(Spades.i()), Seven.of(Hearts.i()), Seven.of(Diamonds.i()), Six.of(Clubs.i()),
            Eight.of(Spades.i()), Six.of(Hearts.i()), Jack.of(Spades.i()), Queen.of(Hearts.i()),
            Four.of(Clubs.i()));
    game.getPlayer(South.i()).init(Queen.of(Diamonds.i()), Five.of(Diamonds.i()), Queen.of(Spades.i()),
        Three.of(Diamonds.i()), King.of(Diamonds.i()), Ten.of(Clubs.i()), Six.of(Diamonds.i()),
        Ace.of(Diamonds.i()), Ace.of(Hearts.i()), Ace.of(Spades.i()), Eight.of(Diamonds.i()),
        King.of(Spades.i()), Six.of(Spades.i()));

    DoubleDummySolver pruned = new DoubleDummySolver(game);
View Full Code Here

TOP

Related Classes of org.gnubridge.core.Deal

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.