Types
GoFish.Game — TypeGame{T} <: AbstractGame{T}A Go Fish game object where T is the player id type.
Fields
deck: deck of cardsbook: a dictionary containing player id and card value:id => valuehand_size: maximum number of cards in each player's hand
GoFish.Game — MethodGame(ids)A constructor function for simulation game
Argument
ids: a vector or key set of player ids for book dictionary
GoFish.Human — TypeHuman{T} <: AbstractPlayerA human player game object where T is the player id type.
Fields
id::Int: suit of cardcards::Vector{Card}: player's cards
GoFish.Human — MethodHuman(;id)Creates a Human object
Keyword
id: integer representing unique id
GoFish.InteractiveGame — TypeInteractiveGame{T} <: AbstractGame{T}A constructor function to play Go Fish interactively where T is the player id type.
Argument
ids: a vector of player ids for book dictionary
GoFish.Player — TypePlayer{T} <: AbstractPlayerA Go Fish player object where T is the player id type.
Fields
id::Int: suit of cardcards::Vector{Card}: player's cards
GoFish.Player — MethodPlayer(; id)Creates a Player object
Keyword
id: integer representing unique id
Public Functions
GoFish.deal! — Methoddeal!(game::AbstractGame, players)Randomizes and deals cards to each player. Each player recieves 7 cards if the number of cards is 1-3; otherwise, each player recieves 5 cards.
Arguments
game: a game objectplayers: a dictionary of players
GoFish.get_winners — Methodget_winners(game::AbstractGame{T})Returns a vector of winners. In the event of a tie, there will not be a unique winner.
Arguments
game: game object
GoFish.simulate! — Methodsimulate!(game::AbstractGame, players)Performs a single simulation of GoFish.
Arguments
game: game objectinquirer: the player who asks for cardsplayers: a dictionary of players.
Public Functions
GoFish.PlayGame — MethodPlayGame(; ids, delay = 1.0)A constructor function for simulation game
Keywords
n_players: the number of playerdelay: delay between actions
GoFish.add! — Methodadd!(player::AbstractPlayer, card::Card)Add a card to a player's hand.
Arguments
player: a player objectcard: a card objects
GoFish.add! — Methodadd!(player::AbstractPlayer, cards::Vector{Card})Add a vector of cards to a player's hand.
Arguments
player: a player objectcards: a vector of card objects
GoFish.decide — Methoddecide(player::AbstractPlayer, ids)A default method impliments the player's decision logic and returns a tuple containing the id of the player who is queried and the rank of the card.
Arguments
player: the player who makes a decisionids: a vector of player ids
GoFish.go_fish — Methodgo_fish(game::AbstractGame)Draw a single card from the deck.
Arguments
game: game object
GoFish.has_card — Methodhas_card(player::AbstractPlayer, value)Check whether a player has a card with a specified value
Arguments
player: a player objectvalue: value or rank of a card
GoFish.inquire! — Methodinquire!(game::AbstractGame, player::AbstractPlayer, players)The primary inquiry loop in which a player asks other plays for cards. This procedure will handle the exchange of cards, update the books, and go fish.
Arguments
game: game objectinquirer: the player who asks for cardsplayers: a dictionary of players.
GoFish.observe_exchange! — Functionobserve_exchange!(players, inquirer, opponent_id, value, cards=Card[])Loop through all players and process the exchange of cards
Arguments
players: a dictionary of players.inquirer: the player who asks for cardsopponent_id: player id of player who was queriedvalue: value of the card in the querycards=Card[]: a vector of cards exchanged between the inquirer and the opponent player
GoFish.process_books! — Methodprocess_books!(player::AbstractPlayer, book_map)Allow the player to track the cards that are no longer in play.
Arguments
player: the player which is updatedbook_map: a dictionary with player id as key and new book as vector of cards
GoFish.process_exchange! — Methodprocess_exchange!(player::AbstractPlayer, inquirer_id, opponent_id, value, cards)Default function which allows a player to observe the exchange of cards between two players. This function must be extended for custom player types.
Arguments
players: a dictionary of players.inquirer_id: id of the player who asks for cardsopponent_id: player id of player who was queriedvalue: value of the card in the querycards=Card[]: a vector of cards exchanged between the inquirer and the opponent player
GoFish.process_go_fish! — Methodprocess_go_fish!(player::AbstractPlayer, inquirer_id)Process the result of a go fish.
This function must be extended for custom player types.
Arguments
player: the player which is updatedinquirer_id: id of the player who asks for cards
GoFish.remove! — Methodremove!(player::AbstractPlayer, value)Remove and return cards of a specified value from a player.
Arguments
player: a player objectvalue: value or rank of a card
GoFish.setup! — Methodsetup!(player::AbstractPlayer, ids)Perform initial setup after cards are delt, but before the game begins.
Arguments
player: a player objectids: all player ids