Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Artificial Life in Rebol ?

From: greggirwin:mindspring at: 27-Dec-2002 14:48

Hi pat665, p> Is Rebol used in Articial Life? p> I don't remind seing even a simple "Game Of Life" programmed in Rebol. p> I would be interesed if anyone know a "must have" book on that matter, p> or can point me to a good place on internet to start with. At the end of this message is a very simple, incomplete, first-whack I did some time back at Conway's Game of Life. As far as books, I'm not sure about "must have" titles, but I have a couple here I like: 'Creating Artificial Life' by Edward Rietman 'Artificial Life Lab' by Rudy Rucker 'Turtles, Termites, and Traffic Jams' by Mitchel Resnick I have O'Reilly's 'Beginning Perl for Bioinformatics' by James Tisdall, which I got with the intent of seeing how REBOL could be applied, but haven't had any time to pursue it yet. REBOL should be great for creating genetic algorithms because of its dynamic nature and code/data duality. E.g. you could generate a specification that included not only the executable code, but the metadata that you could access reflectively for future mutation generation, etc. -- Gregg REBOL [ Title: {Conway's Game of Life} Author: "Gregg Irwin" Email: [greggirwin--acm--org] Version: 0.0.1 Date: 11-Mar-2002 Notes: { Only side edges wrap. Top and bottom should as well. It's very slow. I used images, rather than a separate data structure, so there may be a lot of room to speed things up. Larger images slow it down substantially. Should add some standard patterns to load as seeds. } ] get-pix: func [img [image!] loc [pair!]] [ pick img 1 + ((loc/y - 1) * img/size/x) + ((loc/x - 1) // img/size/x) ] set-pix: func [img [image!] loc [pair!] value [tuple!]] [ poke img 1 + ((loc/y - 1) * img/size/x) + ((loc/x - 1) // img/size/x) value ] config: [ img-size 32x24 ; this is our data-set image ; (128x96 64x48 32x24 16x12) view-size 256x192 ; how big is the viewer (256x192 512x384) grid-size 0x0 ] config/grid-size: divide config/view-size config/img-size neighbors: [-1x0 -1x-1 0x-1 1x-1 1x0 1x1 0x1 -1x1] on-color: white off-color: black on-ct: 0 cell: 0x0 img: make image! config/img-size alt-img: copy img do-gen: func [img alt-img] [ repeat row img/size/y [ repeat col img/size/x [ cell: to-pair reduce [col row] foreach offset neighbors [ if on-color = get-pix img cell + offset [on-ct: add on-ct 1] ] either off-color = get-pix img cell [ set-pix alt-img cell either on-ct = 3 [on-color][off-color] ][ set-pix alt-img cell either any [on-ct = 2 on-ct = 3][on-color][off-color] ] on-ct: 0 ] ;world/effect: compose [ ; fit grid (config/grid-size) emboss ; gradcol (random 255.255.255) (random 255.255.255) first random neighbors ; blur blur blur ;] ] alt-img ] view layout [ world: image img config/view-size effect compose/deep [fit grid (config/grid-size)] ;gradcol (blue) (green)] return button "seed" [ random/seed now/precise repeat i divide length? img 16 [ poke img random divide length? img 4 on-color ] show world ] button "go" [ forever [ world/image: do-gen img alt-img tmp: img img: alt-img alt-img: tmp show world wait 0.05 ;if equal? img alt-img [ ; alert "Done!" ; break ;] ] ] button "Quit" [quit] ]