Files
OrbitTv/docs/bumblehive-native.md
pauljdandClaude Opus 5.5 9ea20b5a2a BumbleHive: Hard mode gets its own High Scores table
Paul chose a separate list. Hard runs are saved only under their own record
(HiveHard) in the profile's Arcade file; Normal's stay under Hive exactly as
before, so the "· Hard" marker is gone. High Scores shows a Normal / HARD
switch on BumbleHive's row (Left/Right), and the Top 10 says which table it
is. Clear high scores for BumbleHive clears both. Kids filtering and
per-profile storage are unchanged.

5 new tests (tables never mix, Normal's data untouched, files from before).
853 run, 24 skipped, 0 failed; Node 28 passed; lint unchanged; release APK
unchanged in size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:45:28 +00:00

11 KiB
Raw Permalink Blame History

BumbleHive, native (8 November 2026)

Branch arcade-bumblehive-native (from arcade-orbi-raiders). Paul decided to rebuild BumbleHive in Kotlin, drawn on a Compose Canvas like the other Arcade games, replacing the WebView, and playing exactly as android/app/src/main/assets/orbithive/game.js did. He also asked for a Hard mode. Verification: docs/VERIFICATION-bumblehive-native.md.

What changed

  • The Arcade's BumbleHive card now opens the native game (arcade/hive/BumbleHiveScreen.kt). The WebView game (OrbitHiveScreen, its JavaScript bridge and hiveConfig) is gone, and so is ArcadeFlags.hiveProfileSaves: saves are always per profile now. No WebView is made by BumbleHive except once, briefly, to carry the old save over (below).
  • assets/orbithive stays in the APK for now: the one-time import must load the same page URL (the same origin) to find the old localStorage, the Barlow font is read from it, and keeping it makes a rollback to the WebView build safe.
  • Shared Arcade parts: the pause menu (Resume, Restart Level, How to Play, Sound, Exit to Arcade), How to Play, a result card in the Arcade's style, Reduce motion, the Quiet / Wind Down sound ceiling, per-profile saves in ArcadeStore, High Scores (each level played is a run; Hard has its own table, below).
File What it is
arcade/hive/HiveRules.kt The constants, the six colours, rng(), cellsIn, the 12 shapes, levelInfo, buildLevel with clumping and the hanging-flower prune, neighbours, cluster, what hangs from the ceiling.
arcade/hive/HiveSim.kt The game with no screen: shooting with wall bounces, landing and snapping, bursts and falls, swaps, Honeybombs, the panic timer, ceiling drops and breach, scoring, stars, win and lose, weighted aim, menus and focus, level pages, help and settings, Bumble's Daily Bonus, the Household question.
arcade/hive/HiveArt.kt game.js's render() on android.graphics: both skins, the hive, flowers, bee, launcher and guide line, effects, HUD, menus, wheel.
arcade/hive/HiveTones.kt game.js's beeps, rendered once to short WAVs and played through ArcadeAudio.
arcade/hive/HiveSave.kt Per-mode progress, the profile's BumbleHive save, the old save's format, Continue from the Household save.
arcade/hive/HiveLegacy.kt The one-time import of the WebView save.

Parity approach

The rules are ported line for line, on doubles as in JavaScript. Two details matter for exactness:

  • rng(seed): JavaScript's (s * 1664525 + 1013904223) >>> 0 never exceeds 2^53, so 64-bit longs masked to 32 bits give the same numbers. Math.round, Math.floor, % and the shape tests are the same operations in the same order.
  • Shots use StrictMath.sin / cos (fdlibm, as V8 uses), so a shot's path is the same to the last bit.

src/test/js/hive-parity.js runs the real game.js under Node (the same headless sandbox as Stage C's tests, with a seeded Math.random) and records src/test/resources/bumblehive/parity.json:

  • all 200 levels: the grid cell by cell, colours, rows, shape and panic;
  • 15 levels of scripted shots (an angle and a flower each, every fifth a Honeybomb, flown 16 ms at a time): after every landing, the grid, score, ceiling, drops, panic and screen. 469 shots, including a win and five swarms;
  • 26 shot paths into levels 5 and 40 at 13 angles: position and velocity every frame, and where it stuck.

BumbleHiveParityTest replays the same inputs through the Kotlin rules. Result: 200/200 levels identical; all 469 landings identical; all 26 paths identical frame by frame (largest difference 0.0). hive-parity.test.js checks the committed record still matches game.js, so a change on either side shows.

The game runs its rules on a fixed 60 Hz step (game.js used the screen's frame time, capped at 50 ms; at 60 frames a second they're the same steps).

The save carry-over

On the downstairs TV the old game's progress (48 unlocked, 96 stars) is in the WebView's localStorage under orbithive-save-v1, for the page file:///android_asset/orbithive/index.html (the old screen's loadUrl, with JavaScript, DOM storage and file access on, and the default WebView data folder).

  1. The first time native BumbleHive opens, if filesDir/arcade/household-bumblehive-legacy.json doesn't exist, it puts a WebView in the composition, 1 dp, see-through and never focused, with the old settings and the default data folder, and loads that exact URL. On the way in, game.js and hive-save.js are answered with empty scripts, so none of the old game runs (if a WebView ever ignored that, loading game.js with no bridge only reads: tested under Node).
  2. When the page has loaded, HiveLegacy.READ_SCRIPT runs through evaluateJavascript. It only calls getItem, key and length, and returns orbithive-save-v1's text exactly, plus any orbithive-save-v1:<profile> copies the old profile-saves flag could have made (it was never switched on, so none are expected; they're recorded, not used).
  3. The answer is written once (writeSafely) as the read-only snapshot, and the WebView is destroyed. The snapshot is never rewritten, even if asked.
  4. Nothing ever writes, clears or deletes the localStorage key or the WebView data folder. No setItem, removeItem, clear, clearCache, WebStorage.deleteAllData or data-folder change anywhere.
  5. Any failure (no WebView on the box, the page not loading, storage unreadable, no answer in 10 s) writes nothing, so it's tried again next time BumbleHive opens. The game plays meanwhile; the Household question just isn't there yet.
{ "schema": 1, "readOnly": true, "source": "localStorage/orbithive-save-v1",
  "origin": "file:///android_asset/orbithive/index.html", "copiedAt": 1762632000000,
  "present": true, "value": "{\"unlocked\":48,\"stars\":{...},...}", "profiles": {} }

The Household save

Any profile whose Household question is unanswered, when the snapshot has progress, sees game.js's own screen first: "Carry on from this TV's hive?" with Continue from it or Start fresh.

  • Continue: a copy becomes the profile's Normal progress (their own, in their Arcade file); the snapshot is untouched, so every other profile can do the same. A profile that hasn't played takes the old save's Honeybombs, daily spin and choices too, as game.js's copy did.
  • The question waits until it's answered: if the import finished after the game opened, or someone cleared a level first, it comes up the next time the title would. Then Continue keeps the best of both (furthest level, each level's best stars and score, the larger number of Honeybombs) so nothing played meanwhile is lost.
  • Start fresh: level 1, and it isn't asked again. Back leaves the game, as before.
  • Hard is never offered the Household save: it starts at level 1.

