Skip to content
Back to Projects

// VERSUS · CRAPS, FROM ONE FILE TO A CASINO FLOOR

v1 vs. today

On 15 July 2025 the craps table was one 981-line HTML file that ran end to end on the first try. Today it is a table you walk up to in The Gilded Cube, a voxel casino. Both are playable below, and every claim on this page is a line you can go read in the source.

The v1 craps table: flat coloured boxes for Pass Line, the place bets, Field, Come and the proposition bets.

// FIRST WORKING BUILD

Complete Craps Table

15 Jul 2025 · gilfila/craps @ 03a6881 · 981 lines

One file, one class, nineteen betting boxes on green felt — two of which are wired to nothing. It knows the come-out and point phases, pays the hard ways correctly, and loses your money on a push. Preserved byte for byte.

Play v1
The craps table in The Gilded Cube: a voxel table seen from above with chips on the felt, two red dice mid-throw and three block-built guests watching.

// RUNNING NOW

The Gilded Cube

December 2026 · public/games/voxel-casino · 9,385 lines across 28 files

A voxel casino you cross on foot, with the craps table on the east side of the hall. Come and Don’t Come that slide to their numbers, free odds up to three times the bet, bets you can take down, dice you throw down the felt, and one bankroll that follows you to the slots, blackjack and roulette. Play money only.

Walk in and find the table
Dimensions
v1 is a page of coloured boxes. Today the table stands in a hall you walk across.
V1
2
NOW
3
Lines of code
The whole casino, not counting three.js. The craps table’s own share is 1,007: 245 of rules and 762 of table.
V1
981
NOW
9,385
Files
Twenty-six scripts, a stylesheet and a 31-line index.html. Every model, texture and sound is made in code.
V1
1
NOW
28
Bet types
v1 paints Come and Don’t Come on the felt and never resolves them. Today: seventeen on the felt, plus free odds behind each of the four line bets.
V1
19 boxes, 17 live
NOW
21
Automated tests
94 Node tests over the rules, the bankroll and the hall, then 754 browser checks that play every game with the money counted to the cent.
V1
0
NOW
94 + 754
Survives a reload
v1 rebuilds itself at 5,000 chips every time the page loads.
V1
nothing
NOW
bankroll, trophies, chips on the felt
Pass / Don’t PassV1NOW

Both resolve the come-out and point phases correctly.

Come / Don’t ComeV1NOW

Both boxes are painted on the v1 felt and both accept chips. Neither has a line of code behind it. In the casino the stack slides to its number and each one resolves on its own.

Free oddsV1NOW

Up to three times the bet behind the line, and behind travelled come bets, paid at true odds — the only bet on the table with no house edge.

Place bets 4–10V1NOW

v1 pays them from decimal approximations (1.167 for 7:6) and marks the point number as OFF, which is exactly backwards.

Hard waysV1NOW

Both lose on the easy way or any 7. v1 got this one right.

One-roll propsV1NOW

v1 has Any 7, Any Craps, Aces and Boxcars. The casino kept the first two and left out the 30:1 pair — a deliberate trim, not an upgrade.

Push returns your stakeV1NOW

v1 detects the Don’t Pass push on 12 and then swallows the chips. See the receipt below.

Take bets downV1NOW

v1 offers Clear All or nothing. In the casino any bet the rules let you pick up comes back off the felt — everything but a Pass Line bet with the point on and a Come bet on its number.

A closed tab costs you nothingV1NOW

A throw is saved the moment it is decided, and chips left on the felt are saved with the table. v1 forgets everything, bankroll included.

Statistics and trophiesV1NOW

Stats, 36 trophies, VIP tiers and daily missions, all in one saved profile.

One bankroll across the casinoV1NOW

v1 hardcodes 5,000 chips at construction. In the casino one bankroll walks with you between the slot machines, blackjack, roulette and the craps table.

Errors without alert()V1NOW

v1 blocks the page with a native alert when you overbet. The casino has no alert in it.

Four places where the difference is not a matter of taste. Left is v1 as shipped, right is the same decision in the casino’s craps rules.

The push that eats your money

A real bug, live in v1 today

V1

// resolveBet() — the push is detected correctly:
case 'dontpass':
  } else if (total === 12) {
    result = { remove: true, payout: betAmount }; // Push
  }

// resolveRoll() — but payout is only ever banked on a win:
if (result.win) {
    winnings += result.payout;
} else if (result.lose) {
    message += ` | ${betType.toUpperCase()}: LOSE`;
}

