Five Gods Exiled — 5 of 191

Carolyn VanEseltine

Release 1

Book 2 - Randomizing Rooms and Directions

The X-coord maximum is a number that varies.

The X-coord maximum is 8.

The Y-coord maximum is a number that varies.

The Y-coord maximum is 8.

The current room is a room that varies.

The important room is a room that varies.

To randomize Blight rooms and directions:

let the next room be R1; [Just to satisfy the new requirements re: declaring variables.]

choose row 1 in the Table of Existing Rooms; [If it were possible to have starting null values in a table, we wouldn't have this rigamarole anyway.]

blank out the whole row;

now the location in row 1 of the Table of Existing Rooms is R1; [Putting our original room back.]

let coord-table maximum be the X-coord maximum times the Y-coord maximum; [How big is this table? Define the grid.]

let X-count be 1;

let Y-count be 1;

repeat with N running from 1 to the coord-table maximum:

now the X in row N of the Table of Coordinates is X-count;

now the Y in row N of the Table of Coordinates is Y-count;

if Y-count is the Y-coord maximum:

now Y-count is 1;

now X-count is X-count plus 1;

otherwise:

now Y-count is Y-count plus 1;

now the current room is the location in row 1 of the Table of Existing Rooms;

let X-current be a random number between 1 and the X-coord maximum;

let Y-current be a random number between 1 and the Y-coord maximum;

repeat with N running from 1 to the coord-table maximum:

if the X in row N of the Table of Coordinates is X-current and the Y in row N of the Table of Coordinates is Y-current:

now the location in row N of the Table of Coordinates is the current room;

[say "The current room ([current room]) is at [X-current] [Y-current].";]

repeat through the Table of Existing Rooms:

now the important room is the location entry;

let the next room be the location entry;

[say "[line break]**Current room: [current room] Important room: [important room] Next room: [next room]***[line break]";]

while the important room is not a location listed in the Table of Coordinates:

let the connection randomizer be a random number between 1 and 8;

[say "Connection randomized to [connection randomizer] - ";]

let X-next be 0;

let Y-next be 0;

if the connection randomizer is 1: [north]

let X-next be X-current;

let Y-next be Y-current plus 1;

otherwise if the connection randomizer is 2: [northeast]

let X-next be X-current plus 1;

let Y-next be Y-current plus 1;

otherwise if the connection randomizer is 3: [east]

let X-next be X-current plus 1;

let Y-next be Y-current;

otherwise if the connection randomizer is 4: [southeast]

let X-next be X-current plus 1;

let Y-next be Y-current minus 1;

otherwise if the connection randomizer is 5: [south]

let X-next be X-current;

let Y-next be Y-current minus 1;

otherwise if the connection randomizer is 6: [southwest]

let X-next be X-current minus 1;

let Y-next be Y-current minus 1;

otherwise if the connection randomizer is 7: [west]

let X-next be X-current minus 1;

let Y-next be Y-current;

otherwise if the connection randomizer is 8: [northwest]

let X-next be X-current minus 1;

let Y-next be Y-current plus 1;

repeat with N running from 1 to the coord-table maximum:

if the X in row N of the Table of Coordinates is X-next and the Y in row N of the Table of Coordinates is Y-next:

[say "The important room ([important room]) should be placed at [X-next] [Y-next]. ";]

if there is no location in row N of the Table of Coordinates:

[say "And, hooray, that location is empty! ";]

now the location in row N of the Table of Coordinates is the important room;

now the next room is the important room;

if the connection randomizer is 1: [north]

[say "Connecting [current room] to [next room] via a north exit.";]

now the n-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the s-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

if the connection randomizer is 2: [northeast]

[say "Connecting [current room] to [next room] via a northeast exit.";]

now the ne-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the sw-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

if the connection randomizer is 3: [east]

[say "Connecting [current room] to [next room] via an east exit.";]

now the e-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the w-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

if the connection randomizer is 4: [southeast]

[say "Connecting [current room] to [next room] via a southeast exit.";]

now the se-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the nw-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

if the connection randomizer is 5: [south]

[say "Connecting [current room] to [next room] via a south exit.";]

now the s-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the n-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

if the connection randomizer is 6: [southwest]

[say "Connecting [current room] to [next room] via a southwest exit.";]

now the sw-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the ne-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

if the connection randomizer is 7: [west]

[say "Connecting [current room] to [next room] via a west exit.";]

now the w-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the e-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

if the connection randomizer is 8: [northwest]

[say "Connecting [current room] to [next room] via a northwest exit.";]

now the nw-room corresponding to a location of the current room in the Table of Existing Rooms is the next room;

now the se-room corresponding to a location of the next room in the Table of Existing Rooms is the current room;

otherwise:

[say "Unfortunately, that row is already taken, but we can hook the directions up anyway.";]

let the blocking room be the location in row N of the Table of Coordinates;

if the connection randomizer is 1: [north]

[say "Connecting [current room] with [blocking room] to the north.";]

now the n-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the s-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

if the connection randomizer is 2: [northeast]

[say "Connecting [current room] with [blocking room] to the northeast.";]

now the ne-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the sw-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

if the connection randomizer is 3: [east]

[say "Connecting [current room] with [blocking room] to the east.";]

now the e-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the w-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

if the connection randomizer is 4: [southeast]

[say "Connecting [current room] with [blocking room] to the southeast.";]

now the se-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the nw-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

if the connection randomizer is 5: [south]

[say "Connecting [current room] with [blocking room] to the south.";]

now the s-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the n-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

if the connection randomizer is 6: [southwest]

[say "Connecting [current room] with [blocking room] to the southwest.";]

now the sw-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the ne-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

if the connection randomizer is 7: [west]

[say "Connecting [current room] with [blocking room] to the west.";]

now the w-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the e-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

if the connection randomizer is 8: [northwest]

[say "Connecting [current room] with [blocking room] to the northwest.";]

now the nw-room corresponding to a location of the current room in the Table of Existing Rooms is the blocking room;

now the se-room corresponding to a location of the blocking room in the Table of Existing Rooms is the current room;

now the current room is the blocking room;

[say "Continuing from [blocking room] (current room [current room], next room [next room], important room [important room])....";]

now X-current is the X corresponding to a location of the current room in the Table of Coordinates;

now Y-current is the Y corresponding to a location of the current room in the Table of Coordinates;

now the current room is the important room;

now X-current is the X corresponding to a location of the current room in the Table of Coordinates;

now Y-current is the Y corresponding to a location of the current room in the Table of Coordinates;

move the player to R1;

repeat with N running from 1 to the number of rows in the Table of Existing Rooms:

now the current room is the location in row N of the Table of Existing Rooms;

if there is an n-room in row N of the Table of Existing Rooms:

now the next room is the n-room in row N of the Table of Existing Rooms;

change the north exit of the current room to the next room;

change the south exit of the next room to the current room;

if there is a ne-room in row N of the Table of Existing Rooms:

now the next room is the ne-room in row N of the Table of Existing Rooms;

change the northeast exit of the current room to the next room;

change the southwest exit of the next room to the current room;

if there is an e-room in row N of the Table of Existing Rooms:

now the next room is the e-room in row N of the Table of Existing Rooms;

change the east exit of the current room to the next room;

change the west exit of the next room to the current room;

if there is an se-room in row N of the Table of Existing Rooms:

now the next room is the se-room in row N of the Table of Existing Rooms;

change the southeast exit of the current room to the next room;

change the northwest exit of the next room to the current room;

if there is an s-room in row N of the Table of Existing Rooms:

now the next room is the s-room in row N of the Table of Existing Rooms;

change the south exit of the current room to the next room;

change the north exit of the next room to the current room;

if there is an sw-room in row N of the Table of Existing Rooms:

now the next room is the sw-room in row N of the Table of Existing Rooms;

change the southwest exit of the current room to the next room;

change the northeast exit of the next room to the current room;

if there is an w-room in row N of the Table of Existing Rooms:

now the next room is the w-room in row N of the Table of Existing Rooms;

change the west exit of the current room to the next room;

change the east exit of the next room to the current room;

if there is an nw-room in row N of the Table of Existing Rooms:

now the next room is the nw-room in row N of the Table of Existing Rooms;

change the northwest exit of the current room to the next room;

change the southeast exit of the next room to the current room.