# Sorting directions by visitedness in "you can't go that way" list

I have the code below, which is okay if you eliminate the “sort lvd in visyet order” command.

But I’d like it in, because otherwise you get “You can go north or south to room-that’s-south,” which is confusing.

However, Inform seems to think that I am trying to sort a table. What am I missing? Thanks!

``````check going nowhere:
carry out the exitlisting activity;
the rule succeeds;

exitlisting is an activity.

rule for exitlisting:
let lvd be list of viable directions;
sort lvd in visyet order;
say "You [if noun is diagonal]never need to use diagonal directions[else]can't go [noun][end if], [if number of viable directions is 0]and you may need to figure a puzzle to go anywhere[else]but you can go [lvd][end if].";

to determine what number is visyet of (x - a direction):
if the room x of location of player is visited, 0;
1;

after printing the name of a direction (called d) while exitlisting:
let rm be the room d of location of player;
if rm is visited, say " to [rm]";

``````

Now, I’ve found an adequate solution with

``````rule for exitlisting:
let lvd be the list of viable-gone directions;
let lvd2 be the list of viable-not-gone directions;
say "You [if noun is diagonal]never need to use diagonal directions[else]can't go [noun][end if], [if number of viable directions is 0]and you may need to figure a puzzle to go anywhere[else]but you can go [lvd][end if].";

definition: a direction (called d) is viable-gone:
if d is viable and the room d of location of player is visited, yes;
no;

definition: a direction (called d) is viable-ungone:
if d is viable and the room d of location of player is unvisited, yes;
no;
``````

But I suspect I am missing something about sorting and would love to know what it is.

Thanks!

I suspect the issue here is that visyet isn’t a property of the directions. So if you said “A direction has a number called visyet,” and everytime the player went to a new place it reassigned the numbers to the directions in the appropriate way, then you could probably sort a list of directions in visyet order. (Haven’t tested it though.)

1 Like

Thanks, Matt. I forgot about this, and while this wasn’t the solution I finally used, you helped me find something good.

1 Like