Where a profile's BumbleHive lives

In the profile's Arcade file (filesDir/arcade/<profile>.json), game Hive:

  • level.normal, level.hard: each mode's {unlocked, stars, best, page}. Reset level progress clears both.
  • kept (new, additive; older builds ignore it): bombs, lastSpin, mode, household. A level reset keeps these, as game.js kept Honeybombs through a reset.
  • settings: sound, guide, classicSkin (they also show under the game in Arcade Settings, and Reset settings resets them).

Reset level progress is now allowed for BumbleHive (it was blocked while its save was one box-wide save).

Hard mode

Chosen on BumbleHive's title (MODE: NORMAL / MODE: HARD, right of Play); remembered per profile.

Normal (game.js) Hard
Ceiling (panic) timer 20 s at level 1 down to 7 s from level 121 × 0.6: 12 s at level 1, never under 5 s (5 s from level 109)
Swaps 5 3
Colours 3, one more every 15 levels (6 from level 46) 3, one more every 10 levels (6 from level 31)
Layouts the 200 levels the same shapes, rows and random draws; with more colours the flowers are coloured differently
Save Normal's unlocks, stars, bests, page its own, starting at level 1; never reads or writes Normal's

Honeybombs, the daily spin and the skin, guide and sound choices belong to the profile, whichever mode.

Hard's own High Scores (Paul, 8 November 2026)

  • Hard runs are saved only into a separate table, record id HiveHard (HIVE_HARD_SCORES) in the profile's Arcade file; Normal runs stay under Hive, exactly as before. The two never mix, and no "· Hard" marker is needed.
  • High Scores: BumbleHive's row shows a ◀ Normal ▶ / ◀ HARD ▶ switch (Hard in pink); ◀▶ on that row changes table, and the Top 10 is headed "BUMBLEHIVE HARD · TOP 10". The footer says so when BumbleHive is visible.
  • HiveHard isn't a game: no card, no settings, nothing extra for Kids filtering (it follows BumbleHive's visibility).
  • Reset › Clear high scores for BumbleHive clears both tables; nothing else touches HiveHard.
  • Existing files simply have no HiveHard yet: Normal's data is read and written unchanged.

Known gaps

  • Nothing has been seen running. No emulator or TV was used: the drawing, the Barlow text and the glyphs it borrows from the system (★ ☆ ⇅ ✸ ▼ 🔒), focus, the result card, the tones by ear, and frame times on the 2 GB box are unchecked.
  • The import has never run on a real WebView. The same URL, settings and data folder should give the same origin and storage; that is reasoned from the old code, not observed. If it doesn't find the save it records "nothing there" (present false) and the Household question never appears. That would need a fix and a fresh snapshot; the old save itself would still be untouched.
  • The shared pause menu replaces BumbleHive's own: its "Levels" and "Menu" entries are gone (Exit to Arcade, or the result card's Levels). How to Play from pause is the Arcade's card; the full help page with skin, guide and sound stays on the title.
  • Win and lose show the Arcade-style card (same choices: Next Level / Replay / Levels, Try Again / Levels / Menu) instead of game.js's canvas overlay.
  • Touch, mouse and the Gamepad API aren't ported (a TV app). Pads work through their key events: A or R2 fires, X swaps, Y arms a Honeybomb, B is Back, Start pauses.
  • Small drawing differences: the flowers' centre gradient is a plain radial one (the focal kind needs Android 12); the Orbit planet is drawn in its outer colour, which is what game.js actually showed (its gradient was in the wrong units); the Classic sun's rays now stand still under Reduce motion.
  • The tones are simple waveforms, not Web Audio's band-limited ones. ArcadeAudio now allows 4 sounds at once (was 3), for every game.
  • Daily Bonus days turn over at midnight UTC, as game.js's toISOString() did (01:00 in summer time).
  • The rules allocate nothing per frame (measured); the drawing is written not to (paths, gradients and labels made once or when they change) but couldn't be measured off the box. On the JVM a shot's four sin/cos calls allocate a few bytes (StrictMath's Java port); on Android StrictMath is native.
  • assets/orbithive (172 KB) stays until the import has run on every TV; then the font can move to res/font and the folder can go.