How bysggit/gobonsaisetup works
Purpose and Entry Points
This repository reverse-engineers the native GoBonsai executable and reimplements its simulation as a browser application with executable-parity goals. The original binary and extracted/decompiled evidence are retained at GoBonsai.exe, decompiled/full.c, and installed game/GoBonsai.exe. The web runtime starts at gobonsai-web/src/main.ts, mounts gobonsai-web/src/App.vue, and presents simulation/UI components including gobonsai-web/src/components/BonsaiViewer.vue.
UI-to-Engine Control Boundary
Vue components own browser presentation and user interaction; the engine is isolated beneath gobonsai-web/src/engine. gobonsai-web/src/components/Dashboard.vue likely exposes controls/state, while gobonsai-web/src/engine/BonsaiController.ts coordinates tree lifecycle and interaction. gobonsai-web/src/engine/GrowthController.ts drives growth updates. This separation keeps rendering/UI concerns outside native-behavior emulation.
Canonical Tree Model
Tree state is represented as an object graph rooted in gobonsai-web/src/engine/TreeRoot.ts, composed of sections and leaves in gobonsai-web/src/engine/TreeSection.ts and gobonsai-web/src/engine/TreeLeaf.ts. Shared shapes and state contracts reside in gobonsai-web/src/engine/TreeInterfaces.ts and gobonsai-web/src/engine/TreeState.ts. Runtime section behavior/type dispatch is modeled by gobonsai-web/src/engine/SectionRuntimeType.ts.
Frame Growth Pipeline
The principal simulation flow is organized in gobonsai-web/src/engine/growth/GrowthFramePipeline.ts: frame state enters, strict/parity branching is selected, and mutations are applied to the tree/world. The original growth-tick translation is gobonsai-web/src/engine/growth/sub40DC90GrowthTick.ts; a native-aligned route is maintained in gobonsai-web/src/engine/growth/strictExeSimPath.ts. Supporting stages include light tracing (gobonsai-web/src/engine/growth/lightTracingSub40E460.ts), leaf metabolism (gobonsai-web/src/engine/growth/leafMetabolismSub416510.ts), and per-frame physics (gobonsai-web/src/engine/growth/perFramePhysicsSub4143E0.ts).
Growth, Branching, and Structural Mutation
Branching decisions dispatch through gobonsai-web/src/engine/growth/branchingDispatcherSub417F40.ts; twig update and elongation are handled by gobonsai-web/src/engine/growth/twigUpdateSub417C90.ts and gobonsai-web/src/engine/growth/twigLengthGrowthSub418BD0.ts. Structural removal/detachment is a distinct mutation boundary in gobonsai-web/src/engine/growth/detachPipelineSub40EEE0.ts. Higher-level domain services—gobonsai-web/src/engine/GrowthService.ts, gobonsai-web/src/engine/BranchingService.ts, and gobonsai-web/src/engine/MetabolismService.ts—provide named orchestration around this lower-level recovered behavior.
World, Geometry, and Rendering Data
World-level allocation, lookup, and spatial behavior are separated under gobonsai-web/src/engine/world/, notably gobonsai-web/src/engine/world/WorldGrowthState.ts, gobonsai-web/src/engine/world/WorldObjectSub401830.ts, and gobonsai-web/src/engine/world/SectionSpatialQueriesSub40x.ts. Geometry and transform computation are isolated in gobonsai-web/src/engine/GeometryService.ts, gobonsai-web/src/engine/growth/transformChainSub450BD0.ts, and gobonsai-web/src/engine/math/TransformService.ts. Render submission parity has a dedicated specification at GUIDES/spec_render_submit_sub_44F2A0.md.
Parity Evidence and Toolchain
GUIDES/ is the operational specification layer linking recovered native functions to TypeScript implementations, including GUIDES/decomp_master_manifest.csv, GUIDES/sub_to_ts_coverage_map.md, and GUIDES/full_technical_parity_execution_plan_v2.md. IDA artifacts and automation support further native analysis under installed game/ and tools/ida/gobonsai_one_run_trace.py. The material runtime is a Vite/TypeScript/Vue browser app (gobonsai-web/package.json, gobonsai-web/vite.config.ts); no server-side infrastructure or external service integration is evident.
Main entry points: GrowthFramePipeline.ts Growth frame pipeline · TreeRoot.ts Tree object graph · App.vue App shell · BonsaiController.ts Bonsai controller
Components 22
Native Evidence
Retained executable, decompilation, and parity specifications.
- Native executables
GoBonsai.exe - Decompiled native evidence
decompiled/full.c - Parity guides · Maps recovered native functions to TypeScript behavior.
GUIDES/sub_to_ts_coverage_map.md - IDA trace automation
tools/ida/gobonsai_one_run_trace.py
Browser UI
Vite/Vue application entry and presentation layer.
- Browser entry
gobonsai-web/src/main.ts - App shell
gobonsai-web/src/App.vue - Dashboard controls · Exposes simulation controls and state.
gobonsai-web/src/components/Dashboard.vue - Bonsai viewer · Presents the simulated tree.
gobonsai-web/src/components/BonsaiViewer.vue
Simulation Engine
Controller, model, world, and recovered growth behavior.
- Bonsai controller · Coordinates tree lifecycle and interaction.
gobonsai-web/src/engine/BonsaiController.ts - Growth controller · Drives frame growth updates.
gobonsai-web/src/engine/GrowthController.ts - Tree object graph · Root, sections, and leaves form canonical tree state.
gobonsai-web/src/engine/TreeRoot.ts - Tree contracts and state · Shared state, shapes, and runtime section dispatch.
gobonsai-web/src/engine/TreeInterfaces.ts - World growth state · Holds world-level growth allocation and state.
gobonsai-web/src/engine/world/WorldGrowthState.ts - Section spatial queries
gobonsai-web/src/engine/world/SectionSpatialQueriesSub40x.ts - Geometry and transforms · Computes geometry and transform chains.
gobonsai-web/src/engine/GeometryService.ts - Domain growth services · Named growth, branching, and metabolism orchestration.
gobonsai-web/src/engine/GrowthService.ts
Frame Growth Pipeline
Native-aligned per-frame simulation stages.
- Growth frame pipeline · Selects parity path and applies frame mutations.
gobonsai-web/src/engine/growth/GrowthFramePipeline.ts - Strict EXE simulation path · Native-aligned growth execution route.
gobonsai-web/src/engine/growth/strictExeSimPath.ts - Recovered growth tick
gobonsai-web/src/engine/growth/sub40DC90GrowthTick.ts - Light and leaf metabolism · Light tracing feeds leaf metabolism.
gobonsai-web/src/engine/growth/lightTracingSub40E460.ts - Branching and twig growth · Dispatches branching and elongates twigs.
gobonsai-web/src/engine/growth/branchingDispatcherSub417F40.ts - Detach pipeline · Removes or detaches tree structures.
gobonsai-web/src/engine/growth/detachPipelineSub40EEE0.ts
Connections 24
- Native executables → Decompiled native evidence: reverse-engineered into
- Decompiled native evidence → Parity guides: documents recovered behavior
- IDA trace automation → Decompiled native evidence: supports analysis
- Parity guides → Strict EXE simulation path: specifies parity
- Browser entry → App shell: mounts
- App shell → Dashboard controls: hosts
- App shell → Bonsai viewer: hosts
- Dashboard controls → Bonsai controller: controls
- Bonsai controller → Growth controller: coordinates updates
- Growth controller → Growth frame pipeline: runs each frame
- Bonsai controller → Tree object graph: owns lifecycle
- Tree contracts and state → Tree object graph: defines state
- Bonsai viewer → Tree object graph: renders
- Growth frame pipeline → Strict EXE simulation path: selects strict branch
- Growth frame pipeline → Recovered growth tick: runs growth tick
- Recovered growth tick → Light and leaf metabolism: evaluates resources
- Recovered growth tick → Branching and twig growth: updates growth structure
- Branching and twig growth → Detach pipeline: removes structures
- Growth frame pipeline → Tree object graph: mutates
- Growth frame pipeline → World growth state: updates world
- Light and leaf metabolism → Section spatial queries: traces through
- Section spatial queries → World growth state: queries
- Geometry and transforms → Tree object graph: computes transforms for
- Domain growth services → Growth frame pipeline: orchestrates named behavior