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

blackjack-tools

v2.0.0

Published

Blackjack tools

Downloads

3

Readme

Blackjack-tools

Some JS classes to work with the popular card game Blackjack.

sim.js is a simulator (run it, it defaultly simulates 6 players playing basic strategy, and a dealer hitting on 16 and below).

blackjack.js contains the classes of the card deck, player, dealer, result, hand, card and log.

game.js contains the game class that runs through a game of blackjack.

strategy.js contains the implementation of the blackjack Basic Strategy choice matrix.

Basic Strategy

Implements "Basic Strategy" i.e. the matrix of whether to hit/stand/double/split on any hand, given the dealer's face-up card.

Player will double when the stategy tells them to, leading to larger winnings in the case of a win.

Customisations

You can change the default bet amount.

You can change the payout (i.e., default is 3/2, whereas some casino tables are 6/5 etc.)

You can change the number of rounds.

You can change the number of players.

You can select what to print using different logging types.

You can choose to print emoji suits or just letters.

Example Output

If full log output is enabled, the following is an example of a round of play:

Round 1, Card 1, Player 1: (4♠️  [hard 4])
Round 1, Card 1, Player 2: (10♠️  [hard 10])
Round 1, Card 1, Player 3: (Q♣️  [hard 10])
Round 1, Card 1, Player 4: (5♥️  [hard 5])
Round 1, Card 1, Player 5: (3♠️  [hard 3])
Round 1, Card 1, Player 6: (A♦️  [soft 11])
Round 1, Card 1, Dealer: (7♥️  [hard 7])
Round 1, Card 2, Player 1: (4♠️ ,6♦️  [hard 10])
Round 1, Card 2, Player 1 (after strategy): (4♠️ ,6♦️ ,8♦️  [hard 18])
Round 1, Card 2, Player 2: (10♠️ ,2♠️  [hard 12])
Round 1, Card 2, Player 2 (after strategy): (10♠️ ,2♠️ ,4♥️ ,9♦️  [hard 25])
Round 1, Card 2, Player 3: (Q♣️ ,9♥️  [hard 19])
Round 1, Card 2, Player 3 (after strategy): (Q♣️ ,9♥️  [hard 19])
Round 1, Card 2, Player 4: (5♥️ ,10♥️  [hard 15])
Round 1, Card 2, Player 4 (after strategy): (5♥️ ,10♥️ ,10♣️  [hard 25])
Round 1, Card 2, Player 5: (3♠️ ,J♠️  [hard 13])
Round 1, Card 2, Player 5 (after strategy): (3♠️ ,J♠️ ,4♣️  [hard 17])
Round 1, Card 2, Player 6: (A♦️ ,5♦️  [soft 16])
Round 1, Card 2, Player 6 (after strategy): (A♦️ ,5♦️ ,A♣️ ,6♣️ ,J♣️  [hard 23])
Round 1, Card 2, Dealer: (7♥️ ,Q♠️  [hard 17])
Round 1, Card 2, Dealer (after dealer strategy): (7♥️ ,Q♠️  [hard 17])
Player 1, trick 1 wins.
Player 2, trick 1 loses.
Player 3, trick 1 wins.
Player 4, trick 1 loses.
Player 5, trick 1 pushes.
Player 6, trick 1 loses.

At the end of the simulation, a summary of the results are shown:

Player 1: 
    Played: 5, Won: 4, Pushed: 0, Lost: 1
    Bet: 50, Winnings: 100, Payout: 2
Player 2: 
    Played: 5, Won: 2, Pushed: 1, Lost: 2
    Bet: 50, Winnings: 60, Payout: 1.2
Player 3: 
    Played: 5, Won: 3, Pushed: 0, Lost: 2
    Bet: 50, Winnings: 75, Payout: 1.5
Player 4: 
    Played: 5, Won: 1, Pushed: 1, Lost: 3
    Bet: 50, Winnings: 35, Payout: 0.7
Player 5: 
    Played: 5, Won: 4, Pushed: 1, Lost: 0
    Bet: 50, Winnings: 110, Payout: 2.2
Player 6: 
    Played: 5, Won: 2, Pushed: 0, Lost: 3
    Bet: 50, Winnings: 50, Payout: 1

Average Payout: 1.4333333333333336

Installation

Run npm install to install the dependencies.

Run node sim to run the simulation.

Issues

Does not implement splitting (although there is skeleton support, in that multiple tricks per hand has been coded in).

Does not implement insurance.