Inspiration

"The house always wins" is the one rule everyone knows about casinos. House Edge gave us slot-machine logs and asked us to predict the odds of each machine's next payout (0×, 1×, 2×, 5× or 20×). Slots are built to feel random, so the real question was whether there was a hidden pattern underneath, and whether we could recover it well enough to get the edge back. That's where the name comes from.

What it does

For every query, our model takes a machine's past payouts and returns five calibrated probabilities for its next spin. It covers all four conditions in the challenge:

  • Stable machines
  • Short-history machines with only a few observed ticks
  • Drift, where a machine's behaviour changes during the episode
  • Shared change, where every machine in an episode shifts together

On validation it scores 59.08 / 60 technical points. The starter baselines score about 30 / 60. Our normalized error ratio is R ≈ 0.016, so our error is about 1.6% of the reference model's, roughly 60 times lower.

How we built it

We treated the problem as reverse-engineering a generative process rather than fitting a black box.

  1. Finding the structure. Simple counting showed almost nothing: any single earlier payout was close to useless for predicting the next one. The signal turned out to be the parity (XOR) of a machine's own wins at a pair of lags, specifically (1,3), (2,5) or (4,7), with a machine-specific orientation. XOR is invisible to methods that look at one feature at a time, which is why the baselines missed it.
  2. v1: Bayesian lag averaging. Our first entry averaged over candidate lag sets and orientations with Bayesian weights, using exponentially decayed counts (half-life 12 ticks), type-specific priors (steady, balanced, jackpot), and a two-mode mixture for payout size.
  3. v2: an exact generative model. We rewrote it as a softmax over the five payouts with logits [0, A, A+g2+B, A+g5+B, A+g20+B]:
    • A, the win logit, combines the lag-pair parity, the observable signal, the number of other machines that won 3 ticks earlier, and a per-machine offset.
    • B = ±0.65 shifts payout size depending on whether the payout at the pair's first lag was ≥ 2.
    • We fit everything with hard-EM maximum likelihood.
    • We detect drift episodes, abrupt or ramped, where the win orientation flips, and flip the pre-change ticks to match.
  4. v3–v5: hidden states and short histories. We added a two-state episode-level HMM (±0.30 on A, switching about 3% per tick) filtered across all machines in an episode, which handles shared change. For short histories we use older sampled ticks and marginalise over the lag bits we can't see. The final prediction is the posterior average over all latent choices.

Engineering:

  • Standard library only: pure Python, no numpy and no dependencies.
  • Deterministic: no seeds, no network.
  • Fast: prediction takes about 80 s on one core with under 200 MB RAM; training takes about 3 minutes with multiprocessing.
  • Verified: every version was re-run from a clean folder and checked to produce byte-identical output.
  • Round-two ready: we built a one-command pipeline (make_round_entry.py) that refits on new data, validates, packages and verifies reproduction, so the overnight round wouldn't depend on manual steps.

Challenges we ran into

  • The signal hides from simple statistics. Because the win rule is an XOR, single-lag correlations look like noise. Our first instinct, more features and more smoothing, went nowhere until we started testing pairs of lags.
  • Latent variables everywhere. Each machine has a hidden lag set, orientations, an offset, and an episode regime. Getting EM to converge reliably, without the latent assignments collapsing, took several rewrites.
  • Short history is still the hardest condition. Its error ratio (0.034) is about twice that of the other three. With only a few ticks there isn't much data to identify which lag pair a machine uses, so we marginalise over it instead of guessing.
  • Not fooling ourselves. With validation targets public, it would have been easy to overfit. We fit on train, used validation to choose settings, and read only the fixed payout-shape constants from validation targets.
  • Reproducibility under constraints. The organizer rerun has a 30-minute budget, 2 CPUs and no network, so the model had to be fast, deterministic and dependency-free.

Accomplishments that we're proud of

  • About 59.1 / 60 validation points, against a baseline near 30.
  • A model that explains the data: every parameter has a meaning (lag pair, orientation, size state, regime). It is not a pile of tuned weights.
  • Exact, byte-identical reproduction for every version we shipped (v1–v5).
  • Zero dependencies: the whole thing is about 1,100 lines of standard-library Python.

What we learned

  • Look for the generating process before reaching for a bigger model. A small, correct model beat everything a more generic approach would have given us.
  • Interactions can be invisible to marginal statistics. XOR is the textbook example, and we ran into it for real.
  • Bayesian averaging over latent structure is more robust than picking one answer, especially with little data.
  • Automate the boring parts early. The packaging and reproduction pipeline saved us during the time-boxed second round.

What's next for im edging the house

  • Close the short-history gap with better priors on lag-set and orientation choice when only a few ticks are observed.
  • Online updating: turn the EM fit into a streaming filter that updates tick by tick instead of refitting.
  • Generalize the discovery step: automate the search for hidden parity and interaction structure so it carries over to other "random-looking" sequential data.
  • An interactive demo that shows the inferred hidden state of each machine as it plays, so you can watch the house's edge disappear.

Built With

Share this project:

Updates

Submission history