card_table_engine 0.1.0
card_table_engine: ^0.1.0 copied to clipboard
Pure Dart rules for card table games: deck and shoe, Texas Hold'em hand evaluator, side pots, a full Texas Hold'em table and a Blackjack table, plus bots. No Flutter needed.
card_table_engine #
Rules for card table games in pure Dart (no Flutter, no dependencies): the parts you need to build a poker or Blackjack game, tested and ready to put behind any UI or network layer.
Extracted from Poker Dice Dash, a Flutter game with Texas Hold'em and Blackjack over the local network.
What is inside #
| Cards | PlayingCard, Suit, Deck (shuffled, multi-deck shoes, stacked decks for tests), cards('As Kd 10h') |
| Hand evaluator | Best 5 of any number of cards, every category, wheel straight, kickers, ties (HandEvaluator.evaluate) |
| Side pots | PotCalculator.distribute: one pot per all-in level, folded money stays in, odd chips left of the button |
| Texas Hold'em table | TexasHoldemTable: button, blinds (heads-up rules too), four streets, raises that reopen the action, all-in run-outs, showdown with side pots, fold wins |
| Poker bot | PokerBotBrain: Monte Carlo equity, pot odds, five personalities, three difficulty levels |
| Blackjack hand | BlackjackHand: soft/hard totals, naturals, busts, splits |
| Blackjack table | BlackjackTable: bets, deal, insurance and dealer peek, hit / stand / double / split, dealer draw, payouts |
| Blackjack bot | BlackjackBotBrain: multi-deck basic strategy (or a casual player on easy) |
Everything is synchronous: you call an action, the table updates. Timers, animations, networking and saving are up to you.
Texas Hold'em #
import 'package:card_table_engine/card_table_engine.dart';
final table = TexasHoldemTable(
seats: [TexasSeat('ana', 1000), TexasSeat('luis', 1000), TexasSeat('carla', 1000)],
smallBlind: 10,
bigBlind: 20,
)..startHand();
while (table.outcome == null) {
final seat = table.currentSeat!;
// Ask your player (or a bot): table.legalMoves(seat.id), table.toCall(seat.id)
table.call(seat.id); // or fold(id), raise(id, by), allIn(id)
}
print(table.board); // revealed community cards
print(table.outcome!.winners); // main pot winners
print(table.outcome!.payouts); // chips won by each player, side pots included
Rules: no-limit, no minimum raise (raise(id, by) calls and adds by), a short call is an
all-in for less, post-flop the first player left of the button acts first. Between hands,
change TexasSeat.chips (rebuys) or sittingOut freely; startHand() moves the button and
skips seats without chips.
House rules can add money that belongs to nobody to the pot with addDeadMoney or
replace a player's hole cards with setHoleCards.
Blackjack #
final bj = BlackjackTable(seats: [BlackjackSeat('ana', 1000)])
..placeBet('ana', 100)
..deal();
if (bj.phase == BlackjackRoundPhase.insurance) bj.insure('ana', take: false);
while (bj.phase == BlackjackRoundPhase.playerTurn) {
bj.stand(bj.currentSeat!.id); // hit, double, split
}
print(bj.results['ana']); // BlackjackOutcome.win(100) ...
bj.newRound();
House rules are in BlackjackRules: decks in the shoe, when to reshuffle, blackjack payout
(3:2 by default), 5-card Charlie, dealer hits or stands on soft 17, insurance.
Bots #
final decision = PokerBotBrain(difficulty: BotDifficulty.hard).decide(
BotSituation(hole: seat.hole, board: table.board, toCall: table.toCall(seat.id),
pot: table.pot, chips: seat.chips, opponents: 2),
BotPersonality.shark,
);
See example/main.dart for a full hand played by bots.
License #
MIT. Poker Dice Dash itself is GPL-3.0; this package is MIT so any project can use it.