• Stars
    star
    104
  • Rank 323,970 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Texas hold'em poker engine

@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;
  },
};

More Repositories

1

promise

A spec-complaint `Promise` implementation optimised for readability.
JavaScript
8
star
2

webpack-101

A progressive webpack configuration demo/tutorial.
JavaScript
7
star
3

poker-rank

Compute the texas hold'em best hand
JavaScript
6
star
4

xpath-analyzer

Google Chrome extension that allows to evaluate xPath expressions against the XML of the current browser tab.
JavaScript
5
star
5

dom-events

A JavaScript event handler micro library.
JavaScript
4
star
6

poker-deck

Basic french deck of poker cards.
JavaScript
3
star
7

poker-has

Evaluate poker hold'em hands
JavaScript
2
star
8

risk-neighborhood

Risk world information.
JavaScript
2
star
9

starter-express

A ready to use express web app for fast prototyping, or debugging.
JavaScript
2
star
10

starter-ssr-react

A ready to use express/reactjs web app for quickly scaffold new projects, or debugging.
JavaScript
2
star
11

use-forward-ref

React hook that permits to use the forwarded ref, or a fallback when it's not provided.
JavaScript
2
star
12

brunoscopelliti.github.io

My website (2021 edition). See https://brunoscopelliti.com
HTML
1
star
13

risk-target-cards

Risk target cards
JavaScript
1
star
14

buffer-emoji-picker

An emoji picker addons for Buffer
HTML
1
star
15

risk-dice

Computes wins/loses of a risk dice match
JavaScript
1
star
16

risk-continents

Determines which continents a player controls.
JavaScript
1
star
17

karma-travis-saucelabs-integration

CI integrating karma/travis/saucelabs
JavaScript
1
star
18

risk-reinforces

Computes the number of reinforces a player can have
JavaScript
1
star
19

poker-combinations

Produce all the 21 possible combinations of texas hold'em cards
JavaScript
1
star
20

risk-cards

Risk cards
JavaScript
1
star
21

risk-card-combination

Determine the number of reinforcement armies for a given cards combination
JavaScript
1
star