npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prokerjs

v1.0.0

Published

Texas Hold'em Poker Probability Library

Downloads

17

Readme

ProkerJS - Poker Hand Probability Calculator Library

A library to calculate the probabilities of a Texas Hold'em Poker hand using a Monte Carlo algorithm.

Development

  • Run npm run start to automatically compile the program into dist/bundle.js as you save new files.
  • Test the program by opening the examples/index.html file in a browser.
  • If you create new classes, include them in src/index.js.

TODO

  • [x] Project structure
  • [x] Class relationships
  • [ ] Poker logic
    • [x] Set ranks
    • [x] Compare hands
    • [x] Deal specific/random cards
    • [x] Probabilities
    • [ ] Concurrency
  • [ ] API
  • [ ] Documentation
  • [ ] Tests

Logic to calculate the best hand

  1. Class: Hand
  2. Receives 7 cards: 5 from the table and 2 from the player
  3. Generates all combinations
  4. Evaluates the rank of each hand
  5. Breaks ties between hands of the same rank

Tests

Automatic tests

  • TO-DO // Mocha (?)

Manual tests

  • Test dealing cards // player best hands
t = new Table(6);
cards = [new Card('A','s')];
t.deal_to_player(t.players[0],cards);
t.full_deal_random();
t.player_hands();
t.players[0].hand.show();
  • Testing sort method
h=new Hand([new Card('A','D'),new Card('K','D'),new Card('Q','D'),new Card('J','D'),new Card('T','D')]);
h.show()
h.cards.sort(Hand.compare)
h.show()
  • Test sorting straights
h=new Hand([new Card('A','D'),new Card('K','D'),new Card('Q','D'),new Card('J','D'),new Card('T','D')]);
h=new Hand([new Card('5','D'),new Card('A','D'),new Card('3','D'),new Card('2','D'),new Card('4','D')]);
  • Compare combinations
c = new Combination([new Card('7','S'),new Card('J','H'),new Card('6','C'),new Card('4','C'),new Card('2','D'),new Card('8','S'),new Card('6','')])
  • Test winner
t = new Table(6);
cards = [new Card('A','s'), new Card('a','c')];
t.deal_to_player(t.players[0],cards);
t.full_deal_random();
t.player_hands();
t.show();
for (let i=0; i<6; i++) {
  t.players[i].hand.show();
}
  • Test compare_to (Hand)
h1 = new Hand([new Card('J','H'),new Card('8','S'),new Card('7','S'),new Card('6','D'),new Card('6','S')]);
h2 = new Hand([new Card('J','H'),new Card('8','S'),new Card('7','S'),new Card('6','D'),new Card('4','D')]);
h1.compare_to(h2);
h2.compare_to(h1);
  • Test deck
d = new Deck()
d.is_free_card(new Card('a','s'))
d.remove_card(new Card('a','s'))
d.is_free_card(new Card('a','s'))
  • Test probabilities
t = new Table(6);
// Opcional to set 
  cards = [new Card('A','s'), new Card('a','c')];
  t.deal_to_player(t.players[0],cards);
  cards = [new Card('K','s'), new Card('t','h')];
  t.deal_to_player(t.players[1],cards);
  cards = [new Card('k','c'), new Card('q','d'), new Card('j','d'), new Card('t','d')];
  t.deal_to_table(cards);
//
p = new Proker(t);
p.compute(10000);
  • Test deep copies

    • Deck
d = new Deck()
d2 = d.copy()
d.shuffle()
d.show()
d2.show()
  • Table
t = new Table(6)
t2 = t.copy()
  • Player
p = new Player('p1')
p2 = p.copy()
p.cards = [new Card('a','c'), new Card('a','s')]
  • Proker
t = new Table(3);
// Opcional to set 
  cards = [new Card('A','s'), new Card('a','c')];
  t.deal_to_player(t.players[0],cards);
  cards = [new Card('K','s'), new Card('t','h')];
  t.deal_to_player(t.players[1],cards);
  cards = [new Card('k','c'), new Card('q','d'), new Card('j','d'), new Card('t','c')];
  t.deal_to_table(cards);
//
p = new Proker(t);
p.compute(10000);
// p.table.players[5].cards
t = new Table(3);
// Opcional to set 
  cards = [new Card('A','s'), new Card('a','c')];
  t.deal_to_player(t.players[0],cards);
  cards = [new Card('K','s'), new Card('t','h')];
  t.deal_to_player(t.players[1],cards);
  cards = [new Card('k','c'), new Card('q','d'), new Card('j','d'), new Card('t','c')];
  t.deal_to_table(cards);
//
p = new Proker(t);
p.compute(10000);
p.show();
// p.table.players[5].cards
  t = new Table(2);
  cards = [new Card('A','s'), new Card('j','s')];
  t.deal_to_player(t.players[0],cards);
  cards = [new Card('6','h'), new Card('6','h')];
  t.deal_to_player(t.players[1],cards);
  p = new Proker(t);
  p.compute(10000);
  p.show();
// p.table.players[5].cards