Repository navigation
Combustion engine: 41 parts, driven from the browser - #81
Merged
Merged
Conversation
The engine grows from 12 components to 41, one per real part: camshaft and eight valves, fuel rail and injectors, throttle body and intake manifold, exhaust manifold and oxygen sensor, oil pump, water pump, thermostat, radiator, cooling fan and its sensor, alternator, battery, fuse box, AC compressor, headlights, ECU, cockpit and instrument cluster. The crankshaft's turn still drives every stroke, and the mesh still stops by itself when the engine does. The program now serves a self-contained canvas page (go:embed, standard library only): the driver's pedal and switches go in over HTTP, every part's state comes back as server-sent events. Throttle on the keyboard (hold Up/W, Space to floor it), with on-screen buttons and a hand throttle slider for touch. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ggt9ptDN59sQDzu9a21DJP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by ovsep · project thread
Before: the combustion engine was 12 components printing a dashboard line to the terminal while a scripted driver floored it until the tank ran dry.
After: it is 41 components, one per real part (camshaft and eight valves, fuel rail with injectors, throttle body, intake and exhaust manifolds, oxygen sensor, oil pump and pressure sensor, water pump, thermostat, radiator, cooling fan and coolant sensor, alternator, battery, fuse box, AC compressor, headlights, starter, ECU, cockpit, instrument cluster), and
go run .serves a game-like page at http://localhost:8080. On the page pistons move, valves open, injectors spray, cylinders burn, the belt and fan spin and the exhaust glows. It also has gauges and warning lamps. You drive it yourself: hold ↑/W for the throttle or Space to floor it, I to start and stop, A for the AC, L for the lights, F to refuel, 1/2/3 for real time, ¼ speed or slow motion, and M for sound. Every control is also a button, and a hand throttle slider makes it work on a phone.The mesh is still the whole model. One trip around it is one stroke, the crankshaft's turn drives the next one, and the mesh still stops by itself when the engine does: key off, tank dry, stall, or a flat battery that only clicks.
How
mechanical.go,breathing.go,cooling.go,electrical.go,control.go). Parts that need several flows per stroke wait for all of them withRequireInputs. Sensors arrive late in the stroke, so the ECU and the instrument cluster listen instead: they keep the latest reading in state. The accessory belt and the fuse box each work in two beats of one stroke. The fuse box tells the battery the load before the battery answers with volts, so a weak battery sags under the starter in the same stroke.Driver, and thecockpitcomponent reads it once per stroke. AnAfterCyclehook paces the run to the wall clock and streams every part'sState()as server-sent events. Only the standard library is used.web/index.htmlembedded withgo:embed. It uses vanilla JS on an HTML5 canvas, with no build step and nothing loaded from the internet.-raceand in Chromium at desktop and phone widths.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ggt9ptDN59sQDzu9a21DJP
Generated by Claude Code