public class BasicHand extends Object implements Iterable<Card>, Hand
This only keeps track of only explicitly told information (performs no deduction)
Constructor and Description |
---|
BasicHand(BasicHand hand)
Create a deep copy of a given hand.
|
BasicHand(int size)
Create a new blank hand.
|
Modifier and Type | Method and Description |
---|---|
void |
bindCard(int slot,
Card card)
Bind a card to a given slot, keeping all known information about it.
|
boolean |
equals(Object o) |
Card |
getCard(int slot)
Get the card really present in the slot (or null if unknown).
|
CardColour |
getKnownColour(int slot)
Get the known colour of this slot, from the perspective of the player who's hand it is.
|
Integer |
getKnownValue(int slot)
Get the known value of this slot, from the perspective of the player who's hand it is.
|
CardColour[] |
getPossibleColours(int slot)
get possible colours for a given slot.
|
int[] |
getPossibleValues(int slot)
get possible values for a given slot.
|
int |
getSize()
The number of cards which make up this hand.
|
boolean |
hasCard(int slot)
Does the hand contain a card in this slot?
|
boolean |
hasColour(CardColour colour)
Has a card of that colour that it knows exactly about
|
int |
hashCode() |
boolean |
hasValue(Integer value)
Has a card of that value that it knows exactly about
|
void |
init()
Initialise all information about the slots.
|
boolean |
isCompletePossible(int slot,
Card card)
Check if this card is possible based on complete infomation.
|
boolean |
isPossible(int slot,
Card card)
check if the card is possible, based on the owner's prespective
|
Iterator<Card> |
iterator()
Create an iterator of the cards, based on the real cards present.
|
void |
setCard(int slot,
Card card)
Set a card in a given slot, removing all known information about it.
|
void |
setHasCard(int slot,
boolean value)
Sets whether the hand has a card in this slot.
|
void |
setKnownColour(CardColour colour,
Integer[] slots)
Sets the known colour of a slot from the perspective of the owner.
|
void |
setKnownValue(Integer value,
Integer[] slots)
Sets the known value of a slot from the perspective of the owner.
|
String |
toString()
Pretty print this hand.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public BasicHand(BasicHand hand)
hand
- the hand to copypublic BasicHand(int size)
When initialised, all card slots will be blank (have no card present).
size
- the number of cards in this handpublic void init()
This should reset any known infomation for any slot in the hand.
public Card getCard(int slot)
This is the card which is present in the slot based on information provided by the game itself. This method should always return null for your own hand (agents should not call this method on their own hands).
Agents can use this for accurate information about other player's hands.
public CardColour getKnownColour(int slot)
For this version of the hand class, this is worked out based on explicitly observed tell actions. It will not take into account negative information.
getKnownColour
in interface Hand
slot
- the slot to querypublic Integer getKnownValue(int slot)
For this version of the hand class, this is worked out based on explicitly observed tell actions. It will not take into account negative information.
getKnownValue
in interface Hand
slot
- the slot to querypublic int getSize()
This can very with game size, and so this should be used whenever you need to iterate over the number of slots in this player's hand.
public Iterator<Card> iterator()
This uses the same values as getCard(int)
.
public void setCard(int slot, Card card)
This should be called when a CardDrawn
event occurs in order
to update this hand with the correct information.
It will also reset all known information from the perspective of the owner.
public void bindCard(int slot, Card card)
This has the same basic role as setCard(int, com.fossgalaxy.games.fireworks.state.Card)
but will not remove any information from the owners perspective.
This is mostly useful when using this class as part of a simulation based agent to set the value of the card.
public void setKnownColour(CardColour colour, Integer[] slots)
This method is used to inform the hand about the card from the owner's perspective (tell actions).
setKnownColour
in interface Hand
colour
- the colour to assign to the slotsslots
- the slots to assign the colour to.public void setKnownValue(Integer value, Integer[] slots)
This method is used to inform the hand about the card from the owner's perspective (tell actions).
setKnownValue
in interface Hand
value
- the value to assign to the slotsslots
- the slots to assign the value to.public String toString()
public boolean isCompletePossible(int slot, Card card)
isCompletePossible
in interface Hand
slot
- the slot to checkcard
- the card we are consideringpublic boolean isPossible(int slot, Card card)
isPossible
in interface Hand
slot
- the slot to checkcard
- the card we are consideringpublic int[] getPossibleValues(int slot)
getPossibleValues
in interface Hand
slot
- the slot to checkpublic CardColour[] getPossibleColours(int slot)
getPossibleColours
in interface Hand
slot
- the slot to checkpublic boolean hasColour(CardColour colour)
Hand
public boolean hasValue(Integer value)
Hand
public boolean hasCard(int slot)
Hand
public void setHasCard(int slot, boolean value)
Hand
setHasCard
in interface Hand
slot
- The slot to setvalue
- The presence or not of a cardCopyright © 2017 FOSS Galaxy. All rights reserved.