tiny-life


Information

Created with NetLogo version NetLogo 3.0
Running with NetLogoLite.jar version 302.


INFORMATION


-------

COPYRIGHT


-----
Tiny-life Copyright (C) 2005 James P. Steiner

Procedures

NetLogo Version: NetLogo 3.0

;; SUMMARY
;;;;  A tiny version of Conway's Life. Click it to stop it.
;; COPYRIGHT & LICENSE
;;;; Copyright (C) 2005 James P. Steiner
;;;; Some Rights Reserved.
;;;; Creative Commons Attribution-NonCommercial-ShareAlike License v. 2.0.
;;;; Visit http://creativecommons.org/licenses/by-nc-sa/2.0/ for more information.
;; APPLET DIMENSIONS (width x height)
;;;; 149 x 161
;;
globals
[ ;; mouse-effects variables
  click?
  run-mode
]


patches-own
[ ;; model variables
  alive?
  new-status
]

to startup
   setup
   loop
   [ go ]
end

to setup
   ca
   set run-mode 1
   set click? false
   ;; model setup tasks
   setup-life
   display   
end

to go
   no-display
   go-mouse-effects
   if run-mode > 0
   [ 
     go-life
     every (30 * run-mode) [ randomize-life ]
   ]
   display
   wait 1 / 15
end

to go-mouse-effects
   ifelse mouse-down?
   [ if click? != true [ set click? true ] ]
   [ if click?  = true
     [ set run-mode run-mode + 1
       if run-mode > 1 [ set run-mode 0 ]
       set click? false
     ]
   ]
end

to setup-life
   randomize-life
end

to go-life
   ask patches
   [ let c count neighbors with [ alive? = 1 ]
     ifelse alive? = 0 
     [ if c = 3 [ set new-status 1 ] ]
     [ if c < 2 or c > 3
       [ set new-status 0 ]
     ]
   ]
   ask patches
   [ ifelse new-status = 0
     [ set pcolor black ]
     [ ifelse new-status = alive?
       [ set pcolor pcolor - 10 ]
       [ set pcolor gray ]
     ]
     set alive? new-status
   ]
end  
  
to randomize-life
      ask patches [ set alive? ifelse-value (random 100 <= 50) [ 1 ] [ 0 ] ]
end   
   

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download tiny-life --