game.monsters.NavGraph
How a creature finds its way through the house.
The graph is the house. Nodes are the twelve areas and the doorways between them; edges are the doorways and the stairways. So a creature routes the way a person does — room, doorway, room — and it uses the same doors the player uses.
A doorway is a node, not just an edge, so a creature walks to the door and then through it rather than straight at a wall corner.
Why not a voxel grid: a grid over a two-storey house is thousands of nodes built from raycasts, and it would have to be rebuilt whenever a door moved. The room graph is about thirty nodes, comes free from the plan the house is already built from, and cannot disagree with the geometry, because it is that plan.
local NavGraph = require("game.monsters.NavGraph")
local points, status = NavGraph.route(from, to) -- plain world points, first to last
local spot = NavGraph.randomRoom(rand) -- somewhere to wander to
local rooms = NavGraph.roomsNear(point, 4) -- the rooms a searcher checks first
Scoped to this part · feeds back into the world's score.