NetLogo banner

 Home
 Download
 Help
 Resources
 Extensions
 FAQ
 NetLogo Publications
 Contact Us
 Donate

 Models:
 Library
 Community
 Modeling Commons

 User Manuals:
 Web
 Printable
 Chinese
 Czech
 Farsi / Persian
 Japanese
 Spanish

  Donate

NetLogo Models Library:
Code Examples

(back to the library)

Moore & Von Neumann Example

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web

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 like that given here.

THINGS TO NOTICE

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

(back to the NetLogo Models Library)