New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@botpoker/engine-holdem

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@botpoker/engine-holdem

Texas Hold'em poker engine

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-62.5%
Maintainers
1
Weekly downloads
 
Created
Source

@botpoker/engine-holdem

@botpoker/engine-holdem provides an engine to play Texas Hold'em Poker in respect of the official rules.

Poker here is meant to be played by other programs, which should be listening for POST http request somewhere in the Internet, or on your localhost.

It's used as default poker holdem engine for http://botpoker.org.

demo

It's possible to run a demo on your local machine by executing the npm run demo from the project root folder.

start a tournament

const Tournament = require("@botpoker/engine-holdem");

const tournamentID = "botparty";

const players = [
  {
    id: "r2",
    name: "r2d2",
    serviceUrl: "http://127.0.0.1:8080/"
  },
  ...
];

const tournamentSettings = {
  BUYIN: 100,
  // Read docs/game-settings.md for the available configuration options.
};

const opts = {
  async onFeed (feed) {},
  async onGameComplete (chart) {},
  async onTournamentComplete (data) {},
};

const tournament = new Tournament(tournamentID, players, tournamentSettings, opts);
tournament.start();

Players should be object with at least the name, id, and serviceUrl properties specified.

On the specified end point there should be an http server, responding on the POST /bet, GET /, and GET /version routes.

quit a tournament

tournament.quit();

prepare your player

It's possible to code your player in whatever language you want. In the following example I will use JavaScript.

// server.js

"use strict";

const player = require("./player");

const http = require("http");
const express = require("express");
const bodyParser = require("body-parser");

const app = express();
const server = http.Server(app);

app.use(bodyParser.json());

app.get("/", function (req, res) {
  res.sendStatus(200);
});

app.get("/version", function (req, res) {
  res.status(200).send(player.VERSION);
});

app.post("/bet", function (req, res) {
  res.status(200).send(String(player.bet(req.body)));
});

const port = Number.parseInt(process.env["PORT"] || 1337);

server.listen(port, function () {
  console.log("Server listening on port", server.address().port);
});

And the player module

module.exports = {
  VERSION: "pokerstar v1",
  bet (gamestate) {
    // gamestate contains info about the state of the game;
    // currently we just fold every single hand.
    return 0;
  },
};

Keywords

FAQs

Package last updated on 02 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc