Initial add (with Netbeans project and build script)
[shoot.git] / src / shoot_the_moon / DummyPlayer.java
blobbdeb8af1e99c2af71cf7583bbda60a716bfb31cb
1 package shoot_the_moon;
4 import java.util.List;
7 /**
8 * Dummy AI class that will always bid one higher than the previous bid in
9 * hearts (unless the maximum bid is reached then it will pass) and will always
10 * play it's first legal card in it's hand.
12 * @author ben
15 public class DummyPlayer extends Player {
16 private String name;
18 public DummyPlayer( String name ) {
19 this.name = name;
21 @Override
22 protected Bid decideBid( Bid lastHighestBid ) {
23 if ( lastHighestBid == null ) {
24 return Bid.makeNormalBid( 1, Trump.HEARTS );
26 if ( lastHighestBid.isPass() ) {
27 return Bid.makeNormalBid( 1, Trump.HEARTS );
28 } else if ( lastHighestBid.isNormalBid() ) {
29 int lastBid = lastHighestBid.getNumber();
30 if ( lastBid >= Rules.getHandSize( this.getSettings() ) ) {
31 return Bid.makePassBid();
32 } else {
33 return Bid.makeNormalBid( lastBid +1, Trump.HEARTS );
35 //else the last highest bid was a shoot
36 } else {
37 return Bid.makePassBid();
41 @Override
42 protected Card decideCard( List<Card> legalCards ) {
43 // System.out.print( this.getPosition() + " has the hand: " );
44 // List<Card> hand = ListFactory.makeList( this.getHand() );
45 // Collections.sort( hand, new CardComparator( this.getCurrentTrump() ) );
46 //
47 // for ( Card c: hand ) {
48 // System.out.print( c.toString() + " ");
49 // }
50 // System.out.print( '\n' );
52 return legalCards.get( 0 );
55 @Override
56 public String getName() {
57 return name;
60 @Override
61 protected void processEvent( Event e ) {
62 //do nothing