trigo

package module
v0.0.0-...-fa3ad48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2015 License: MIT Imports: 4 Imported by: 2

README

TriGo

TriGo is a pattern matching card game.

The trigo package provides the basic game engine, with customizable game parameters.

Two front ends are included. app/trigo is a mobile app, which currently runs on Android, using golang.org/x/mobile. cmd/trigo is a terminal app, and requires unicode and ANSI color support.

The game

  • Each card has four attributes: number, shape, color, and fill.
  • Each attribute has three possible values (terminal version in parentheses):
    • number: 1, 2, 3
    • shape: triangle, square, hexagon (circle)
    • color: red, green, blue (magenta)
    • fill: outline, striped (filled with outline), solid
  • The deck consists of the 81 possible combinations of the attributes (3^4).
  • The goal is to find matches which consist of three cards that satisfy the following rule. For each of the four attribute, the three cards must be all the same or all different. To put it another way, if two cards have the same attribute and the third is different, the cards are not a match. Matches can have a mix of all-same and all-different for the four attributes.

Play

  • A 4x3 grid of cards is dealt.
  • Select three cards to make a match.
    • In the mobile app, tap or click the three cards.
    • In the terminal app, type the letters corresponding to the cards and press ''.
  • If the cards form a valid match, they are removed and new cards are dealt in their place.
  • At any time during play, if there are no possible matches, extra rows of cards are dealt until there is at least one possible match.
  • Play continues until all cards have been dealt and valid matches remain.
  • When all matches have been found, the deck is reshuffled and a new game begins.

Documentation

Overview

Package trigo provides the base for implementing a card game

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	Attr  []int
	Blank bool
}

Card represents a playing card with attributes.

type TriGo

type TriGo struct {
	// contains filtered or unexported fields
}

TriGo represents an instance of a game and its state.

func New

func New(numAttrs, numAttrVals, fieldSize, fieldExpand int) *TriGo

New returns an instance of a custom game.

func NewFromSavedState

func NewFromSavedState(state []byte) *TriGo

NewFromSavedState returns a game instance initialized to the given state.

func NewStd

func NewStd() *TriGo

NewStd returns an instance of a standard game.

func (*TriGo) Card

func (t *TriGo) Card(i int) Card

Card returns ith card from the set of all cards, or a blank card if i is out of range.

func (*TriGo) Deal

func (t *TriGo) Deal()

Deal deals new cards to the field, expanding the field if necessary until at least one match is available.

func (*TriGo) DeckSize

func (t *TriGo) DeckSize() int

DeckSize returns the number of cards currently in the deck.

func (*TriGo) Field

func (t *TriGo) Field() []Card

Field returns a slice of card indices representing the current field.

func (*TriGo) FieldCard

func (t *TriGo) FieldCard(i int) Card

FieldCard returns the ith field card, or a blank card if i is out of range.

func (*TriGo) FieldMatches

func (t *TriGo) FieldMatches() int

FieldMatches returns the number of matches in the field.

func (*TriGo) IsMatch

func (t *TriGo) IsMatch(candidate []int) bool

IsMatch returns whether a given match candidate is valid

func (*TriGo) MatchesFound

func (t *TriGo) MatchesFound() int

MatchesFound returns the number of matches found in the current game

func (*TriGo) Remove

func (t *TriGo) Remove(match []int)

Remove removes a match from the field. Match is not verified. Use IsMatch() to check.

func (*TriGo) Shuffle

func (t *TriGo) Shuffle()

Shuffle refills and shuffles the deck, and clears the field.

func (*TriGo) State

func (t *TriGo) State() ([]byte, error)

Directories

Path Synopsis
app
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL