As I prepare to overcomplicate yet another thing, I want to check and see if there’s an obvious solution I’ve missed.

The core of my current project is that NPCs can do things you can’t, but you can never communicate with them directly. So you have to try to manipulate the environment to make things happen to your benefit.

One of these NPCs is running around putting out any metaphorical fires that happen. You need to cause problems in particular rooms and then ensure the map is set up such that his route to those problems will open the doors you need. So far so good. Inform’s got good route-finding built in, and I’ve got my Enhanced Route Finding extension to improve it even further.

Some doors are jammed and he can’t use them. Some rooms are cramped and he prefers to avoid them. Some rooms are overheated and he *really* prefers to avoid them. So far so good. Inform can handle all of this.

But how does he choose his targets in the first place?

The obvious solution is to use a superlative adjective:

Definition: a room (called the place) is ready if the number of moves from the location of Bashti to the place through moderate rooms using easy doors is less than 5.

Let the goal be the readiest sabotaged room…

Unfortunately superlatives only work with properties of objects, not calculated values. So this is off the table.

My current plan is to make a table, and put each sabotaged room in its own row. Then for each one, I’ll record:

- The number of moves from Bashti’s location to this place, through easy rooms only
- The number of moves through easy and cramped rooms
- The number of moves through easy, cramped, and overheated rooms

Then I can calculate some kind of heuristic for how easy it will be to get to that room. Maybe add a penalty to the second and third columns, change “there is no route” to 9999, then take the minimum distance between the three. Sort by this heuristic column, and the top row is his new destination.

But this seems like a lot of wheel-reinventing going on. Is there a simpler or more elegant way to do this in I7?

(Side note: for anyone else who wants to do this, remember to calculate the values one *column* at a time, not one *row* at a time. With fast route-finding Inform reruns the shortest-path algorithm every time you change which subset of rooms and doors you’re looking for, and caches the results. So you want to change that subset as few times as possible. This is my reason for putting them in a table instead of storing the heuristic value as a property of each object.)