statistics
Dice Timer
# Overview
Dice Timer is a game-night app for Settlers of Catan that records every dice roll, who rolled it, and when, then turns those rolls into statistics on a big screen. It's built to run on a TV next to the table, so everyone can watch the roll distribution build up while the game is played.
The point is statistics. Two dice make 7 the most likely total and 2 and 12 the least, and Catan is built on those odds. Dice Timer shows how each game, and each player, actually rolled compared with what the math says should happen.
# How it works
- Recording rolls: the current player taps a big button drawn as a pair of dice faces. Each button also lists the dice combinations that make its number. A roll can be tagged with whether a knight was played, and whether someone "called it" (predicted the number), along with who called it. Rolls can be edited or deleted afterward.
- Game flow: start a game, set the point goal, and set the turn order. The current turn comes from the latest roll and highlights that player. A live game clock runs in the header.
- Turn timer: a countdown timer with play, pause, and reset. It plays a chime and shows an overlay when time runs out.
- Standings: a points table tracks each player's settlements, cities, and victory-point cards, plus Longest Road and Largest Army (+2 points each). Totals update as you go.
- Winners and history: record the winner (including whether the winner had played a knight), browse past games with their rolls, and see recent winners.
- The bias stat: a light-hearted per-game "Bias" toggle under the banner "The gavel of no bias." If someone gets accused of bias at the table, it goes on the record, and that game gets a badge in Past Games.
# The statistics
- Roll distribution chart for the current game, all time, or any past game, shown as bars or as a line.
- Compare to all time (line mode): overlays the selected game against the all-time distribution as percentages, plus a dotted expected line from the two-dice probabilities,
(6 − |7 − n|) / 36for each total n from 2 to 12. Hovering a point shows the percentage and the raw roll count. - Per-player roll breakdown: how often each player rolled each number.
- Roll scoreboard and a newest-first roll history for the current game, with an expanded view.
# Tech stack
- Server: Node.js with Express. The only dependency is Express.
- Data: JSON files for players, games, rolls, and winners, written by the server.
- Front end: plain HTML, CSS, and JavaScript in a static folder. Charts use Chart.js, and the dice faces are drawn as inline SVG.
- Layout: a compact dashboard designed for a TV display.
# Interface and quality details
- Server-side validation: every roll must be a whole number from 2 to 12, the point goal from 1 to 99, and the yes/no fields must be real true or false values.
- Safe display: player names are escaped before they're shown on the page.
- Remembered preferences: chart settings, like the all-time comparison, are saved in the browser.
- Built for a room: big touch targets, a dashboard that fits on a TV, and a sound cue for the timer.
# What's next: a probability table
Yes, the chances can be calculated exactly. The next feature is a table that shows, for every total from 2 to 12:
- The chance of rolling it: two dice have 36 equally likely outcomes, and n can be made in
6 − |7 − n|of them, so p(n) = (6 − |7 − n|) / 36. For example, 7 is 6/36 ≈ 16.7%, 6 and 8 are 5/36 ≈ 13.9%, and 2 and 12 are 1/36 ≈ 2.8%. - Expected vs actual counts: after N rolls, a number is expected about N × p(n) times. Showing that next to the real count makes "hot" and "cold" numbers easy to see.
- The chance it shows up soon: the chance a number rolls at least once in the next k rolls is 1 − (1 − p)^k. For example, a 6 or an 8 has about a 52% chance of showing up within the next 5 rolls.
One honest note goes with the table: every roll is independent. A number that hasn't come up in a while isn't "due." Its chance on the next roll is still exactly p(n).