Hampton Court Maze NetLogo Model

Produced for the book series "Artificial Intelligence";

Author: W. J. Teahan; Publisher: Ventus Publishing Aps.

powered by NetLogo

view/download model file: Hampton-Court-Maze.nlogo

WHAT IS IT?

This model draws a schematic of the Hampton Court Palace maze in the United Kingdom. The entrance is at the middle bottom of the maze, and the goal is to get to the centre.


THE INTERFACE

The setup-hampton-court-maze button will redraw the maze.

The sliders are defined as follows:
- row-patches-width : the width between horizontal walls in the maze;
- col-patches-width : the width between vertical walls in the maze.


HOW IT WORKS

It uses one ask patches command to set the patches blue that define the walls, and to set the remaining patches white. The code uses two procedures that are similar, setup-row and setup-col, to draw the walls in a horizontal row or vertical column respectively. These procedures take the row or column number as the first parameter, the colour that the walls are to be drawn with, and a list containing two-numbered range lists that define the segments where the walls are to be drawn in the row or column.


HOW TO USE IT

You can't really use it for anything, except for changing the values in the sliders to create different sized mazes. To have the model draw the maze, press the setup-hampton-court-maze button.


WHAT IS ITS PURPOSE?

Its purpose is to create a virtual maze that has a corresponding maze in real-life to demonstrate how virtual environments can mirror real-life environments but where the reflection can often be distorted in the process.


THINGS TO TRY

See what happens when you change the value of the sliders.

Try changing the Settings of the environment such as the Patch size and the maximum and minimum x and y co-ordinates.


EXTENDING THE MODEL

Try adding a turtle agent to move around the maze.


RELATED MODELS

See the Empty Maze and Chevening House Maze models.


CREDITS AND REFERENCES

To refer to this model in publications, please use:

Teahan, W. J. (2010). Hampton Court Maze NetLogo model.
Artificial Intelligence. Ventus Publishing Aps.


PROCEDURES

; Hampton Court Maze model.
; 
; Draws a schematic map of the Hampton Court Maze.
;
; Copyright 2010 William John Teahan. All Rights Reserved.
;
        
to setup-row [row colour segments]
  foreach segments
  [
      if pycor = row * row-patches-width and
        (pxcor >= col-patches-width * (item 0 ?)) and (pxcor <= col-patches-width * (item 1 ?))
          [set pcolor colour]
  ]
end

to setup-col [col colour segments]
  foreach segments
  [
      if pxcor = col * col-patches-width and
        (pycor >= row-patches-width * (item 0 ?)) and (pycor <= row-patches-width * (item 1 ?))
          [set pcolor colour]
  ]
end

to setup-hampton-court-maze
  ca ;; clear everything
  
  ask patches
  [
      if (pxcor >= min-pxcor and pxcor <= max-pxcor and
        pycor >= min-pycor and pycor <= max-pycor)
          [set pcolor white] ;; make background full of white patches
      
      setup-row  5 blue [[-9 10]]
      setup-row  4 blue [[-8 -5] [-3 -1] [0 3] [5 9]]
      setup-row  3 blue [[-7 -4] [-2 2] [4 8]]
      setup-row  2 blue [[-6 -1] [1 4] [5 7]]
      setup-row  1 blue [[-3 3] [8 9]]
      setup-row  0 blue [[-8 -7] [9 10]]
      setup-row -1 blue [[-9 -8]]
      setup-row -2 blue [[-8 -7] [-3 0] [1 3]]
      setup-row -3 blue [[-4 -1] [2 4] [6 8]]
      setup-row -4 blue [[-7 -1] [1 9]]
      setup-row -5 blue [[-8 10]]
      setup-row -6 blue [[-9 0] [1 10]]

      setup-col 10 blue [[-6 5]]
      setup-col  9 blue [[-4 -1] [1 4]]
      setup-col  8 blue [[-3 1] [2 3]]
      setup-col  7 blue [[-2 2]]
      setup-col  6 blue [[-4 1]]
      setup-col  5 blue [[-3 2]]
      setup-col  4 blue [[-3 2] [3 5]]
      setup-col  3 blue [[-2 1] [2 4]]
      setup-col  1 blue [[-4 -2]]
      setup-col  0 blue [[-5 -2] [1 3]]
      setup-col -1 blue [[-4 -3] [4 5]]                  
      setup-col -3 blue [[-2 1] [2 4]]
      setup-col -4 blue [[-3 2] [3 5]]
      setup-col -5 blue [[-4 1]]
      setup-col -6 blue [[-3 2]]
      setup-col -7 blue [[-4 -3] [-2 0] [1 3]]
      setup-col -8 blue [[-5 -2] [0 4]]
      setup-col -9 blue [[-6 5]]
  ]
end
;
; Copyright 2010 by William John Teahan.  All rights reserved.
;
; Permission to use, modify or redistribute this model is hereby granted,
; provided that both of the following requirements are followed:
; a) this copyright notice is included.
; b) this model will not be redistributed for profit without permission
;    from William John Teahan.
; Contact William John Teahan for appropriate licenses for redistribution for
; profit.
;
; To refer to this model in publications, please use:
;
; Teahan, W. J. (2010).  Hampton Court Maze NetLogo model.
;   Artificial Intelligence. Ventus Publishing Aps
;