Package org.gnubridge.core

Examples of org.gnubridge.core.Deal.play()


    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());
View Full Code Here


    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

    System.out.println("#####>  Search strategies " + first + " and " + second
        + " differ on what is the best move ( " + firstMove + " versus " + secondMove + "). "
        + "Now comparing tricks taken if each evaluates the other's best move.");

    Deal firstMovePlayed = originalGame.duplicate();
    firstMovePlayed.play(firstMove);
    firstMovePlayed.printHandsDebug();
    SearchMonkey firstProxy = new SearchMonkey(first.config);
    SearchMonkey secondProxy = new SearchMonkey(second.config);
    firstProxy.runSearch(firstMovePlayed.duplicate());
    secondProxy.runSearch(firstMovePlayed.duplicate());
View Full Code Here

    assertEquals("played " + firstMove + " as recommended by " + firstProxy, firstProxy.getNorthSouthTricks(),
        secondProxy.getNorthSouthTricks());
    int tricksTakenIfFirstMovePlayed = firstProxy.getNorthSouthTricks();

    Deal secondMovePlayed = originalGame.duplicate();
    secondMovePlayed.play(secondMove);
    firstProxy.runSearch(secondMovePlayed);
    secondProxy.runSearch(secondMovePlayed);
    assertEquals("played " + firstMove + " as recommended by " + secondProxy, firstProxy.getNorthSouthTricks(),
        secondProxy.getNorthSouthTricks());
    int tricksTakenIfSecondMovePlayed = firstProxy.getNorthSouthTricks();
View Full Code Here

    game.getPlayer(Direction.NORTH_DEPRECATED).init(new Card[] { Five.of(Spades.i()), Four.of(Spades.i()) });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new Card[] { Ten.of(Hearts.i()), Three.of(Hearts.i()) });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new Card[] { Six.of(Hearts.i()), Two.of(Hearts.i()) });

    game.setNextToPlay(Direction.WEST_DEPRECATED);
    game.play(Ace.of(Spades.i()));
    DoubleDummySolver pruned = new DoubleDummySolver(game.duplicate());
    Node root = new Node(null);
    pruned.examinePosition(root);
    assertNotNull(root.getBestMove());
View Full Code Here

    game.getPlayer(Direction.NORTH_DEPRECATED).init(new Card[] { Six.of(Spades.i()), Four.of(Hearts.i()) });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new Card[] { Ten.of(Hearts.i()), Three.of(Hearts.i()) });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new Card[] { Six.of(Hearts.i()), Two.of(Hearts.i()) });

    game.setNextToPlay(Direction.WEST_DEPRECATED);
    game.play(Ace.of(Spades.i()));
    DoubleDummySolver pruned = new DoubleDummySolver(game.duplicate());
    pruned.setTerminateIfRootOnlyHasOneValidMove(true);
    pruned.search();
    assertEquals(1, pruned.getPositionsExamined());
View Full Code Here

    game.getPlayer(Direction.NORTH_DEPRECATED).init(new Card[] { Six.of(Diamonds.i()), Four.of(Hearts.i()) });
    game.getPlayer(Direction.EAST_DEPRECATED).init(new Card[] { Ten.of(Hearts.i()), Three.of(Hearts.i()) });
    game.getPlayer(Direction.SOUTH_DEPRECATED).init(new Card[] { Six.of(Hearts.i()), Two.of(Hearts.i()) });

    game.setNextToPlay(Direction.WEST_DEPRECATED);
    game.play(Ace.of(Spades.i()));
    DoubleDummySolver pruned = new DoubleDummySolver(game.duplicate());
    pruned.search();
    assertEquals(Four.of(Hearts.i()), pruned.getRoot().getBestMove().getCardPlayed());
    Deal gameWithCardsFlipped = new Deal(NoTrump.i());
    gameWithCardsFlipped.getPlayer(Direction.WEST_DEPRECATED).init(
View Full Code Here

        new Card[] { Ten.of(Hearts.i()), Three.of(Hearts.i()) });
    gameWithCardsFlipped.getPlayer(Direction.SOUTH_DEPRECATED).init(
        new Card[] { Six.of(Hearts.i()), Two.of(Hearts.i()) });

    gameWithCardsFlipped.setNextToPlay(Direction.WEST_DEPRECATED);
    gameWithCardsFlipped.play(Ace.of(Spades.i()));
    DoubleDummySolver triangulate = new DoubleDummySolver(gameWithCardsFlipped.duplicate());
    //triangulate.pruneAlphaBeta = false;
    triangulate.search();
    assertEquals(Four.of(Hearts.i()), triangulate.getRoot().getBestMove().getCardPlayed());
View Full Code Here

  }

  public void testOneCardPlayedDifferentCards() {
    Deal g = new Deal(NoTrump.i());
    GameUtils.initializeSingleColorSuits(g);
    g.play(g.getNextToPlay().getHand().get(0));

    PositionLookup pl = new PositionLookup();
    @SuppressWarnings("unused")
    boolean justPresentThePosition = pl.positionEncountered(g, null);
View Full Code Here

    @SuppressWarnings("unused")
    boolean justPresentThePosition = pl.positionEncountered(g, null);

    Deal gameWithDifferentCardPlayed = new Deal(NoTrump.i());
    GameUtils.initializeSingleColorSuits(gameWithDifferentCardPlayed);
    gameWithDifferentCardPlayed.play(gameWithDifferentCardPlayed.getNextToPlay().getHand().get(1));
    assertFalse(pl.positionEncountered(gameWithDifferentCardPlayed, null));
  }

  @SuppressWarnings("unused")
  public void testCanRememberMoreThanOnePosition() {
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.