Terminator — 24 of 33

Matt Weiner

Release 0

Section - Doing Terminator Stuff

The terminator counter is initially 0. [The every turn kludge is currently playing havoc with the turn count, so we just keep count ourselves.]

When Rescue Mission begins:

now the left hand status line is "Time to Terminator: [time to terminator minus terminator counter]";

now the right hand status line is "Rescued: [number of astronauts in the cabin of the tiptree]/[number of astronauts]".

The terminator rules are a rulebook.

Last every turn during Rescue Mission (this is the update terminator rule):

Follow the terminator rules.

First terminator rule (this is the increment counter rule):

increment the terminator counter;

if the terminator counter is the time to terminator:

now the left hand status line is "Time since Terminator: [terminator counter minus time to terminator]";

say "The deadly sun is beginning to appear to the east...."

A terminator rule (this is the calculate sunlight rule):

if the terminator counter is greater than the time to terminator:

if the distance of the spaceship exterior from the terminator is 0:

deactivate the spaceship exterior; [we need to check this first so we don't get spurious breakdown messages if anything comes before the spaceship exterior in the object loop, in particular robots right next to it]

repeat with item running through responsive things in the Planet: [and now we shouldn't have to worry about this producing spurious messages when the spaceship has been deactivated, because every robot that was next to the spaceship exterior will have been moved into the spaceship]

let D be the distance of the item from the terminator;

if D is less than one and item is in Planet: [If the terminator hits the spaceship while robots are waiting by it, the robots will be in the spaceship even but they'll still be in the repeat through loop, so we need to make this check]

deactivate the item;

otherwise if D is one:

if the item is a robot:

say "The terminator is almost upon [Item]!";

otherwise if the item is the spaceship exterior:

say "[first time]The terminator has almost reached your ship. The crew prepares for takeoff.[only]";

otherwise if D is two:

if the item is a robot:

say "[Item] reports that the terminator is close by to the east.";

otherwise if the item is the spaceship exterior:

say "[first time]The terminator approaches your ship to the east. The captain orders the crew to being preparing for takeoff.[only]".

To deactivate (item - a robot):

now item is unresponsive;

say "Caught in the sun, [Item] overheats and breaks down.";

now everything in item is unresponsive;

if an astronaut is carried by the item:

say "Inside [item], [number of astronauts carried by item in words] perish[if the number of astronauts carried by item is one]es[end if]."

To deactivate (item - a thing):

now item is unresponsive.

To deactivate (item - the spaceship exterior):

move to the endgame.

To decide what number is the distance of (item - a thing) from the terminator:

if the terminator speed is 0 and the terminator counter is at least the time to terminator, decide on 0; [speed 0 means everything gets lit up at once]

let the terminator position be (grid size plus one) minus the advance of terminator; [this should be the x-coordinate east of which the sun is shining, modulo terrain features]

let the effective distance east be the x-coordinate of the item plus the z-coordinate of the item;

let the shadow length be zero;

repeat with index running from 1 to (4 minus the z-coordinate of the item): [move east looking for something higher, to see if it casts a shadow on the item]

if index plus x-coordinate of the item by y-coordinate of the item is on the grid:

choose row (index plus x-coordinate of the item) graphed by y-coordinate of the item in the Table of Planetary Surface;

let z be the elevation entry;

now the shadow length is the greater of the shadow length and (z plus 1 minus (the z-coordinate of the item plus index)); [a feature that's n units higher than the z-coordinate of the item casts a shadow n units west]

decide on (the terminator position minus the effective distance east) plus the shadow length.

To decide what number is the advance of terminator:

if terminator speed > 0:

decide on (the terminator counter minus the time to terminator) divided by the terminator speed;

otherwise:

decide on (the time to terminator minus the terminator counter) times the terminator speed. [That's not awfully transparent, but since the speed is negative we want to multiply it by the negative of the time since the terminator arrived, so we just switch the two terms in the subtraction.]