Integrating NetLogo and Java tutorial
Model was written in NetLogo 5.0.3
•
Viewed 1341 times
•
Downloaded 54 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
NETLOGO/JAVA INTEGRATION EXAMPLE
This example (a simple diffusion example) is explained in the tutorial at http://scientificgems.wordpress.com/2013/12/11/integrating-netlogo-and-java-part-1/
Comments and Questions
Click to Run Model
extensions [diffusion] globals [ grid ;; Java object with a type defined by the diffusion extension java-loop? ] patches-own [ value ;; the more advanced Java code depends on this being variable #5 ] ;; code for SETUP button to setup clear-all set java-loop? false ;; use extension reporter to set up a "clone" of the patch grid set grid (diffusion:init-grid world-width world-height min-pxcor min-pycor) ;; set up initial values in both patches and grid ask patches [ set value (random-float 9.9) if (not java-loop?) [ diffusion:set-grid-cell grid pxcor pycor value ] set-patch-color ] if (java-loop?) [ diffusion:copy-patches-to-grid grid patches ] ;; show text dump of the grid show grid ;; some turtles crt 10 [ setxy random-xcor random-ycor set shape "person" set color sky set size 4 ] reset-ticks end ;; code for GO button to go ;; perform several computation steps within the grid repeat 10 [ diffusion:diffusion-step grid 0.01 ] ;; copy modified grid data to the patches if-else (java-loop?) [ copy-grid-to-patches2 ] [ copy-grid-to-patches1 ] ;; have the turtles interact with the modified patches ask turtles [ uphill value ] tick end ;; utility method (called twice) to set a patch color from a value to set-patch-color set pcolor (30 + value) end ;; copy grid data to the patches: loop within NetLogo to copy-grid-to-patches1 ask patches [ set value (diffusion:get-grid-cell grid pxcor pycor) set-patch-color ] end ;; copy grid data to the patches: loop within Java to copy-grid-to-patches2 diffusion:copy-grid-to-patches grid patches ask patches [ set-patch-color ] end
There is only one version of this model, created almost 11 years ago by Anthony Dekker.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
diffusion.jar | extension | Required extension diffusion.jar | almost 11 years ago, by Anthony Dekker | Download |
DiffusionExtension.java | extension | Java source code for extension | almost 11 years ago, by Anthony Dekker | Download |
Integrating NetLogo and Java tutorial.png | preview | Preview for 'Integrating NetLogo and Java tutorial' | almost 11 years ago, by Anthony Dekker | Download |
This model does not have any ancestors.
This model does not have any descendants.
Anthony Dekker
Explanation
This model is associated with a tutorial at http://scientificgems.wordpress.com/2013/12/11/integrating-netlogo-and-java-part-1/
Posted almost 11 years ago