jskat.player.AIPlayerMJL
Class CardMemory

java.lang.Object
  extended by jskat.player.AIPlayerMJL.CardMemory

public class CardMemory
extends java.lang.Object

CardMemory builds the memory of all the cards that have been played during a certain game. It remembers all the initial cards as well as the individual hands of all players.

Author:
Markus J. Luzius

Constructor Summary
CardMemory()
          Default constructor
CardMemory(int gameType, int trump)
          Extended constructor with the values of the current game
 
Method Summary
 void addTrick(CardVector trick, int forehandPlayer)
          Adds the cards of the current trick to the memory
 int remainingCards(int suit, CardVector myCards)
          Calculates how many cards of that suit are still out.
 int timesDemanded(int suit)
          Counts, how many times the given suit has been demanded as initial card.
 int timesPlayedByPlayer(int player, int suit)
          Counts, how many cards of a given suit a player has already played.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CardMemory

public CardMemory()
Default constructor


CardMemory

public CardMemory(int gameType,
                  int trump)
Extended constructor with the values of the current game

Parameters:
gameType -
trump -
Method Detail

addTrick

public void addTrick(CardVector trick,
                     int forehandPlayer)
Adds the cards of the current trick to the memory

Parameters:
trick - current trick
forehandPlayer - player of the first card in the trick

timesPlayedByPlayer

public int timesPlayedByPlayer(int player,
                               int suit)
Counts, how many cards of a given suit a player has already played.
In a suit game, for a normal suit the maximum can be 7, of trump it can be 11. In a null game, the maximum is 8, in a grand game 7 for all suits.

Parameters:
player - Player who is evaluated
suit - Suit which is evaluated
Returns:
Number of times the given player has played a card of that suit

timesDemanded

public int timesDemanded(int suit)
Counts, how many times the given suit has been demanded as initial card.

Parameters:
suit - Suit which is evaluated
Returns:
Number of times the suit has been demanded

remainingCards

public int remainingCards(int suit,
                          CardVector myCards)
Calculates how many cards of that suit are still out.

Parameters:
suit - Suit which is evaluated
myCards - Hand of the player
Returns:
Number of cards still out for that suit