Giter VIP home page Giter VIP logo

41poker's Introduction

41poker

Build Status

41poker is a JavaScript toolset for Texas Hold'em, including

  • efficient hand evaluator for 5,6,7 cards
  • hand strength simulator for preflop, flop, turn
  • console/browser gameplay
  • smart agent (to be implemented)
  • ...

Some development notes are published in Japanese at Qiita. Contact me @41semicolon at Twitter.

Install

TBW

Usage

import

const P = require('./src/index.js');
// will be replaced by const P = require('41poker') when published to npm;

deal 7 cards and evaluate it.

const myhand = P.deck().slice(0,7);
console.log(myhand)
// -> [ 46, 48, 13, 30, 16, 1, 4 ]

const value = P.handval(myhand);
const name = P.handname(value);
const handrepr = myhand.map(P.repr).join(' ');
console.log(handstr, name, value);
// -> K♣ A♥ 5♦ 9♣ 6♥ 2♦ 3♥ high card 6305

calculate your hand strength (derived by simulation)

P.hs([51, 50], 2) // -> 0.8553, hand strength of AA, 2players, preflop.
P.hs([51, 50], 3) // -> 0.7444, hand strength of AA, 3players, preflop.

P.hs([51, 50], 2, [3, 8, 40]) // -> 0.8466 hs of AA, 2players, flop with 2♠ 4♥ Q♥
P.hs([51, 50], 3, [3, 8, 40]) // -> 0.7287 hs of AA, 3players, flop with 2♠ 4♥ Q♥

P.hs([51, 50], 2, [3, 8, 40, 20]) // -> 0.7837 hs of AA, 2players, turn with 2♠ 4♥ Q♥ 7♥
P.hs([51, 50], 3, [3, 8, 40, 20]) // -> 0.6212 hs of AA, 3players, turn with 2♠ 4♥ Q♥ 7♥

handmeter, which you can find in TV show.

const deck = P.deck();
const hands = [deck.slice(0, 2), deck.slice(2, 4)];
const hrepr = hands.map(([c1 ,c2]) => P.repr(c1) + P.repr(c2));
console.log(hrepr);
// -> [ '7♦A♥', '6♣2♠' ]

const preflop = P.handmeterTV([], hands).map(x => x.toFixed(2));
console.log(hrepr[0], preflop[0], hrepr[1], preflop[1]);
// -> 7♦A♥ 66.41 6♣2♠ 33.59

const flop = P.handmeterTV(deck.slice(4, 7), hands).map(x => x.toFixed(2));
console.log(hrepr[0], flop[0], hrepr[1], flop[1], deck.slice(4, 7).map(P.repr).join(''));
// -> 7♦A♥ 92.64 6♣2♠ 7.36 A♦T♠K♠

const turn = P.handmeterTV(deck.slice(4, 8), hands).map(x => x.toFixed(2));
console.log(hrepr[0], turn[0], hrepr[1], turn[1], deck.slice(4, 8).map(P.repr).join(''));
// -> 7♦A♥ 100.00 6♣2♠ 0.00 A♦T♠K♠8♣

Articles

In github pages, some outcome derived by 41poker is available.

Some development notes are available in Japanese.

Thanks

License

MIT © @41semicolon

41poker's People

Contributors

41semicolon avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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