NetLogo banner
 Home Page
 Download
 Models
 Community Models
 Extensions
 User Manual:
  Web version
  Printable version
 FAQ
 Resources
 Contact Us

NetLogo Models Library:
Code Examples

(back to the library)

Moore & Von Neumann Example

[screen shot] Run Moore & Von Neumann Example in your browser
uses NetLogo 4.0.2
requires Java 1.4.1+
(system requirements)

Note: If you download the NetLogo application, every model in the Models Library (besides the Community Models) is included. If you have trouble running this model in your browser, you may wish to download the application instead.

WHAT IS IT?

This model shows how to make Moore (square) and Von Neumann (diamond) neighborhoods of any radius. The built-in primitive NEIGHBORS gives you a Moore neighborhood of radius 1, and the built-in primitive NEIGHBORS4 gives you a Von Neumann neighborhood of radius 1, but for other radii you have to use the code in this example.

There are many ways possible ways to code these neighborhoods, but the method demonstrated here was chosen because it is efficient.

THINGS TO NOTICE

World wrapping can be on or off; the same code works fine either way.

(back to the NetLogo Models Library)