Examples of Deal


Examples of org.gnubridge.core.Deal

    assertEquals(1, s2.getBestMoves().size());
    assertEquals(Queen.of(Hearts.i()), s2.getBestMoves().get(0));
  }

  public void testNorthTrumps() {
    Deal game = new Deal(Spades.i());
    game.getPlayer(Direction.WEST_DEPRECATED).init(new Card[] { Nine.of(Clubs.i()), Four.of(Spades.i()) });
    game.getPlayer(Direction.NORTH_DEPRECATED).init(new Card[] { Two.of(Spades.i()), Two.of(Hearts.i()) });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new Card[] { Three.of(Clubs.i()), Three.of(Diamonds.i()) });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new Card[] { Six.of(Clubs.i()), Five.of(Diamonds.i()) });
    game.play(Nine.of(Clubs.i()));
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.search();
    s.printStats();
    s.printOptimalPath();
    assertEquals(1, s.getBestMoves().size());
    assertEquals(Two.of(Spades.i()), s.getBestMoves().get(0));

    Deal game2 = new Deal(Spades.i());
    game2.getPlayer(Direction.WEST_DEPRECATED).init(new Card[] { Nine.of(Clubs.i()), Four.of(Spades.i()) });
    game2.getPlayer(Direction.NORTH_DEPRECATED).init(new Card[] { Two.of(Hearts.i()), Two.of(Spades.i()) }); // order
    // reverted
    game2.getPlayer(Direction.EAST_DEPRECATED).init(new Card[] { Three.of(Clubs.i()), Three.of(Diamonds.i()) });
    game2.getPlayer(Direction.SOUTH_DEPRECATED).init(new Card[] { Six.of(Clubs.i()), Five.of(Diamonds.i()) });
    game2.doNextCard(0);
    DoubleDummySolver s2 = new DoubleDummySolver(game2);
    s2.search();
    assertEquals(1, s2.getBestMoves().size());
    assertEquals(Two.of(Spades.i()), s2.getBestMoves().get(0));
View Full Code Here

Examples of org.gnubridge.core.Deal

    assertEquals(Two.of(Spades.i()), s2.getBestMoves().get(0));

  }

  public void testNorthCannotTrumpBecauseHasColor() {
    Deal game = new Deal(Spades.i());
    game.getPlayer(Direction.WEST_DEPRECATED).init(new Card[] { Nine.of(Clubs.i()), Four.of(Spades.i()) });
    game.getPlayer(Direction.NORTH_DEPRECATED).init(new Card[] { Two.of(Spades.i()), Two.of(Clubs.i()) });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new Card[] { Three.of(Diamonds.i()), Three.of(Hearts.i()) });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new Card[] { Six.of(Diamonds.i()), Five.of(Hearts.i()) });
    game.doNextCard(0);
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.search();
    assertEquals(1, s.getBestMoves().size());
    assertEquals(Two.of(Clubs.i()), s.getBestMoves().get(0));
  }
View Full Code Here

Examples of org.gnubridge.core.Deal

    assertEquals(1, s.getBestMoves().size());
    assertEquals(Two.of(Clubs.i()), s.getBestMoves().get(0));
  }

  public void testBestMoveForOneTrick() {
    Deal game = new Deal(NoTrump.i());
    game.getPlayer(Direction.WEST_DEPRECATED).init(new String[] { "3" });
    game.getPlayer(Direction.NORTH_DEPRECATED).init(new String[] { "2" });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new String[] { "A" });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new String[] { "K" });
    game.setNextToPlay(Direction.SOUTH_DEPRECATED);
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.search();
    assertNotNull(s.getBestMoves());
    assertEquals(1, s.getBestMoves().size());
  }
View Full Code Here

Examples of org.gnubridge.core.Deal

    assertNotNull(s.getBestMoves());
    assertEquals(1, s.getBestMoves().size());
  }

  public void testBestMoveForOneTrickRootDidNotStartTrick() {
    Deal game = new Deal(NoTrump.i());
    game.getPlayer(Direction.WEST_DEPRECATED).init(new String[] { "3" });
    game.getPlayer(Direction.NORTH_DEPRECATED).init(new String[] { "2" });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new String[] { "A" });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new String[] { "K" });
    game.setNextToPlay(Direction.SOUTH_DEPRECATED);
    game.doNextCard(0);
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.search();
    assertNotNull(s.getBestMoves());
    assertEquals(1, s.getBestMoves().size());
  }
