SetGame

com.phasmidsoftware.number.top.SetGame
class SetGame(random: Random = ...)

Represents the game logic for the card game "Set". See https://en.wikipedia.org/wiki/Set_(card_game).

The SetGame class encapsulates functionality for managing and executing the rules and behavior of the game. The game involves identifying sets of three cards from a collection that satisfy specific matching conditions.

This class may include operations such as dealing cards, validating sets, and tracking the state of the game. It is designed to support the core mechanics of the "Set" game.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def dozen: Seq[Card]

Deals a random selection of 12 cards from the full deck. The method shuffles the complete sequence of cards and selects the first 12 cards in the newly randomized order. HINT: use random to do the shuffling.

Deals a random selection of 12 cards from the full deck. The method shuffles the complete sequence of cards and selects the first 12 cards in the newly randomized order. HINT: use random to do the shuffling.

Attributes

Returns

A sequence of 12 randomly selected Card objects.

def sets(cards: Seq[Card]): Seq[Set]

Identifies all possible valid sets from a given sequence of cards. A valid set consists of exactly three cards that satisfy the rules of the "Set" game: for each attribute (shape, color, number, and shading), the values must either all be the same or all be different across the three cards.

Identifies all possible valid sets from a given sequence of cards. A valid set consists of exactly three cards that satisfy the rules of the "Set" game: for each attribute (shape, color, number, and shading), the values must either all be the same or all be different across the three cards.

The method generates all possible combinations of three cards from the input sequence, evaluates each combination to check if it forms a valid set, and returns the collection of valid sets.

Value parameters

cards

A sequence of Card objects to search for valid sets.

Attributes

Returns

A sequence of valid Set objects found within the given cards.

Concrete fields

val fullDeck: Seq[Card]

Generates a full deck of 81 unique cards for the game of Set.

Generates a full deck of 81 unique cards for the game of Set.

Attributes