by kaen » Sat Aug 20, 2016 05:24
Yeah I think imgur might require javascript, now I feel lame for gif'ing it in the first place.
I've edited my OP with a github repo, but keep in mind that at this point it's just scribbles on a napkin.
The task processing itself works well, and is flexible, and in fact very trivial to implement and use. The trick with writing the tasks, as with all programming, is telling the computer exactly what you mean for it to do.
Regarding despawning/general simulation problems: the code currently contains a wonky little async wait method to attempt to force emerge a certain playable area, and will block history generation until the entire area expected is sent to on_generated. We then constrain at least NPCs to the predefined playable area. Once that's done, read_from_map is used as a fallback to get_node calls that return "ignore". With these guarantees in place we can depend on having map data available for calculation (or that's my theory, I haven't thoroughly tested that part lol).
When it comes to the physics/collision detection, that's actually all been disabled in the engine and reimplemented in Lua. Which is definitely bonkers, and I'm not sold on it, but it does afford some advantages. Namely testability without a minetest process, and the ability to simulate at arbitrary speeds (or indeed under arbitrary conditions). This allows us to use a single code path for start-of-world history generation as well as realtime simulation. Minetest's "entities" are used only as dummy rendering tools, reading from an internal Character class to get pos/vel/accel/yaw. Setting physical = false in the entity definition even allows us to use minetest's built in client-side prediction (except for collisions, so we move slowly). In the test environment entities are completely disabled (no rendering is done).
Again because we have guaranteed that map data will be available, and we have 100% control over the physics and collision detection system, as well as the class that represents characters in the world, we can simulate with arbitrary parameters any amount of the simulation, even if minetest is not running (let alone when a map block is not in memory).
Man I hope that made sense. I just barely understand all of this myself, and I apologize if that comes through in my description.