NOW

const win = (key, label, stake, profit, remove) =>
  ({ key, label, kind: 'win', stake, profit,
     payout: remove ? stake + profit : profit, remove });
const lose = (key, label, stake) =>
  ({ key, label, kind: 'lose', stake, profit: -stake,
     payout: 0, remove: true });
const push = (key, label, stake) =>
  ({ key, label, kind: 'push', stake, profit: 0,
     payout: stake, remove: true });

// roll(): whatever happened, the chips come back one way
const cashReturned =
  results.reduce((a, r) => a + r.payout, 0);

The stake is deducted the moment you place the bet. A push has win false and lose false, so v1 deletes the bet without ever crediting the payout back — a Don’t Pass push on 12 quietly costs you the full wager. In the casino every outcome, push included, is one result shape that always names its payout, and the roll hands back the sum.

Two bets that look finished and aren’t

Takes your chips, never pays out

V1

<!-- The felt: both boxes are drawn and both are clickable -->
<div class="come" data-bet="come"
     onclick="placeBet('come')">
<div class="dont-come" data-bet="dontcome"
     onclick="placeBet('dontcome')">

// resolveBet(): there is no case 'come' and no
// case 'dontcome'. Every roll falls through to:
let result = { win: false, lose: false,
               remove: false, payout: 0 };

NOW

if (take('come') > 0) {
  const s = B.come;
  if (total === 7 || total === 11)
    apply(win('come', 'Come', s, s, true));
  else if (total === 2 || total === 3 || total === 12)
    apply(lose('come', 'Come', s));
  else {                                  // travels
    delete B.come;
    (this.comePoints[total] ??= { amount: 0, odds: 0 })
      .amount += s;
    moves.push({ key: 'come', to: 'come' + total, amount: s });
  }
}

Clicking Come in v1 deducts the chips and puts a stack on the felt. It then sits there through every roll — never winning, never losing, unrecoverable except by clearing the whole table. The one field the constructor set aside for it, comePoint, is written once and never read. This is the difference the time actually bought: not that the casino has come bets, but that it does not ship a button with nothing behind it.

Payouts by approximation

Correct at some stakes, wrong at others

V1

case 'place6': case 'place8':
  result = { payout: Math.floor(betAmount * 1.167) + betAmount };

case 'place5': case 'place9':
  result = { payout: Math.floor(betAmount * 1.4) + betAmount };

case 'place4': case 'place10':
  result = { payout: Math.floor(betAmount * 1.8) + betAmount };

NOW

const placeProfit = (n, amount) =>
  n === 4 || n === 10 ? Math.floor(amount * 9 / 5)
  : n === 5 || n === 9 ? Math.floor(amount * 7 / 5)
  : Math.floor(amount * 7 / 6);

7:6 is not 1.167. A $503 place-6 pays $587 in v1 where the table owes $586, and the drift grows with the stake. 7:5 really is 1.4, but not in floating point: 45 × 1.4 comes out a hair under 63, so the floor pays $62. The ratios are integers in the casino because that is what they actually are.

Parsing a bet name by slicing the string

Works by luck

V1

case 'place4': case 'place10':
  if (total === parseInt(betType.slice(-1)) ||
      total === parseInt(betType.slice(-2))) {

NOW

for (const n of POINTS) {
  const key = 'place' + n, s = take(key);
  if (!(s > 0)) continue;
  if (total === n)
    apply(win(key, 'Place ' + n, s, placeProfit(n, s), false));
  else if (total === 7)
    apply(lose(key, 'Place ' + n, s));
}

For place10 the last character is "0" and the last two are "10", so the second half of the condition rescues the first. For place4 the last two characters parse to NaN, which happens to be harmless. Both branches are accidents. The casino’s place bets go the other way round: loop over the six numbers and build the name from each, so there is nothing to parse.

Two things got worse, and pretending otherwise would make the rest of this page worthless. The casino left out Aces and Boxcars, the two 30:1 one-roll props v1 had. And v1 is 981 lines you can read on a train and open in any browser — the casino is more than nine thousand across 28 files, plus a 3D library, and it needs WebGL 2. That is the real price of come bets, odds, a save that survives a closed tab and a room to walk around. Bigger is not the achievement. Being right about the money is.

There was a step in between: a 2D rebuild that held the “today” side of this page until December 2026. It is still here, with a test page you can run in the browser, and the casino’s craps rules are pinned to its payouts.