jskat.player.AIPlayerMJL
Class Helper

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

public class Helper
extends java.lang.Object

Author:
Markus J. Luzius

Constructor Summary
Helper()
           
 
Method Summary
static int binaryToSuit(int binary)
          Converts a binary stream to a suit color
static int countJacks(CardVector cards)
          Gets the number of jacks in the given hand
static int getHighestTrump(CardVector cards, int currTrump)
          Gets the highest trump card out of a given hand
static int getJacks(CardVector cards)
          Gets a binary representation of the jacks in the given hand
static int getMultiplier(CardVector cards)
          Gets the game multiplier
static boolean hasTrump(CardVector cards, int currTrump)
          Checks, whether there is at least one trump card in a given hand
static int isAbleToBeat(CardVector cards, Card cardToBeat, int trump, Card initialCard, int gameType)
          Decides whether a player is able to beat a certain card
static boolean isAbleToMatch(CardVector cards, int trump, Card initialCard, int gameType)
          Decides whether a player is able to match a certain initial card
static boolean isSinglePlayerWin(TrickInfo trick)
          Checks whether the current trick would be won by the single player, so that the AIPlayer can decide which card to play
static int suitCardsToBinary(CardVector cards, int suit)
          Converts a hand's cards of a certain suit to a binary stream
static int suitCardsToBinaryNullGame(CardVector cards, int suit)
          Converts a hand's cards of a certain suit to a binary stream for a null game (which means that jacks are also considered)
static int suitCardsToBinaryWithSkat(CardVector cards, CardVector skat, int suit)
          Converts a hand's and the skat's cards of a certain suit to a binary stream
static java.lang.String suitName(int suit)
          Converts the suit value to a suit name (one character)
"D" for Diamonds, "H" for Hearts, "S" for Spades, "C" for Clubs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Helper

public Helper()
Method Detail

isSinglePlayerWin

public static boolean isSinglePlayerWin(TrickInfo trick)
Checks whether the current trick would be won by the single player, so that the AIPlayer can decide which card to play

Parameters:
trick - All the necessary trick infos
Returns:
true, if the single player would win the trick

isAbleToBeat

public static int isAbleToBeat(CardVector cards,
                               Card cardToBeat,
                               int trump,
                               Card initialCard,
                               int gameType)
Decides whether a player is able to beat a certain card

Parameters:
cards - hand of the player
cardToBeat - card that should be beaten
trump - current trump color
initialCard - initial card of the trick
gameType - game type
Returns:
true, if cards contain a card that can beat the cardToBeat

isAbleToMatch

public static boolean isAbleToMatch(CardVector cards,
                                    int trump,
                                    Card initialCard,
                                    int gameType)
Decides whether a player is able to match a certain initial card

Parameters:
cards -
trump -
initialCard -
gameType -
Returns:
true if there is at least one card in the hand that can match initialCard

getHighestTrump

public static int getHighestTrump(CardVector cards,
                                  int currTrump)
Gets the highest trump card out of a given hand

Parameters:
cards - a hand
currTrump - the current trump color
Returns:
index of the highest trump, 0 if there is no trump

hasTrump

public static boolean hasTrump(CardVector cards,
                               int currTrump)
Checks, whether there is at least one trump card in a given hand

Parameters:
cards - a hand
currTrump - trump color
Returns:
true, if there is at least one trump card in the hand

getMultiplier

public static int getMultiplier(CardVector cards)
Gets the game multiplier

Parameters:
cards - a hand
Returns:
multiplier (only positive values)

suitCardsToBinaryWithSkat

public static int suitCardsToBinaryWithSkat(CardVector cards,
                                            CardVector skat,
                                            int suit)
Converts a hand's and the skat's cards of a certain suit to a binary stream

Parameters:
cards - a hand
skat - the skat
suit - only cards of this suit are considered
Returns:
binary value of the available cards

suitCardsToBinary

public static int suitCardsToBinary(CardVector cards,
                                    int suit)
Converts a hand's cards of a certain suit to a binary stream

Parameters:
cards - a hand
suit - only cards of this suit are considered
Returns:
binary value of the available cards

suitCardsToBinaryNullGame

public static int suitCardsToBinaryNullGame(CardVector cards,
                                            int suit)
Converts a hand's cards of a certain suit to a binary stream for a null game (which means that jacks are also considered)

Parameters:
cards - a hand
suit - only cards of this suit are considered
Returns:
binary value of the available cards

getJacks

public static int getJacks(CardVector cards)
Gets a binary representation of the jacks in the given hand

Parameters:
cards - a hand
Returns:
binary value of the available jacks

countJacks

public static int countJacks(CardVector cards)
Gets the number of jacks in the given hand

Parameters:
cards - a hand
Returns:
number of jacks

binaryToSuit

public static int binaryToSuit(int binary)
Converts a binary stream to a suit color

Parameters:
binary - binary stream (four bits)
Returns:
suit color, -1 if more than one bit is set

suitName

public static java.lang.String suitName(int suit)
Converts the suit value to a suit name (one character)
"D" for Diamonds, "H" for Hearts, "S" for Spades, "C" for Clubs

Parameters:
suit - suit value
Returns:
suit name ("x" if not recognized)