Here’s an implementation of David’s GPS compass, without resorting to x and y coordinates in the kind. Instead, this uses the built-in best route mechanism to find the direction the treasure is in from where the player is.
[code]To say GPS direction to (t - a thing):
let tr_loc be the location of t;
let the total distance be the number of moves from the location to tr_loc, using even locked doors;
let count of ns moves be 0;
let count of ew moves be 0;
let next place be the location;
repeat with counter running from 1 to the total distance
begin;
let the way be the best route from the next place to tr_loc, using even locked doors;
if the way is north, let count of ns moves be the count of ns moves plus 1;
if the way is east, let count of ew moves be the count of ew moves plus 1;
if the way is south, let count of ns moves be the count of ns moves minus 1;
if the way is west, let count of ew moves be the count of ew moves minus 1;
if the way is northeast
begin;
let count of ns moves be the count of ns moves plus 1;
let count of ew moves be the count of ew moves plus 1;
end if;
if the way is southeast
begin;
let count of ns moves be the count of ns moves minus 1;
let count of ew moves be the count of ew moves plus 1;
end if;
if the way is southwest
begin;
let count of ns moves be the count of ns moves minus 1;
let count of ew moves be the count of ew moves minus 1;
end if;
if the way is northwest
begin;
let count of ns moves be the count of ns moves plus 1;
let count of ew moves be the count of ew moves minus 1;
end if;
let next place be the room the way from next place;
end repeat;
if count of ns moves is 0 and count of ew moves is 0
begin;
say “spinning in circles”;
otherwise;
say "pointing ";
let absolute count of ns moves be the count of ns moves;
let absolute count of ew moves be the count of ew moves;
if absolute count of ns moves is less than 0, let absolute count of ns moves be 0 minus absolute count of ns moves;
if absolute count of ew moves is less than 0, let absolute count of ew moves be 0 minus absolute count of ew moves;
if absolute count of ns moves is less than absolute count of ew moves
begin;
if absolute count of ns moves is at most the absolute count of ew moves divided by 2, let count of ns moves be 0;
otherwise;
if absolute count of ew moves is at most the absolute count of ns moves divided by 2, let count of ew moves be 0;
end if;
if count of ew moves is 0
begin;
if count of ns moves is greater than 0, say “north”;
otherwise say “south”;
otherwise;
if count of ns moves is 0
begin;
if count of ew moves is greater than 0, say “east”;
otherwise say “west”;
otherwise;
if count of ew moves is greater than 0
begin;
if count of ns moves is greater than 0, say “northeast”;
otherwise say “southeast”;
otherwise;
if count of ns moves is greater than 0, say “northwest”;
otherwise say “southwest”;
end if;
end if;
end if;
end if.
Forestpart is a kind of room. The printed name of a forestpart is “Somewhere in a Forest”. The description of a forestpart is “You are in a forest of twisty trees, all alike. Your GPS is [GPS direction to treasure].”
The player carries a GPS. The inventory listing of the GPS is “A GPS ([GPS direction to treasure])”. The description of the GPS is “The GPS is [GPS direction to treasure].”
Forest_01 is a forestpart. Forest_02 is a forestpart. Forest_03 is a forestpart. Forest_04 is a forestpart. Forest_05 is a forestpart. Forest_06 is a forestpart. Forest_07 is a forestpart. Forest_08 is a forestpart. Forest_09 is a forestpart. Forest_10 is a forestpart. Forest_11 is a forestpart. Forest_12 is a forestpart. Forest_13 is a forestpart. Forest_14 is a forestpart. Forest_15 is a forestpart. Forest_16 is a forestpart. Forest_17 is a forestpart. Forest_18 is a forestpart. Forest_19 is a forestpart. Forest_20 is a forestpart. Forest_21 is a forestpart. Forest_22 is a forestpart. Forest_23 is a forestpart. Forest_24 is a forestpart. Forest_25 is a forestpart.
The player is in Forest_11. A treasure is in Forest_04.
Forest_06 is north of Forest_11. Forest_01 is north of Forest_06. Forest_02 is east of Forest_01. Forest_07 is south of Forest_02. Forest_08 is east of Forest_07. Forest_13 is south of Forest_08. Forest_12 is west of Forest_13. Forest_17 is south of Forest_12. Forest_16 is west of Forest_17. Forest_21 is south of Forest_16. Forest_22 is east of Forest_21. Forest_23 is east of Forest_22. Forest_24 is east of Forest_23. Forest_19 is north of Forest_24. Forest_20 is east of Forest_19. Forest_15 is north of Forest_20. Forest_10 is north of Forest_15. Forest_05 is north of Forest_10. Forest_04 is west of Forest_05.
Forest_03 is north of Forest_08. Forest_09 is east of Forest_08. Forest_14 is south of Forest_09. Forest_18 is south of Forest_13. Forest_25 is east of Forest_24.
Index map with Forest_02 mapped east of Forest_01. Index map with Forest_03 mapped east of Forest_02. Index map with Forest_04 mapped east of Forest_03. Index map with Forest_05 mapped east of Forest_04.
Index map with Forest_06 mapped south of Forest_01. Index map with Forest_07 mapped south of Forest_02. Index map with Forest_08 mapped south of Forest_03. Index map with Forest_09 mapped south of Forest_04. Index map with Forest_10 mapped south of Forest_05.
Index map with Forest_11 mapped south of Forest_06. Index map with Forest_12 mapped south of Forest_07. Index map with Forest_13 mapped south of Forest_08. Index map with Forest_14 mapped south of Forest_09. Index map with Forest_15 mapped south of Forest_10.
Index map with Forest_16 mapped south of Forest_11. Index map with Forest_17 mapped south of Forest_12. Index map with Forest_18 mapped south of Forest_13. Index map with Forest_19 mapped south of Forest_14. Index map with Forest_20 mapped south of Forest_15.
Index map with Forest_21 mapped south of Forest_16. Index map with Forest_22 mapped south of Forest_17. Index map with Forest_23 mapped south of Forest_18. Index map with Forest_24 mapped south of Forest_19. Index map with Forest_25 mapped south of Forest_20.
The Start Room is a region. Forest_11 is in the Start Room.
The Treasure Room is a region. Forest_04 is in the Treasure Room.[/code]