'repeat with' x 'running through' y giving 'does not exist' errors

I’m adapting code from Ryan Veeder’s Island of Dr Wooby:

(https://www.rcveeder.net/blog/2017/05/17/procedural-generation-of-dinosaurs-in-inform-7/)

The idea being that I’m trying to generate a randomized student with certain biographical backgrounds.

But using the ‘repeat with’ command in generally the same way Ryan does is giving me an error: (I’m getting a few errors but this is the first one!)

But I didn’t recognise ‘bio_storys incorporated by student_biography’.

The name ‘bio_fact’ doesn’t yet exist.

As far as I can tell, ‘repeat with’ is supposed to use a new value, and that’s who Ryan is using it, so I’m not sure why it’s causing a problem here!

My code below:

"student building" by "Jason Mehmel"


Book 1 - making students

A student is a kind of thing.

A generated_student is a kind of thing.

A locker_owner is a kind of thing.

A blank_human is a kind of thing.



Section 1 - Index of bio-stories

A bio_story is a kind of thing.

A bio_story has text called flavour.

A thing can be marked.

Section 2 - biography

A Student_Biography is a kind of bio_story. A Student_Biography is a part of every locker_owner.

Student_economics is a kind of value. The student_economics are rich, middle-class, and poor.

Understand the student_economics property as describing a student_biography.

Student_home is a kind of value. The student_homes are downtown, suburbs, and country.

Understand the student_home property as describing a student_biography.

Student_parents is a kind of value. The student_parents are divorced, married, separated, blended, foster, and adopted.

Understand the student_parents property as describing a student_biography.

A student_biography has student_economics. The student_economics of a student_biography is usually middle-class.

A student_biography has student_home. The student_home of a student_biography is usually suburbs.

A student_biography has student_parents. The student_parents of a student_biography is usually married.



This is the biographize rule:
    let the current student_biography be a random student_biography;
    now the student_economics of the current student_biography is a random student_economics;
    now the student_home of the current student_biography is a random student_home;
    now the student_parents of the current student_biography is a random student_parents;
	rule succeeds with result student_biography.

A locker_owner has text called the impression.

The description of a locker_owner is usually "[the impression of the noun].".


To say the impression of (student - locker_owner):
	let L be a list of texts;
	repeat with bio_fact running through bio-storys incorporated by student_biography:
		if bio_fact is a student_economics:
			add "[flavor of bio-fact] economic class," to L;
		if bio_fact is a student_home:
			add "[flavor of bio-fact] housing location," to L;
		if bio_fact is a student_parents:
			add "[flavor of bio-fact] family background," to L;

	sort L in random order;
	say "What we know about The Student: [L] but we need to find out more. That's where you come in."


Book 2 - game begins

When play begins:
	follow biographize rule.
	
	
The office is a room.

There is a boy in the office. The boy is a locker_owner.

bio-fact doesn’t exist because bio-storys incorporated by student_biography is not compilable, because student_biography is a kind, not a thing. You need to substitute some definite thing (a random student_biography, maybe?).

The ‘doesn’t yet exist’ error is a strangely-worded one, because it’s talking about the result of the error, not the cause.

I think you’re confusing object properties (“a crayon has a colour”) with incorporation (“a control panel is part of the nuclear reactor”). Your biographies have a house, economic background, parent, etc. - but you only need to “repeat running through” when they might incorporate (or some other relation) an unknown number of other objects.

For properties, every student-biography has exactly one house, one economics, one parents, so you can just say “the student-economics of the student-background of the locker-owner”.

I’m on mobile right now so can’t write up any proper code but hopefully that helps you see why it wasn’t working?

3 Likes

That is a useful distinction! This whole time I’ve been grappling with the concepts of ‘things’ vs. ‘kinds of things’ as relates to the variables I’m using.

Am I falling into the below mistake?

A sword is a thing.

A rapier is a kind of sword.

'etc etc' bio_storys incorporated by rapier.

This is definitely getting me on the right track, alongside @rileypb’s note about trying to incorporate kinds of things vs things themselves.

I think Ryan’s code was built around the idea of some uncertainty regarding the total contents of the thing created (in his case, dinosaurs) and I’ve mostly lifted that framework for my own project, because of how robust it is.

(I eventually want to create a similar level of possible random combinations.)

I’m going to try a few things:

I’ll try your method of just saying the properties of the locker_owner.

Then I’ll try shifting the code so that those elements are parts of the student_background, just to try to see how to get the original framework working.

Do you need a bunch of rapiers, or just the one? If it’s the latter (and I think it is from the way that it seems like you’re trying to get a specific story incorporated into it), you just say “a rapier is a sword,” and then it’ll be a specific object, not a kind.

(Subkinds can be useful, to be clear, so if you do want to have multiple rapiers this is the approach to take).

Well, I’m trying to design towards a bigger version of the project I’m making.

So going back to my code, eventually I’d like to generate the biography of a multiple students, because the player would be investigating multiple people.