Chapter 6 - Robot Vision
Section 1 - Describing What Can Be Seen
An object has some text called the seen name. The seen name of an object is usually "[printed name of the item described]". The seen name of a scout is usually "[if the disambiguation status is about to ask for disambiguation]the [otherwise if the asking which do you mean activity is not going on]a [end if]scout". The seen name of a hauler is usually "[if the disambiguation status is about to ask for disambiguation]the [otherwise if the asking which do you mean activity is not going on]a [end if]hauler".
To say sun-caught status of (item - a thing):
if the item is unresponsive, say " caught in the sunlight".
A robot has a stored action called the current attempt. A robot can be successful or unsuccessful.
First before a robot (called bot) doing something (this is the record robot action rule):
now the bot is unsuccessful;
now the current attempt of the bot is the current action.
First after a robot (called the bot) doing something other than looking or taking inventory (this is the mark success rule): [We don't want the robots to be described by other robots as looking or taking inventory, so we don't mark those actions as successful]
now the bot is successful;
continue the action.
To say action description of (bot - a robot):
say seen name of bot;
if the bot is successful:
let the attempt in question be the current attempt of the bot;
say ", [participle part of the attempt in question]";
if the noun part of the attempt in question is not nothing:
if the noun part of the attempt in question is a thing:
say " [a seen name of the noun part of the attempt in question]";
otherwise:
say " [noun part of the attempt in question]";
if the preposition part of the attempt in question is not "":
say " [the preposition part of the attempt in question]";
if the second noun part of the attempt in question is not nothing:
if the second noun part of the attempt in question is a thing:
say " [a seen name of the second noun part of the attempt in question]";
otherwise:
say " [second noun part of the attempt in question]".
To say action description of (item - a thing):
say a seen name of item.
A thing has a number called the sight radius. The sight radius of a hauler is 3. The sight radius of a scout is 2. [The sight radius of terrain features gets decided when we place them.]
A robot has a number called the sight bonus. The sight bonus of a hauler is 0. The sight bonus of a scout is 1.
To decide whether (item - a thing) is within sight of (bot - a robot): [originally had this as "can see," which led to a namespace clash]
if bot is item, no;
let delta-x be (x-coordinate of bot minus x-coordinate of item);
let delta-y be (y-coordinate of bot minus y-coordinate of item);
let z be the sight radius of the item plus the sight bonus of the bot;
if z squared is at least delta-x squared plus delta-y squared, yes;
no.
To decide what number is the integer absolute value of (x - a number):
if x < 0, decide on 0 - x;
decide on x. ["Absolute value" is built in but casts the number to real numbers, and I figure it's better to avoid heavy real number calculations if possible; also in Inform version 6L02 comparing numbers to real numbers is buggy.]
To decide what number is (n - a number) squared:
decide on n * n.
To decide what number is the greater of (n - a number) and (m - a number):
if n is at least m, decide on n;
decide on m.
To decide what number is the lesser of (n - a number) and (m - a number):
if n is at least m, decide on m;
decide on n.