Repository navigation
Own backend: unit events (step 11, part 3) - #57
Merged
Merged
Conversation
Step 11, part 3 of the way off eudplib: the ledger's 15 rows of on.created, on.died, on.killed, on.order and on.morphed are taken, and step 11 is done (50 of 50). The map's events pass, once before every program's turn as the Python side's: the units linked in behind the head of the game's list since the pass before, each not seen before marked and listed; the dying list both ways from its head; with on.order or on.morphed, every unit's order and type against the pass before's. What it keeps of a unit place is a table of plain dwords 336 bytes apart, as the places are, which the layout lays out before the triggers so that they fill the room between; the current player is pointed at a unit's dword of it (pointAt). A listener is a task looping over what the pass found. probes/own-events.ts, lifted game, Remastered's weights, µs a frame (ours / eudplib): nothing coming or going 4.7 / 5.1, forty units made 210 / 248, forty-six dying 146 / 89, with on.order 221 / 164; the map 1.05 / 1.78 MB. The walks are slower: the plan says how to be past eudplib at all of it (a trigger a unit place holding what it last saw). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01En4SHqafb1QFJ4xgbUkAe5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01En4SHqafb1QFJ4xgbUkAe5
The events pass no longer walks the game's lists by their pointers: it is a trigger for each unit place, whose conditions compare the place's record with what the trigger saw there last, held in its own conditions' numbers (the uniqueness byte, whether the unit is alive or its order, its type). A place as it was costs that one trigger; one that changed goes through its stub to the handler, which lists what came on, died, took up an order or turned into another type, and writes what it sees back into the trigger. A place whose unit is dead or gone is watched by its uniqueness byte alone: the handler switches the second condition off. The places are walked newest first, from the one the game hands out next. The 336-byte tables and pointAt are gone. Lifted game, Remastered's weights, µs a frame (ours / eudplib): with on.order, nothing happening 7.2 / 164, forty-six dying 9.0 / 224; without it, forty-six dying 8.7 / 89, forty made 188 / 248, forty killed 180 / 392, nothing happening 9.3 / 5.2 with 128 places handed out (the one frame eudplib's build is ahead on: in the plan's Open list). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01En4SHqafb1QFJ4xgbUkAe5
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.
Step 11 of the way off eudplib, part 3: unit events on a map of our own. The ledger's 15 rows of
on.created,on.died,on.killed,on.orderandon.morphedare taken, so step 11 is done: 50 of 50. No row of another stepmoved.
What it does
trigger for each place, whose conditions compare the place's record with what the trigger saw there last, held in
its own conditions' numbers. That is the uniqueness byte, and, as the events need them, whether the unit is alive or
which order it has, and its type.
before it back and go on to the next. A place that changed goes through a stub of its own to the handler, laid out
once. If the uniqueness byte differs and the unit is alive, a unit came on. If it was seen alive and isn't now, it
died. If it took up another order or turned into another type, that is reported too. Then what it sees now goes back
into the trigger's numbers.
the second condition, and the game reads no further. That costs 48 ns a place, against 60 for a living unit.
hand out next, goes up to 1,699, then does place 0. The game hands places out in that order, never-used ones last, so
the starting point only moves down. When the handler sees that place handed out, the walk starts one further on from
then on.
It was slower than eudplib when units were dying (146 µs against 89) and with
on.order(221 against 164). The tableof plain dwords 336 bytes apart and
pointAtwent with it.earlier in the same trigger moved it. A task's call (
start) with a unit among its parameters was rewritten as anexpression instead of as statements. An empty trigger whose next pointer gets written has to be kept.
Weighed (
probes/own-events.ts, and the same probe withouton.order; lifted game, Remastered's weights, µs aframe)
on.orderamong the eventson.orderamong the eventson.orderamong the eventson.order: forty-six units dyingon.order: forty units made / killed in a frameon.order: nothing coming or going, about 80 places handed outon.order: the same, 128 places handed outon.orderamong the events / withoutStill behind eudplib, listed in the plan's Open list
on.order. eudplib's build looks only at the headsof its lists then. The watch costs 48–60 ns for every place the game has handed out: 9.3 µs against 5.2 at 128
places, and about 90 against 5 with the whole table in use. The way out is a gate that skips the watch when nothing
can have changed: the head of the game's free list (it moves when a unit gets a place or one is freed) plus a count
that moves when a unit starts to die. That has to be read in both games first, since Remastered links its lists
differently.
Checked
tests/emitter.test.ts, "a map of our own, unit events": a unit table laid out as the game keeps it, changed betweenframes: a unit handed a place, an order taken up, a type changed, a unit dying in a fight, and its place handed to
another unit. The payload is walked from its bytes frame after frame, each line checked at its frame. Also a handler
that waits: a task each.
probes/own-tasks.tsandprobes/own-errors.tsbuild byte for byte as before. The emitter's random-program tests take as long as before.Played in Remastered: the first commit's map (recording 21.59.29): all 7 lines in order, each at the lifted game's
frame. To play:
Maps/TrigScript/own-step11-events-watch.scx, the merged version, with its answer sheet.🤖 Generated with Claude Code
https://claude.ai/code/session_01En4SHqafb1QFJ4xgbUkAe5