rebol [ title: "Generator of Life" version: 0.0.4 date: 14-Oct-2005/20:11:47+2:00 author: "oldes and cyphre" type: 'graphic Purpose: "A colorful cellular automata." ] img-size: 320x320 ;160x160 random/seed now px: to-integer img-size/x / 2 py: to-integer img-size/y / 2 isx: img-size/x isy: img-size/y img: make image! img-size view/new layout [origin 0 im: image img ] pixels: isx * isy noise: rebcode [/local c] [ repeat p pixels [ set c 16777215 randz c poke img p c ] ] setPixel: rebcode [img x y clr] [ set.i p isx mul.i p y add.i p x poke img p clr ] newDirection: rebcode [] [ set dx 3 randz dx sub.i dx 1 set dy 3 randz dy sub.i dy 1 ] cango?: rebcode [x y] [ glt.i x 0 isx iff [return false] glt.i y 0 isy iff [return false] return true ] live: rebcode [] [ apply r newDirection [] add.i x dx add.i y dy apply r cango? [x y] sett r either [ ;can go apply r setPixel [img x y c] ][ sub.i x dx sub.i y dy ] ] heartbeat: rebcode [] [ head bunky until [ pick x bunky 1 next bunky pick y bunky 1 next bunky pick p bunky 1 next bunky pick c bunky 1 next bunky ;print [x y c] apply r live [] skip bunky -4 change bunky x 1 next bunky change bunky y 1 next bunky change bunky p 1 next bunky change bunky c 1 next bunky tail? bunky ] ] bunek: 5000 bunky: make image! as-pair (4 * bunek) 1 initbunky: rebcode [/local x y p c] [ head bunky loop bunek [ set c 16777215 randz c set x isx randz x set y isy randz y set p isx mul.i p y add.i p x change bunky x 1 next bunky change bunky y 1 next bunky change bunky p 1 next bunky change bunky c 1 next bunky ] head bunky ] initbunky while [not empty? system/view/screen-face/pane] [ heartbeat show im wait 0.001 ]