View Full Code Here

Examples of org.gnubridge.core.Deal

  }

  private static void buildGui() throws InterruptedException, InvocationTargetException {
    SwingUtilities.invokeAndWait(new Runnable() {
      public void run() {
        Deal g = createSampleGame();
        MainViewImpl mainView = new MainViewImpl("Gnubridge Analysis Mode");
        AnalysisView pv = new AnalysisView(mainView);
        pv.show();
        mainView.show();
        pv.setGame(g, South.i());
        pv.setContract(new Bid(1, g.getTrump()));
        pv.setListener(new MockCardPlayedListener());
        pv.displayCurrentTrick();

      }
    });
View Full Code Here

Examples of org.gnubridge.core.Deal

      }
    });
  }

  private static Deal createSampleGame() {
    Deal g = new Deal(NoTrump.i());
    GameUtils.initializeRandom(g, 13);
    g.setHumanPlayer(g.getSouth());
    return g;
  }
View Full Code Here

Examples of org.gnubridge.core.Deal

  public void examinePosition(Node node) {
    if (node.isPruned()) {
      return;
    }
    Deal position = game.duplicate();
    position.playMoves(node.getMoves());

    Player player = position.getNextToPlay();
    node.setPlayerTurn(player.getDirection());
    node.setPosition(position);
    if (position.oneTrickLeft()) {
      node.setCardPlayed(player.getPossibleMoves(position.getCurrentTrick()).get(0));
      position.playMoves(finalMoves);
    }
    for (Card card : player.getPossibleMoves(position.getCurrentTrick())) {
      makeChildNodeForCardPlayed(node, player, card);
    }

    checkDuplicatePositions(node, position);
    if (position.getTricksPlayed() >= maxTricks || position.isDone() || node.hasIdenticalTwin()) {
      node.setLeaf(true);
      trim(node);
    } else {
      for (Node move : node.children) {
        if (shouldPruneCardsInSequence) {
View Full Code Here

Examples of org.gnubridge.core.Deal

public class DoubleDummySolverTest extends TestCase {

  public void testExaminePositionSetsNextToPlay() {
    Node node = new Node(null);
    Deal game = new Deal(NoTrump.i());
    GameUtils.initializeSingleColorSuits(game, 2);
    game.setNextToPlay(Direction.SOUTH_DEPRECATED);
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.examinePosition(node);
    assertEquals(game.getNextToPlay().getDirection(), node.getPlayerTurn());
    assertEquals(Direction.SOUTH_DEPRECATED, node.getPlayerTurn());
  }
View Full Code Here

Examples of org.gnubridge.core.Deal

    assertEquals(Direction.SOUTH_DEPRECATED, node.getPlayerTurn());
  }

  public void testExaminePositionInitsChildren() {
    Node node = new Node(null);
    Deal game = new Deal(NoTrump.i());
    game.getPlayer(Direction.WEST_DEPRECATED).init(new String[] { "3", "10" });
    game.getPlayer(Direction.NORTH_DEPRECATED).init(new String[] { "2", "9" });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new String[] { "A", "5" });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new String[] { "K", "7" });
    game.setNextToPlay(Direction.SOUTH_DEPRECATED);
    DoubleDummySolver s = new DoubleDummySolver(game);
    s.examinePosition(node);
    assertEquals(2, node.children.size());
  }
View Full Code Here

Examples of org.gnubridge.core.Deal

    });

  }

  private static Deal constructGame() {
    Deal game = new Deal(NoTrump.i());
    game.getWest().init(new Hand("", "8", "", ""));
    game.getNorth().init(new Hand("3", "", "", ""));
    game.getEast().init(new Hand("A", "", "", ""));
    game.getSouth().init(new Hand("", "", "", "3"));
    game.setNextToPlay(Direction.EAST_DEPRECATED);
    return game;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.