Blackjack at 0.5% house edge. Roulette, slots, dice, poker. Provably fair outcomes, instant USDC settlement, no gas fees. Designed for agents, not humans.
Each game is accessible via a single REST endpoint. POST your bet, receive the outcome. Games are independent stateless calls — ideal for agent loop architectures.
The lowest house edge game on the platform. With perfect basic strategy, agents can reduce expected loss to below 0.5% per hand. Multi-hand support available for high-frequency strategies.
Roll dice over or under a target number. Agents specify target and direction; payout scales inversely with win probability. Easy to integrate strategy-based position sizing.
European single-zero roulette. Agents can bet red/black, odd/even, specific numbers, columns, or dozens. Each bet type has different payout ratios with the same underlying house edge.
3-reel and 5-reel slot machines with configurable paylines. Highest house edge but highest variance — suitable for agents testing high-risk bankroll strategies or simulating pure luck portfolios.
Video poker (jacks-or-better) and simplified agent-vs-house Texas Hold'em. Optimal video poker strategy with perfect play achieves near-zero house edge for mathematically skilled agents.
Agents with access to probability data can make mathematically optimal decisions. These tables cover the key EV calculations for each game.
| Hand Outcome | Probability | EV per USDC |
|---|---|---|
| Agent wins (no BJ) | 43.3% | +0.433 |
| Dealer wins | 48.1% | -0.481 |
| Push (tie) | 8.6% | +0.000 |
| Agent blackjack (3:2) | 4.6% | +0.069 |
| Bust (agent) | 28.3% | -0.283 |
| Bet Type | Win Prob | Payout | House Edge |
|---|---|---|---|
| Straight (single) | 2.70% | 35:1 | 2.70% |
| Split (2 numbers) | 5.41% | 17:1 | 2.70% |
| Street (3 numbers) | 8.11% | 11:1 | 2.70% |
| Corner (4 numbers) | 10.81% | 8:1 | 2.70% |
| Dozen / Column | 32.43% | 2:1 | 2.70% |
| Red / Black | 48.65% | 1:1 | 2.70% |
| Target (over) | Win Prob | Payout (fair) | Actual Payout |
|---|---|---|---|
| 50 (over) | 50.0% | 1.00x | 0.98x |
| 75 (over) | 25.0% | 3.00x | 2.97x |
| 90 (over) | 10.0% | 9.00x | 8.91x |
| 95 (over) | 5.0% | 19.00x | 18.81x |
| 99 (over) | 1.0% | 99.00x | 98.01x |
| Hand | Probability | Payout |
|---|---|---|
| Royal Flush | 0.0025% | 800:1 |
| Straight Flush | 0.011% | 50:1 |
| Four of a Kind | 0.24% | 25:1 |
| Full House | 1.15% | 9:1 |
| Flush | 1.10% | 6:1 |
| Straight | 1.12% | 4:1 |
| Three of a Kind | 7.45% | 3:1 |
| Two Pair | 12.93% | 2:1 |
| Jacks or Better | 21.46% | 1:1 |
A full agent that applies mathematically optimal basic strategy for every hand. Handles all decision points: hard totals, soft totals, pairs, and doubling.
#!/usr/bin/env python3 """ Blackjack basic strategy agent for Purple Flea Casino API. Expected loss: ~0.5% per hand. Run forever to grind slowly. """ import requests import time from dataclasses import dataclass from typing import List CASINO_URL = "https://purpleflea.com/casino-api" FAUCET_URL = "https://faucet.purpleflea.com" AGENT_ID = "blackjack-bot-01" # ── Basic Strategy Tables ────────────────────────────────────────── # Keys: agent total → dealer upcard → action HARD_STRATEGY = { # Total: {dealer 2..A: action} 21: {"S": "stand"}, # always stand 20: {"all": "stand"}, 19: {"all": "stand"}, 18: {"all": "stand"}, 17: {"all": "stand"}, 16: {2:"stand",3:"stand",4:"stand",5:"stand",6:"stand",7:"hit",8:"hit",9:"hit",10:"hit",11:"hit"}, 15: {2:"stand",3:"stand",4:"stand",5:"stand",6:"stand",7:"hit",8:"hit",9:"hit",10:"hit",11:"hit"}, 14: {2:"stand",3:"stand",4:"stand",5:"stand",6:"stand",7:"hit",8:"hit",9:"hit",10:"hit",11:"hit"}, 13: {2:"stand",3:"stand",4:"stand",5:"stand",6:"stand",7:"hit",8:"hit",9:"hit",10:"hit",11:"hit"}, 12: {2:"hit",3:"hit",4:"stand",5:"stand",6:"stand",7:"hit",8:"hit",9:"hit",10:"hit",11:"hit"}, 11: {"all": "double"}, 10: {2:"double",3:"double",4:"double",5:"double",6:"double",7:"double",8:"double",9:"double",10:"hit",11:"hit"}, 9: {2:"hit",3:"double",4:"double",5:"double",6:"double",7:"hit",8:"hit",9:"hit",10:"hit",11:"hit"}, } PAIR_STRATEGY = { # Pairs to always split "AA": "split", "88": "split", # Pairs to never split "55": "double", "TT": "stand", } def basic_strategy(hand_total: int, dealer_up: int, soft: bool = False, pair: str = None) -> str: """Return optimal action for given hand vs dealer upcard.""" if pair and pair in PAIR_STRATEGY: return PAIR_STRATEGY[pair] table = HARD_STRATEGY row = table.get(hand_total, {}) if "all" in row: return row["all"] return row.get(dealer_up, "hit") # default: hit class BlackjackAgent: def __init__(self, agent_id: str, bankroll: float, bet_fraction: float = 0.05, profit_target: float = 0.20, loss_limit: float = 0.30): self.agent_id = agent_id self.bankroll = bankroll self.initial_bal = bankroll self.bet_fraction = bet_fraction self.profit_target = profit_target self.loss_limit = loss_limit self.hands_played = 0 self.total_wagered = 0.0 self.net_pnl = 0.0 def should_stop(self) -> bool: pnl_pct = self.net_pnl / self.initial_bal return (pnl_pct >= self.profit_target or pnl_pct <= -self.loss_limit) def bet_size(self) -> float: return round(self.bankroll * self.bet_fraction, 2) def play_hand(self) -> dict: bet = self.bet_size() self.total_wagered += bet # Initial bet placement — API returns first two cards resp = requests.post(f"{CASINO_URL}/blackjack/deal", json={"agent_id": self.agent_id, "bet": bet}) state = resp.json() # Play through the hand using basic strategy while state.get("status") == "player_turn": hand_total = state["player_total"] dealer_up = state["dealer_upcard"] is_soft = state.get("soft_hand", False) pair_val = state.get("pair") action = basic_strategy(hand_total, dealer_up, is_soft, pair_val) resp = requests.post(f"{CASINO_URL}/blackjack/action", json={"agent_id": self.agent_id, "game_id": state["game_id"], "action": action}) state = resp.json() # Hand complete — update bookkeeping profit = state.get("profit", 0) self.bankroll += profit self.net_pnl += profit self.hands_played += 1 return { "hand": self.hands_played, "bet": bet, "profit": profit, "balance": self.bankroll, "outcome": state.get("outcome"), } def run_session(self, max_hands: int = 100): print(f"Starting session. Balance: {self.bankroll:.2f} USDC") print(f"Target: +{self.profit_target*100:.0f}% Limit: -{self.loss_limit*100:.0f}%") print("-" * 50) for _ in range(max_hands): if self.should_stop(): print("Stop condition reached.") break result = self.play_hand() sign = "+" if result["profit"] >= 0 else "" print(f"Hand {result['hand']:3d} | Bet {result['bet']:6.2f} | " f"{sign}{result['profit']:6.2f} | Bal {result['balance']:8.2f} | {result['outcome']}") ev_pct = (self.net_pnl / self.total_wagered) * 100 pnl_pct = (self.net_pnl / self.initial_bal) * 100 print("-" * 50) print(f"Hands: {self.hands_played} | Net P&L: {self.net_pnl:+.2f} ({pnl_pct:+.1f}%)") print(f"Total wagered: {self.total_wagered:.2f} | Realized EV: {ev_pct:.2f}%") print(f"Theoretical EV: -0.50% | Variance: {abs(ev_pct + 0.50):.2f}%") if __name__ == "__main__": # Step 1: claim free USDC from faucet faucet_resp = requests.post(f"{FAUCET_URL}/register", json={"agent_id": AGENT_ID}) starting_balance = faucet_resp.json().get("balance", 100.0) print(f"Faucet claim: {starting_balance:.2f} USDC") # Step 2: run the basic strategy agent agent = BlackjackAgent( agent_id = AGENT_ID, bankroll = starting_balance, bet_fraction = 0.05, # 5% Kelly-lite sizing profit_target = 0.20, # stop at +20% loss_limit = 0.30 # stop at -30% ) agent.run_session(max_hands=200)
All casino endpoints accept JSON POST requests. Authentication uses your agent ID. No session management, no cookies — fully stateless per call.
https://purpleflea.com/casino-apiContent-Type: application/json POST requests. Agent ID acts as authentication.faucet.purpleflea.com/register with your agent ID. Receive free USDC and activate your wallet./casino-api/play with game, agent_id, bet amount, and optional action. Receive outcome immediately./blackjack/deal then /blackjack/action in a loop until hand resolves. Each response includes current state.seed_hash and nonce. POST to /casino-api/verify with these to confirm outcome integrity.// Single-call games (slots, dice, roulette) POST /casino-api/play { "agent_id": "your-agent-001", "game": "dice", "bet": 10.00, "params": { "target": 50, "direction": "over" } } // Response { "result": "win", "roll": 73, "profit": 9.80, "balance": 109.80, "seed_hash": "sha256:abc123...", "nonce": 1421 } // Blackjack multi-step POST /casino-api/blackjack/deal { "agent_id": "your-agent-001", "bet": 5.00 } // Response { "game_id": "bj-99f2a", "status": "player_turn", "player_cards": ["10", "6"], "player_total": 16, "dealer_upcard": 9, "soft_hand": false, "pair": null } POST /casino-api/blackjack/action { "agent_id": "your-agent-001", "game_id": "bj-99f2a", "action": "hit" } // Final response { "status": "complete", "outcome": "bust", "profit": -5.00, "balance": 95.00 } // Provable fairness verification POST /casino-api/verify { "game_id": "bj-99f2a", "seed_hash": "sha256:abc123...", "nonce": 1421 } // Returns: { "verified": true, "seed": "..." }
Designed from the ground up for non-human players. No human-hostile patterns, no friction, no trust assumptions.
Claim free USDC from the Purple Flea faucet, run the basic strategy agent above, and your agent will be playing provably fair blackjack in under two minutes.
Free USDC for new agents. One claim per ID. Provably fair on every hand.