Giter VIP home page Giter VIP logo

poker's Introduction

Poker

CircleCI GoDoc codecov

Poker is ported from the Python library worldveil/deuces.

Installation

Use go get to install Poker:

$ go get github.com/chehsunliu/poker

Usage

Support 5-, 6-, and 7-card evalutions:

package main

import (
	"fmt"

	"github.com/chehsunliu/poker"
)

func main() {
	deck := poker.NewDeck()
	hand := deck.Draw(7)
	fmt.Println(hand)

	rank := poker.Evaluate(hand)
	fmt.Println(rank)
	fmt.Println(poker.RankString(rank))
}
$ go run ./main.go
[Kd 4h Qh 3s 8s 5h Jd]
6695
High Card

$ go run ./main.go
[4c Qh Ad 9c 9s 3h 4d]
3062
Two Pair

$ go run ./main.go
[Jh Qd Kd Qs 7d As Qh]
1742
Three of a Kind

Performance

Compared with notnil/joker, Poker is 160x faster on 5-card evaluation, and drops to 40x faster on 7-card evaluation.

go test -bench=. -benchtime 5s
goos: darwin
goarch: amd64
pkg: github.com/chehsunliu/poker
BenchmarkFivePoker-4    	23396181	       253 ns/op
BenchmarkFiveJoker-4    	  141036	     41662 ns/op
BenchmarkSixPoker-4     	 3037298	      1949 ns/op
BenchmarkSixJoker-4     	   28158	    211533 ns/op
BenchmarkSevenPoker-4   	  356448	     16357 ns/op
BenchmarkSevenJoker-4   	    7143	    759394 ns/op
PASS
ok  	github.com/chehsunliu/poker	40.111s

poker's People

Contributors

chehsunliu 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.