Other than?

How do I resolve these problems?

The code looks like this:

Every turn when 2 students are visible: let student1 be a random visible student; let student2 be a random visible student other than [student1]; say "[student1] and [student2]."

I know I ask a lot of questions, I hope I don’t anger you; I ask a lot of questions because I come from quest, thank you for all your help!

The first thing is that when you put something in square brackets [] outside of quotation marks, Inform 7 treats it as a comment–something put in your code to help you understand it, but that isn’t actually part of the code. So it ignores it. Which means that Inform thinks you just wrote “let student2 be a random visible student other than.”

The other thing is that “other than” isn’t a built-in phrase in Inform. If we were just testing whether student1 was student2, we could write “if student 2 is not student1,” but choosing a random thing is tricky–there our description of the random object has to be built out of adjectives and relations. As far as I know, and I could be wrong, there isn’t a built-in relation that will let us do what we want here… but we can define one, like this:

Difference relates a thing (called X) to a thing (called Y) when X is not Y. The verb to be different from means the difference relation.

With that in place you should be able to write:

Every turn when 2 students are visible: let student1 be a random visible student; let student2 be a random visible student that is different from student1; say "[student1] and [student2]."

And no problem asking questions! Speaking for myself, it’s fun answering them and I’m glad if I can help someone.

1 Like

Thank You!

You’ve been getting a lot of mileage out of this conditional relation technique recently. It’s one that I need to “put in my toolbox” (so to speak) so that it comes to mind more readily when I’m solving problems.

Seconded. They say that the best way to learn something is to explain it to someone else. In some ways, I see this forum as a kind of dynamic set of exercises, each of which I’m sure that at least one person (1) cares about and (2) found challenging enough that they sought help. Answering questions here allows me to: help people, solidify my own understanding of I7, and expose my answers to public scrutiny so that others can correct errors or suggest more elegant solutions. I’d encourage anyone who wants to improve their I7 chops to try answering some questions, even if you don’t think of yourself as an expert. You probably have something to offer the questioner, and other people can fill in any gaps in your answer (and the more you do it, the fewer gaps there are likely to be).

Hey Murph, (Can I call you that or is it annoying? Be honest.)

Anyway, I want to echo what Matt and Vince wrote. (What’s up, Weiner — I’m ba-ack.) To everyone reading this, I guarantee you that for every question you ask, there will be at least three other people right now and several others down the road who have or will have the same question but are too worried about looking foolish to ask it. Never be afraid to ask a question — unless you haven’t even read the docs and just started typing sentences into I7 thinking, “That’ll work.” (Trust me, people like that exist.)

My only problem with your post is that I’m not exactly sure what you want to do, or — more specifically — why (in terms of the work itself). Obviously, you want to be able to randomize the students, but is that to facilitate conversation, to hide the importance of a student who is key to a puzzle, to make the text less repetitive, etc.?

I’m going to guess from the code you provided that you’ve created a “student” kind of person. (There are other ways of accomplishing this, but a new kind of person is probably the best.) I’m also assuming from your code that these students have unique names. I’m a little confused about the whole “Student1 / Student2” thing. The randomization could be done easily with a list:

[code]Use serial comma. [Sorry, it’s a thing of mine.]

A student is a kind of person.
Peter, Paul, Mary, Tom, Dick, Harry, Jane, Joan, and Jill are students.

When play begins:
Repeat with S running through students:
now S is in a random room.

The Hallway is a room.
The Classroom is east of the Hallway.
The Lab is west of the Hallway.
The Library is north of the Hallway.

For listing nondescript items (this is the reorder student list rule):
let slist be the list of students in the location;
sort slist in random order;
say “[slist] [are] here, [if the number of entries in slist is 1]studying as usual.[else]arguing as usual.”

test me with “e/w/w/e/n/s/e”.[/code]
HTH