Giter Club home page Giter Club logo

texas's Introduction

texas

Texas is a library to provide 5 to 7 card hands evaluation for Texas Hold'em on node.js. It uses the look-up table method created by users of the Two Plus Two forum.

Installing

npm install texas

Using

Evaluator

The following example generates a random hand and evaluates it:

var _ = require('underscore');
var texas = require('texas');

var hand = _.first(texas.deck(), 7);
console.log(_.map(hand, texas.abbr));
console.log(texas.evaluate(hand));

Which will output something like:

[ '5h', '3s', '4d', '7s', '5d', 'Jd', '6d' ]
{ name: 'Straight', value: 20483 }

Odds

The following example calculates the odds of a 2-player game after the flop:

var texas = require('texas');

var odds = texas.odds([['As', 'Ac'], ['Ks', 'Qc']], ['3d', 'Qc', 'Kd']);
console.log(odds);

Which will output something like:

[ { win: 0.2608695652173913, split: 0 },
  { win: 0.7391304347826086, split: 0 } ]

Formats

Extended

> texas.extended(3)
'Two of Hearts'

Abbreviated

> texas.abbr(15)
'5h'

Unicode

> texas.unicode(42)
'Q♦'

Benchmark

A benchmark function is included in the library. It evaluates every possible 7 card hands.

> texas.benchmark()
Invalid: 0
High Card: 23294460
One Pair: 58627800
Two Pairs: 31433400
Three of a Kind: 6461620
Straight: 6180020
Flush: 4047644
Full House: 3473184
Four of a Kind: 224848
Straight Flush: 41584
Total: 133784560
891ms // On a Mid 2011 13" MacBook Air

texas's People

Contributors

treyreynolds avatar

Watchers

James Cloos avatar Justin Molitor 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.