Empty Maze NetLogo Model

Produced for the book series "Artificial Intelligence";

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

powered by NetLogo

view/download model file: Empty-Maze.nlogo

WHAT IS IT?

This example sets up an empty "maze" which is a maze with only external walls, and with an entrance and exit at the middle bottom and middle top.


THE INTERFACE

The setup-empty-maze button will redraw the maze.

The sliders are defined as follows:
- left-cols : width of the horizontal walls drawn to the left of the entrance/exit;
- right-cols : width of the horizontal walls drawn to the right of the entrance/exit;
- above-rows : height of the vertical walls drawn above the row at y = 0;
- below-rows : height of the vertical walls drawn below the row at y = 0.


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.


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-empty-maze button.


WHAT IS ITS PURPOSE?

Its purpose is to show how easy it is to use patch commands to define the environment.


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 changing the maze so that the entrance and exit are elsewhere.

Try adding a turtle agent to move around the maze.


RELATED MODELS

See the Hampton Court Maze and Chevening House Maze models.


CREDITS AND REFERENCES

To refer to this model in publications, please use:

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


PROCEDURES

; Empty Maze model
; 
; Draws an empty maze with entrance at middle bottom and exit
; at middle top.

; Copyright 2010 William John Teahan. All Rights Reserved.
 
to setup-empty-maze
  ca ;; clear everything
  
  ask patches
  [
    set pcolor white ;; make background full of white patches
          
    if (pxcor >= (- left-cols - entrance-cols) and pxcor <= (- entrance-cols) and
        pycor = (- below-rows))
      [set pcolor blue] ;; draws bottom left horizontal wall in blue

    if (pxcor >= (entrance-cols) and pxcor <= (right-cols + entrance-cols) and
        pycor = (- below-rows))
      [set pcolor blue] ;; draws bottom right horizontal wall in blue

    if (pxcor >= (- left-cols - entrance-cols) and pxcor <= (- entrance-cols) and
        pycor = (above-rows))
      [set pcolor blue] ;; draws top left horizontal wall in blue

    if (pxcor >= (entrance-cols) and pxcor <= (right-cols + entrance-cols) and
        pycor = (above-rows))         
      [set pcolor blue] ;; draws top left horizontal wall in blue

    if (pxcor = (- left-cols - entrance-cols) and
        pycor >= (- below-rows) and pycor <= (above-rows))
      [set pcolor blue] ;; draws left vertical wall in blue
      
    if (pxcor = (right-cols + entrance-cols) and
        pycor >= (- below-rows) and pycor <= (above-rows))
      [set pcolor blue] ;; draws right vertical wall in blue
  ]
end
;
; Copyright 2009 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).  Empty Maze NetLogo model.
;   Artificial Intelligence. Ventus Publishing Aps
;