Coder Social home page Coder Social logo

cards's Introduction

cards

-- import "github.com/ElectricCoffee/cards"

package cards provides basic structures and functions for dealing with playing cards.

Usage

func NewDeck

func NewDeck(suits, values []string) []Card

NewDeck creates a new deck of cards from a slice of suits and a slice of values.

func NewFifthDimensionDeck

func NewFifthDimensionDeck() []Card

NewFifthDimensionDeck creates a deck of 5°Dimension Playing Cards. 5°Dimension is unique in that it has five suits, a Princess, a '1' different from Ace, and a Joker for each of the five suits. The five suits are: Spades, Clubs, Hearts, Diamonds, and Stars. The 5°Dimension deck has a total of 80 cards, as opposed to the usual 52.

func NewStandardDeck

func NewStandardDeck() []Card

NewStandardDeck creates a new standard western deck of cards with French suits (Spades, Clubs, Hearts, and Diamonds).

func Seed

func Seed()

Seed seeds the card randomiser using the current time in nanoseconds

func SeedInt

func SeedInt(value int64)

SeedInt seeds the card randomiser using an int64 value as its seed.

func Shuffle

func Shuffle(deck []Card)

Shuffle randomises the order of the cards in-place. It uses "math/rand" internally, and thus needs to be seeded before use. cards.Seed() and cards.SeedInt(int64) can be used for this

func Shuffled

func Shuffled(deck []Card) []Card

Shuffled is like Shuffle, except it's not destructive

type Card

type Card struct {
	Suit  string
	Value string
}

Card is a struct holding the suit and value associated with a card.

func NewCard

func NewCard(suit, value string) Card

NewCard creates a new instance of the card struct.

cards's People

Contributors

electriccoffee avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.