Types

GoFish.Game — Type
Game{T} <: AbstractGame{T}

A Go Fish game object where T is the player id type.

Fields

  • deck: deck of cards
  • book: a dictionary containing player id and card value: id => value
  • hand_size: maximum number of cards in each player's hand
source
GoFish.Game — Method
Game(ids)

A constructor function for simulation game

Argument

  • ids: a vector or key set of player ids for book dictionary
source
GoFish.Human — Type
Human{T} <: AbstractPlayer

A human player game object where T is the player id type.

Fields

  • id::Int: suit of card
  • cards::Vector{Card}: player's cards
source
GoFish.Human — Method
Human(;id)

Creates a Human object

Keyword

  • id: integer representing unique id
source
GoFish.InteractiveGame — Type
InteractiveGame{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
source
GoFish.Player — Type
Player{T} <: AbstractPlayer

A Go Fish player object where T is the player id type.

Fields

  • id::Int: suit of card
  • cards::Vector{Card}: player's cards
source
GoFish.Player — Method
Player(; id)

Creates a Player object

Keyword

  • id: integer representing unique id
source

Public Functions

GoFish.deal! — Method
deal!(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 object
  • players: a dictionary of players
source
GoFish.get_winners — Method
get_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
source
GoFish.simulate! — Method
simulate!(game::AbstractGame, players)

Performs a single simulation of GoFish.

Arguments

  • game: game object
  • inquirer: the player who asks for cards
  • players: a dictionary of players.
source

Public Functions

GoFish.PlayGame — Method
PlayGame(; ids, delay = 1.0)

A constructor function for simulation game

Keywords

  • n_players: the number of player
  • delay: delay between actions
source
GoFish.add! — Method
add!(player::AbstractPlayer, card::Card)

Add a card to a player's hand.

Arguments

  • player: a player object
  • card: a card objects
source
GoFish.add! — Method
add!(player::AbstractPlayer, cards::Vector{Card})

Add a vector of cards to a player's hand.

Arguments

  • player: a player object
  • cards: a vector of card objects
source
GoFish.decide — Method
decide(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 decision
  • ids: a vector of player ids
source
GoFish.go_fish — Method
go_fish(game::AbstractGame)

Draw a single card from the deck.

Arguments

  • game: game object
source
GoFish.has_card — Method
has_card(player::AbstractPlayer, value)

Check whether a player has a card with a specified value

Arguments

  • player: a player object
  • value: value or rank of a card
source
GoFish.inquire! — Method
inquire!(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 object
  • inquirer: the player who asks for cards
  • players: a dictionary of players.
source
GoFish.observe_exchange! — Function
observe_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 cards
  • opponent_id: player id of player who was queried
  • value: value of the card in the query
  • cards=Card[]: a vector of cards exchanged between the inquirer and the opponent player
source
GoFish.process_books! — Method
process_books!(player::AbstractPlayer, book_map)

Allow the player to track the cards that are no longer in play.

Arguments

  • player: the player which is updated
  • book_map: a dictionary with player id as key and new book as vector of cards
source
GoFish.process_exchange! — Method
process_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 cards
  • opponent_id: player id of player who was queried
  • value: value of the card in the query
  • cards=Card[]: a vector of cards exchanged between the inquirer and the opponent player
source
GoFish.process_go_fish! — Method
process_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 updated
  • inquirer_id: id of the player who asks for cards
source
GoFish.remove! — Method
remove!(player::AbstractPlayer, value)

Remove and return cards of a specified value from a player.

Arguments

  • player: a player object
  • value: value or rank of a card
source
GoFish.setup! — Method
setup!(player::AbstractPlayer, ids)

Perform initial setup after cards are delt, but before the game begins.

Arguments

  • player: a player object
  • ids: all player ids
source