VCNet AI

VCNet Introduction

VCNet provides a secure way to test AI because the only the information displayed in the GUI is available to the AI.
- AI cannot peek at other AbstractPlayer's hands because the client is not supplied with that information.
- AI cannot play illegal cards/card patterns or play out of turn because that is checked by the server.

VCNet AI development package:

- VCServer.jar (runs a VCServer)
- VCClient.jar (runs a VC human Client)
- source code for Card, CardPlay, CardPlay implementations, BotClient
- package_vcnet.jar

Assume that:

- There will be 4 AbstractPlayers, each AbstractPlayer will start with 13 cards.
- It will use a standard deck of 52 cards.
- All cards played will be legal - checked by the server.

Every AI must extend BotClient and implement methods:

// precondition: ai has >0 cards
// precondition: ai's turn
// @return: a CardPlay to play cards, or null to pass
public abstract CardPlay myTurn();

// precondition: ai has >0 cards
// precondition: ai has control (can play any cards)
// note: if ai has 3 of spades, and person with 3 of spades starts, ai must play 3 of spades
// @return: a CardPlay to play cards
public abstract CardPlay myControl();

// called to get name to join server
// @param: a List of String names that have already been tried and found unusable
public abstract String getUsername(List<String> unusable);

abstract class BotClient

// @param: the String ip and int port of the server
public BotClient(String ip, int port);

// @return: the last cards played, or null if the AbstractPlayer has control
public CardPlay getLastPlayed();

// called to notify the AI of a new game starting
public void startGame();

// called to notify the AI of a new game starting
public void endGame();

// called when cards are played by any AbstractPlayer
// @param: the CardPlay of the last cards played and the String name of the AbstractPlayer that played them
// Note: getLastPlayed() and AbstractPlayer cards are updated even if cardsPlayed() is overwritten
public void cardsPlayed(CardPlay cards, String AbstractPlayer);

// called when a AbstractPlayer passes
// @param: the String name of the AbstractPlayer that passed
public void passed(String AbstractPlayer);

// called when a AbstractPlayer gains control
// @param: the String name of the AbstractPlayer that has control
public void hasControl(String AbstractPlayer);

// @return: the RuleList for the game
public RuleList getRules();

// @return: a list of the other AbstractPlayers in the game
public ArrayList<AbstractPlayer> getOtherAbstractPlayers();

// @param: the String name of the AbstractPlayer to be found
// @return: the AbstractPlayer with the given name, or null if no AbstractPlayer is found
public AbstractPlayer getAbstractPlayerByName(String name);

// @param: the CardPlay to be checked for playability
// @ return: a boolean denoting whether cards can be played
public boolean isPlayable(CardPlay cards);

// calls myTurn(). if cards are unplayable or null, passes.
// @return: true if cards were played
// Note: does not need to be called by BotClient extension
public boolean playTurn();

// called to pass
// Note: does not need to be called by BotClient extension
public void pass();

// calls myControl() until suitable cards are found.
// Note: does not need to be called by BotClient extension
public void playControl();

// there may be other methods not shown

abstract class CardPlay methods

// @param: an ArrayList of Cards to be included in the returned CardPlay
// precondition: cards is not null
// @return: the best fit CardPlay for the given cards, or null if no CardPlays fit
public static CardPlay getCardPlay(ArrayList<Card> cards);

// @param: the List of cards to be included in this CardPlay
public CardPlay(List<Card> cards);

// @return: the highest card in this CardPlay
public Card getHighestCard();

// @return: a list of cards in this CardPlay
public ArrayList<Card> getCards();

// @return: a boolean denoting whether this CardPlay has the correct pattern of cards
abstract boolean verify();

// @param: the CardPlay of the cards last played, and the RuleList of the game's rules
// @return: a boolean denoting whether this CardPlay can legally be played on top of the cards last played with the given RuleList
abstract boolean playable(CardPlay lastPlayed, RuleList rules);

abstract class CardPlay implementations

abstract class UniformCardPlay extends CardPlay
// a CardPlay in which all cards have the same value

// @return: an int denoting the value of all cards in this CardPlay
public int getIntValue();

// @return: a String denoting the value of all cards in this CardPlay
public String getStrValue();


class SinglePlay extends UniformCardPlay
// a single

class DoublePlay extends UniformCardPlay
// a double

class TriplePlay extends UniformCardPlay
// a triple

class BreakPlay extends UniformCardPlay
// 4 of a kind break

class StraightPlay extends CardPlay
// a straight

class LockPlay extends StraightPlay
// a lock

class BombPlay extends CardPlay
// a bomb of consecutive doubles

Card methods

// @param: two Strings denoting the value and suit of this card
public Card(String value, String suit);

// @param: two ints denoting the value and suit of this card
// 0 is the lowest value/suit
public Card(int value, int suit);

// @return: a String representing this Card's value
public String getStrValue();

// @return: a String representing this Card's suit
public String getStrSuit();

// @return: an int representing this Card's value
public int getIntValue();

// @return: an int representing this Card's suit
public int getIntSuit();

// @return: an int comparing the two card
public int compareTo(Card rhs);

// there may be other methods not shown

abstract class AbstractPlayer

// @return: the number of cards this player has
public int getNumCards();

// @return: the player's name
public String getName();

Email me if you want the source code / jar files, or if you have any questions or comments.