Mari's Tarot
 All Classes Files Functions Variables Enumerations Enumerator Friends
Classes | Public Member Functions | List of all members
AI Class Reference

This class defines AI players. More...

#include <AI.hpp>

Inheritance diagram for AI:
Inheritance graph
Collaboration diagram for AI:
Collaboration graph

Public Member Functions

 AI (const string &name, const vector< string > &knownPartners)
 AI constructor. More...
 
Biddings bid (const Biddings bestBid, const bool chelemAnnounced) const
 Called to decide if one proposes a bid or not, and if any, what bid. More...
 
shared_ptr< CardchooseKing (const Deck &deck) const
 To make a choice for partnership in a 5-player game. More...
 
bool haveSuit (const string &name, const Suits suit) const
 Given a Player p, does p have at least one card on the asked suit? More...
 
bool isOpponent (const string &name) const
 To know if someone is your opponent. More...
 
bool isPartner (const string &name) const
 To know if someone is your partner. More...
 
set< shared_ptr< Card > > makeEcart (const int dogSize)
 To make the ecart once one takes the dog. More...
 
void newGame ()
 Must be called when starting a new game. More...
 
bool opponentsHaveSuit (const Suits suit) const
 Do opponents have at least one card on the asked suit? More...
 
shared_ptr< CardplayCard (const Suits referenceCard, const shared_ptr< Card > highTrump)
 Choose what card one plays, given the first card and the highest trump of the trick. More...
 
void setDifficulty (const shared_ptr< StratDiff > diff)
 Inline function to set the difficulty (set a Strategy concrete class). More...
 
- Public Member Functions inherited from Player
 Player (const string &name)
 The unique constructor of Player. More...
 
void addCard (const shared_ptr< Card > card)
 Add a card among player's initial cards. More...
 
vector< shared_ptr< Card > > getAllCards () const
 Returns the vector of all cards in player's hand. More...
 
set< AnnouncementsgetAnnounced () const
 Inline assessor to the set of announcements. More...
 
vector< shared_ptr< Card > > getInitialCards () const
 Inline assessor to the player's initial cards. More...
 
int getNumberOudlers () const
 Inline assessor to the number of oudlers the player has with his/her initial hand. More...
 
void showCards () const
 To print all player's cards in his/her current hand. More...
 
vector< shared_ptr< Card > > validCards (const Suits referenceSuit, const shared_ptr< Card > greaterTrump) const
 Returns the vector of cards the player can currently play, regarding the asked suit and the greater trump of the trick. More...
 

Additional Inherited Members

- Public Attributes inherited from Player
string name
 The player's name. More...
 
double score
 The player's score. More...
 
- Protected Member Functions inherited from Player
vector< shared_ptr< Card > > callableCards (const Deck &deck) const
 To compute the vector of cards we can call during a 5-player game. More...
 
void delCard (const shared_ptr< Card > card)
 To delete a card from the player's current hand. More...
 
- Protected Attributes inherited from Player
set< shared_ptr< Card >
, cardOrder
hearts
 The set of Hearts owned by the player. More...
 
set< shared_ptr< Card >
, cardOrder
spades
 The set of Spades owned by the player. More...
 
set< shared_ptr< Card >
, cardOrder
diamonds
 The set of Diamonds owned by the player. More...
 
set< shared_ptr< Card >
, cardOrder
clubs
 The set of Clubs owned by the player. More...
 
set< shared_ptr< Card >
, cardOrder
trumps
 The set of trumps owned by the player. More...
 
shared_ptr< Cardfool
 The pointer toward the Fool, if owned by the player. More...
 
vector< shared_ptr< Card > > initialCards
 The vector of player's initial cards, from his/her starting hand. More...
 
int numberOudlers
 The number of oudlers the player has among his/her initial cards. More...
 
double initialPoints
 The number of points the player has with his/her initial cards. More...
 
set< Announcementsannounced
 The set of announcements (for what?). More...
 

Detailed Description

This class defines AI players.

The class AI extends Player and shows an interface for actions like playCard, make a bid, etc. Actions' implementation is decoupled from the class with a Strategy pattern, where concret classes correspond to a level of difficulty.

Constructor & Destructor Documentation

AI::AI ( const string &  name,
const vector< string > &  knownPartners 
)

AI constructor.

Parameters
nameA string for the AI name.
knownPartnersA vector of strings composed of the name of its partners.

Member Function Documentation

Biddings AI::bid ( const Biddings  bestBid,
const bool  chelemAnnounced 
) const
virtual

Called to decide if one proposes a bid or not, and if any, what bid.

bid is delegated to the difficulty Strategy.

Parameters
bestBidThe best bid proposed so far.
chelemAnnouncedA Boolean to know if someone has declared a chelem.
Returns
Our bid (Biddings::none if one passes).

Implements Player.

shared_ptr< Card > AI::chooseKing ( const Deck deck) const
virtual

To make a choice for partnership in a 5-player game.

Parameters
deckThe current deck used for the game
Returns
The chosen king (or card).

Implements Player.

bool AI::haveSuit ( const string &  name,
const Suits  suit 
) const

Given a Player p, does p have at least one card on the asked suit?

Parameters
nameThe Player's name in string.
suitThe asked suit.
Returns
False iff one is sure p does not have any cards of the asked suit.
bool AI::isOpponent ( const string &  name) const
inline

To know if someone is your opponent.

Parameters
nameThe Player's name in string.
Returns
If the given Player is an opponent or not.
bool AI::isPartner ( const string &  name) const
inline

To know if someone is your partner.

Parameters
nameThe Player's name in string.
Returns
If the given Player is an partner or not.
set< shared_ptr< Card > > AI::makeEcart ( const int  dogSize)
virtual

To make the ecart once one takes the dog.

makeEcart is delegated to the difficulty Strategy.

Parameters
dogSizeThe number of card one must include into the ecart.
Returns
A set of Card pointers for the cards one places into the ecart.

Implements Player.

void AI::newGame ( )
virtual

Must be called when starting a new game.

Flush to zero some variables and pointers.

Implements Player.

bool AI::opponentsHaveSuit ( const Suits  suit) const

Do opponents have at least one card on the asked suit?

Parameters
suitThe asked suit.
Returns
False iff one is sure no opponent player has a card of the asked suit.
shared_ptr< Card > AI::playCard ( const Suits  referenceCard,
const shared_ptr< Card highTrump 
)
virtual

Choose what card one plays, given the first card and the highest trump of the trick.

playCard is delegated to the difficulty Strategy.

Parameters
referenceCardA Card pointer of the first played card of the trick.
highTrumpA Card pointer of the highest trump of the trick.
Returns
The card the AI plays.

Implements Player.

void AI::setDifficulty ( const shared_ptr< StratDiff diff)
inline

Inline function to set the difficulty (set a Strategy concrete class).

Parameters
diffA pointer on the difficulty to set.

The documentation for this class was generated from the following files: