Make your own free website on Tripod.com
unit maze;

interface

uses graph3, crt;
const GREEN = 1; RED = 2; ORANGE = 3;
type MAZE_ARRAY = ARRAY [1..33] OF STRING;

procedure init_chicago_maze (var name: STRING; var chicago_maze: MAZE_ARRAY);
procedure init_london_maze (var name: STRING; var london_maze: MAZE_ARRAY);
procedure init_japan_maze (var name: STRING; var japan_maze: MAZE_ARRAY);
procedure write_text (name: STRING);
procedure draw_maze (any_maze: MAZE_ARRAY; colour: INTEGER);
procedure draw_blocks (any_maze: MAZE_ARRAY; colour: INTEGER);
function  roadblock_count (x_pos, y_pos: INTEGER; any_maze: MAZE_ARRAY):INTEGER;
function  wall_count (x_pos, y_pos: INTEGER; any_maze: MAZE_ARRAY):INTEGER;

implementation

procedure init_chicago_maze (var name: STRING; var chicago_maze: MAZE_ARRAY);
begin
  name := '       Chicago 1986';
  Chicago_maze [1]:=(' - - - - - - - - - - - - - - - - ');
  chicago_maze [2]:=('                          ');
  chicago_maze [3]:=(' - -                       - -   ');
  chicago_maze [4]:=('                        ');
  chicago_maze [5]:=('   -     - -                     ');
  chicago_maze [6]:=('                   ');
  chicago_maze [7]:=('                                 ');
  chicago_maze [8]:=('                     ');
  chicago_maze [9]:=('   -   - - -   - - - -     -     ');
  chicago_maze[10]:=('                         ');
  chicago_maze[11]:=('     - - -             - -   - - ');
  chicago_maze[12]:=('                       ');
  chicago_maze[13]:=(' -     -   -           - - - -   ');
  chicago_maze[14]:=('                          ');
  chicago_maze[15]:=('   - - - - - - - - - - -     -   ');
  chicago_maze[16]:=('                           ');
  chicago_maze[17]:=('   - - - - -         - -   -   - ');
  chicago_maze[18]:=('                          ');
  chicago_maze[19]:=('     - - -     - - - -           ');
  chicago_maze[20]:=('                     ');
  chicago_maze[21]:=('     - - -               - -     ');
  chicago_maze[22]:=('                         ');
  chicago_maze[23]:=('     -   - - -   -       -       ');
  chicago_maze[24]:=('                         ');
  chicago_maze[25]:=('   - - - - - - - - - - - -       ');
  chicago_maze[26]:=('                         ');
  chicago_maze[27]:=('   - -       -       - -   - -   ');
  chicago_maze[28]:=('                        ');
  chicago_maze[29]:=('   -     - -     - - - - -       ');
  chicago_maze[30]:=('                         ');
  chicago_maze[31]:=('             - -   - -     - -   ');
  chicago_maze[32]:=('                           ');
  chicago_maze[33]:=('   - - - - - - - - - - - - - - - ');
end; { init_chicago_maze }

procedure init_london_maze (var name: STRING; var london_maze: MAZE_ARRAY);
begin
  name := '        London 1981';
  london_maze [1]:=(' - - - - - - - - - - - - - - - - ');
  london_maze [2]:=('                               ');
  london_maze [3]:=('   - - - - - - - - - - - - - -   ');
  london_maze [4]:=('                             ');
  london_maze [5]:=('     - - - -     - - - - - -     ');
  london_maze [6]:=('                         ');
  london_maze [7]:=('       - -       - -   - -       ');
  london_maze [8]:=('                      ');
  london_maze [9]:=('                 - - - -       - ');
  london_maze[10]:=('                     ');
  london_maze[11]:=('               - - - -   -       ');
  london_maze[12]:=('                     ');
  london_maze[13]:=('                 - -   - -       ');
  london_maze[14]:=('                      ');
  london_maze[15]:=('               -     - -   - -   ');
  london_maze[16]:=('                    ');
  london_maze[17]:=('                           -   - ');
  london_maze[18]:=('                     ');
  london_maze[19]:=('   - - -       - -       -   -   ');
  london_maze[20]:=('                        ');
  london_maze[21]:=('       -     - - - - - -       - ');
  london_maze[22]:=('                         ');
  london_maze[23]:=('     - - -     - -   -   -   -   ');
  london_maze[24]:=('                            ');
  london_maze[25]:=('         - - - - - -           - ');
  london_maze[26]:=('                            ');
  london_maze[27]:=(' -     -   - - - -   -   -   -   ');
  london_maze[28]:=('                          ');
  london_maze[29]:=('         -   - -   -   -   -   - ');
  london_maze[30]:=('                         ');
  london_maze[31]:=('       - - -     - - -   - - -   ');
  london_maze[32]:=('                             ');
  london_maze[33]:=('   - - - - - - - - - - - - - - - ');
end; { init_chicago_maze }

procedure init_japan_maze (var name: STRING; var japan_maze: MAZE_ARRAY);
begin
  name := '        Japan 1982';
  japan_maze [1]:=(' - - - - - - - - - - - - - - - - ');
  japan_maze [2]:=('                            ');
  japan_maze [3]:=('     - - - - -   -               ');
  japan_maze [4]:=('                      ');
  japan_maze [5]:=('   -             -       -       ');
  japan_maze [6]:=('                    ');
  japan_maze [7]:=('                 - - -   - - -   ');
  japan_maze [8]:=('                       ');
  japan_maze [9]:=('                 - - -   - -     ');
  japan_maze[10]:=('                        ');
  japan_maze[11]:=('                 - - -   - -     ');
  japan_maze[12]:=('                          ');
  japan_maze[13]:=('                 - - -   - -     ');
  japan_maze[14]:=('                       ');
  japan_maze[15]:=('   -           - - - - - - - -   ');
  japan_maze[16]:=('                          ');
  japan_maze[17]:=('   -               - - - - -     ');
  japan_maze[18]:=('                       ');
  japan_maze[19]:=('               - - - - - - - -   ');
  japan_maze[20]:=('                        ');
  japan_maze[21]:=('                 - - -   - -     ');
  japan_maze[22]:=('                          ');
  japan_maze[23]:=('                 - - -   - -     ');
  japan_maze[24]:=('                        ');
  japan_maze[25]:=('                 - - -   - -     ');
  japan_maze[26]:=('                       ');
  japan_maze[27]:=('                 - - -   - - -   ');
  japan_maze[28]:=('                    ');
  japan_maze[29]:=('   -             -       -       ');
  japan_maze[30]:=('                      ');
  japan_maze[31]:=('     - - - - -   -               ');
  japan_maze[32]:=('                            ');
  japan_maze[33]:=('   - - - - - - - - - - - - - - - ');
end; { init_chicago_maze }

procedure write_text (name: STRING);
var row: INTEGER;
begin
  graphcolormode;
  writeln (name);
  for row := 1 to 11 do writeln;
  writeln ('            F');
  for row := 1 to 9 do writeln;
  writeln ('   S');
end;

procedure draw_maze (any_maze: MAZE_ARRAY; colour: INTEGER);
var row, column, x, y, last_x, last_y: INTEGER;
begin
  y := 23;
  for row := 1 to 34 do
  begin
    x := 21; last_x := x;
    for column := 1 to 32 do
    begin
      x := x + 10;
      column := column + 1;
      if any_maze[row][column] = '-' then draw (last_x, y, x, y, colour);
      last_x := x;
    end;
    y := y + 10;
    row := row + 1;
  end;

  y := 23;
  for row := 2 to 33 do
  begin
    x := 21; last_y := y;
    y := y + 10;
    for column := 1 to 34 do
    begin
      if any_maze[row][column] = '' then draw (x, last_y, x, y, colour);
      x := x + 10;
      column := column + 1;
    end;
    row := row + 1;
  end;
end; { draw_maze }

procedure draw_blocks (any_maze: MAZE_ARRAY; colour: INTEGER);
var row, column, x, y, last_x, last_y: INTEGER;
begin
  y := 23;
  for row := 1 to 34 do
  begin
    x := 21; last_x := x;
    for column := 1 to 32 do
    begin
      x := x + 10;
      column := column + 1;
      if any_maze[row][column] = 'B' then draw (last_x, y, x, y, colour);
      last_x := x;
    end;
    y := y + 10;
    row := row + 1;
  end;

  y := 23;
  for row := 2 to 33 do
  begin
    x := 21; last_y := y;
    y := y + 10;
    for column := 1 to 34 do
    begin
      if any_maze[row][column] = 'B' then draw (x, last_y, x, y, colour);
      x := x + 10;
      column := column + 1;
    end;
    row := row + 1;
  end;
end; { draw_maze }

function roadblock_count (x_pos, y_pos: INTEGER; any_maze: MAZE_ARRAY):INTEGER;
var x_wall, y_wall, count: INTEGER;
begin
  x_wall := x_pos * 2; y_wall := y_pos * 2;
  count := 0;

  if any_maze [y_wall  ][x_wall-1] <> ' ' then count := count + 1;
  if any_maze [y_wall  ][x_wall+1] <> ' ' then count := count + 1;
  if any_maze [y_wall-1][x_wall  ] <> ' ' then count := count + 1;
  if any_maze [y_wall+1][x_wall  ] <> ' ' then count := count + 1;

  roadblock_count := count;
end; { roadblock_count }

function wall_count (x_pos, y_pos: INTEGER; any_maze: MAZE_ARRAY):INTEGER;
var x_wall, y_wall, count: INTEGER;
begin
  x_wall := x_pos * 2; y_wall := y_pos * 2;
  count := 0;

  if any_maze [y_wall  ][x_wall-1] = '' then count := count + 1;
  if any_maze [y_wall  ][x_wall+1] = '' then count := count + 1;
  if any_maze [y_wall-1][x_wall  ] = '-' then count := count + 1;
  if any_maze [y_wall+1][x_wall  ] = '-' then count := count + 1;

  wall_count := count;
end; { wall_count }

end. { mouse }