Skip to content

Instantly share code, notes, and snippets.

@Lifelovinglight
Last active August 11, 2017 07:56
Show Gist options
  • Save Lifelovinglight/d62ecc044ecb65ba24d5764bc636cce8 to your computer and use it in GitHub Desktop.
Save Lifelovinglight/d62ecc044ecb65ba24d5764bc636cce8 to your computer and use it in GitHub Desktop.
moving alien ai in inform 7
"alien" by "whiteline"
the sick bay is a room.
the corridor is a room.
the freezer is a room.
the sick bay is west of the corridor.
the freezer is north of the corridor.
the player is in the sick bay.
a chaser is a kind of animal.
a chaser is either chasing or wandering. A chaser is usually wandering.
a chaser has a room called the destination.
a person can be hidden. A person is usually not hidden.
the alien is a chaser in the freezer.
whistling is an action applying to nothing. understand "whistle" as whistling.
a carry out whistling rule:
repeat with c running through chasers:
now the destination of c is the location of the player;
now c is chasing;
Hiding relates a person to a thing. The verb to hide in means the hiding relation. The verb to be hidden by implies the reversed hiding relation.
Every turn (this is the implied hiding rule):
repeat with p running through people:
if p is contained by a thing (called the hiding spot):
now p is hidden by the hiding spot.
hiding is an action applying to one visible thing. understand "hide using [a thing]" as hiding.
a carry out hiding rule:
now the player is hidden;
now the player is hiding in the noun.
before going when the player is hidden:
now the player is not hidden;
continue the action.
every turn (this is the alien behavior rule):
repeat with c running through chasers:
if c is in the location of the player:
if the player is not hidden:
say "boo!";
else:
if c is chasing:
now c is wandering;
if c is chasing:
let chasedir be the best route from the location of c to the location of the player;
try c going chasedir;
else:
let wanderdir be the best route from the location of c to a random room adjacent to the location of c;
try c going wanderdir;
The implied hiding rule is listed before the alien behavior rule in the every turn rules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment