Examples of PileOfCards


Examples of net.sf.nebulacards.main.PileOfCards

     *
     * @see net.sf.nebulacards.main.UIListener#submitPass(net.sf.nebulacards.main.PileOfCards)
     */
    public boolean submitPass(PileOfCards p) {
      synchronized (GameRunner.this) {
        incomingPasses[im_slot] = new PileOfCards(p);
        GameRunner.this.notifyAll();
      }
      return true;
    }
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

          (whereAmI+1) % 4, beenPlayed, rules ) < 0.35
               ) wantToWin -= 6;
            break;
        }

        PileOfCards vp = Think.validPlays( hand, tableau, beenPlayed, rules );
        PileOfCards tl = Think.takeLead( vp, tableau, whereAmI, rules );

        if (verbose) {
            System.out.print( "Want to Win: " ); System.out.println( wantToWin );
            System.out.println( "Tableau: " + tableau );
      System.out.println( "Hand: " + hand );
            System.out.println( "Valid Plays: " + vp );
            System.out.println( "Take Lead: " + tl );
        }

        if (wantToWin >= 0)
    {
            if (tl.howManyCardsNotNull() > 0)
      {  // want to win and can
                if (tableau.howManyCardsNotNull() == 3)
                    myPlay = Think.lowCard( tl, true );
                else
                    myPlay = Think.highCard( tl, true );
            }
            else  // want to win but can't
                myPlay = Think.lowCard( vp, true );
        }
        else { // don't want to win
            if (tl.howManyCardsNotNull() < vp.howManyCardsNotNull())
      { // don't have to win
                vp.removeAll( tl )// disregard winning cards
                if (pNil || (pWinning && !meNil) ) myPlay = Think.lowCard( vp, true );
                else myPlay = Think.highCard( vp, true );
            }
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

    {
      if (newHands[i] != null)
      {
        if (game instanceof CardOrdering)
            newHands[i].sort((CardOrdering)game);
        PileOfCards oldHand = game.getHands()[i];
        oldHand.clear();
        oldHand.addAll(newHands[i]);
        synchronized (coms[i])
        {
          coms[i].dealHand(new PileOfCards(newHands[i]));
        }
      }
      synchronized (coms[i])
      {
        if (game instanceof Rules)
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

            hasBid[i] = false;
            tricks[i] = 0;
      otherHands[i] = rules.getDeck();
        }
        tableau = new Tableau( 4 );
        beenPlayed = new PileOfCards();
    }
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

        for (int i = 0; i < 4; i++)
    {
            hasBid[i] = false;
            tricks[i] = 0;
            // reset possible hands
            otherHands[i] = new PileOfCards(rules.getDeck());
            // they can't have cards that we have
            otherHands[i].removeAll( hand );
        }
        beenPlayed = new PileOfCards();
    }
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

    okButton.addActionListener(this);
    setVisible(true);
  }

  protected void deactivate() {
    selection = new PileOfCards(checked);
    okButton.removeActionListener(this);
    for (int i = 0; i < hand.size(); i++) {
      if (checks[i].getState()) {
        selection.add(hand.get(i));
      }
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

   * Testing Framework
   */
  public static void main(String[] args) {
    Frame parent = new Frame();
   
    PileOfCards deck = PileOfCards.getStandardDeck();
    deck.shuffle();
    PileOfCards hand = new PileOfCards(13);
    for (int i = 0; i < 13; i++)
      hand.add(deck.takeTop());
    PassWindow pw = new PassWindow(parent, hand, 3, "Bob");
    JOptionPane.showMessageDialog(null, "yo");
    PileOfCards selection;
    while ((selection = pw.waitForAnswer(500)) == null)
      ;
    System.out.println(selection);
    parent.dispose();
    System.exit(0);
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

    public static PileOfCards validPlays( PileOfCards h,
                                          Tableau t,
                                          PileOfCards bp,
                                          Rules rules )
    {
        PileOfCards vp = new PileOfCards();
    Enumeration cards = h.elements();
    while (cards.hasMoreElements())
    {
      PlayingCard c = (PlayingCard)cards.nextElement();
            if (rules.validPlay( bp, t, h, c ))
      {
              vp.add( c );
      }
    }
        return vp;
    }
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

     * @return All cards in vp that would be the highest in the trick.
     */
    public static PileOfCards takeLead( PileOfCards vp, Tableau t,
      int position, Rules rules )
    {
        PileOfCards results = new PileOfCards();
    Tableau tableau = new Tableau( t );
    if (tableau.howManyCardsNotNull() == 0)
      tableau.setLead( position );
    Enumeration cards = vp.elements();
    while (cards.hasMoreElements())
    {
      PlayingCard c = (PlayingCard)cards.nextElement();
            tableau.set( position, c );
      if (rules.whoWinsTrick( tableau ) == position)
              results.add( c );
        }
        return results;
    }
View Full Code Here

Examples of net.sf.nebulacards.main.PileOfCards

    {
        if (tableau == null || tableau.howManyCardsNotNull() == 0)
      return (float)1.0;
        if (h == null || h.howManyCardsNotNull() == 0)
      return (float)0.0;
        PileOfCards tl = takeLead( h, tableau, position, rules );
        if (tl.howManyCardsNotNull() == 0)
            return 0;
        PileOfCards vp = validPlays( h, tableau, bp, rules );
        float f = 0;
    Enumeration tlCards = tl.elements();
    while (tlCards.hasMoreElements())
    {
            PlayingCard c = (PlayingCard)tlCards.nextElement();
            if (vp.contains(c))
                f += 2.0 / vp.howManyCardsNotNull();
            else
                f += 1.0;
        }
        float p = f / (float)vp.howManyCardsNotNull();
        p = (float)( p > 1.0 ? 1.0 : p )// make sure we're not above 1.0
        return p;
    }
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.