Jump to content



Photo

Conway's Game Of Life


  • Please log in to reply
6 replies to this topic

#1 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 03 June 2009 - 11:44 AM

Well, I looked around for this elsewhere but only found an implementation using asterisks and spaces. It didn't update too good either. I made this in a spare hour today; thought I'd throw it out there for fun.

The code can be downloaded from HERE.

It's not a complete work by any means. Ideally there'd be an associated UI and the ability to set your own starting pattern. Use the Global Const to make changes as required. Beware that it sucks CPU if you set the $timerDelay down too low.

Have fun.

WBD

EDIT: 4-June-2009
You now have the ability to set your own starting pattern which you can draw with the mouse.
Press "R" to set a random pattern
Press "C" to clear the pattern
Press "F5" to run the pattern

Edited by WideBoyDixon, 04 June 2009 - 10:54 AM.








#2 Triblade

Triblade

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 388 posts

Posted 03 June 2009 - 03:50 PM

Allways fun to watch something like this :D

They stopped moving after a minute or two. Aww, they died.. :D ;)

#3 crashdemons

crashdemons

    What Avatar?

  • Active Members
  • PipPipPipPipPipPip
  • 495 posts

Posted 03 June 2009 - 05:34 PM

By the way:
An example of a modified "Game of Life" visualization is present in YahELite's "/egg 2" command. [If in doubt, check the credits for YahELite, Conway is listed :D ]

[SS]Posted Image
Quite a strange and psychedelic display.

I'm also tempted to try something similar, but we'll see how much free time I have first.

Edit: I found This page containing an applet for another implementation. (Source available)
Edit: and this.

Edited by crashdemons, 03 June 2009 - 06:10 PM.

Posted ImageMy Projects -WindowDarkenPosted Image (Darken except the active window)Yahsmosis Chat Client (Discontinued)StarShooter GamePosted Image (Red alert! All hands to battlestations!)YMSG Protocol Support (Discontinued)Circular Keyboard and OSK example. (aka Iris KB)Target ScreensaverDrive Toolbar ThingyRollup ProPosted Image (Minimize-to-Titlebar & More!)2D Launcher physics exampleAscii ScreenshotAutoIt3 Quine Example ("Is a Quine" is a Quine.)USB Lock (Another system keydrive - with a toast.)

#4 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 04 June 2009 - 10:55 AM

Updated. See the first post for details. It's also a little more efficient (hopefully) on the drawing code since it doesn't draw cells that haven't changed from one iteration to the next.

WBD

#5 UEZ

UEZ

    Never say never

  • MVPs
  • 3,616 posts

Posted 04 June 2009 - 11:08 AM

Looks really nice WBD. I had this always in mind to code GoL, too!

Personally the grid color is too bright. It looks better when it set darker, e.g. Global $hPen = _GDIPlus_PenCreate(0x7F3F3F3F) (my subjective opinion).

Keep your good work up!


UEZ

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#6 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 04 June 2009 - 11:29 AM

UEZ I think you're right about the grid. The other thing I never mentioned about the code is the function to create an angled gradient line brush; I haven't seen this elsewhere so perhaps it might be useful to someone.

WBD

#7 UEZ

UEZ

    Never say never

  • MVPs
  • 3,616 posts

Posted 04 June 2009 - 12:00 PM

Of course I recognized the gratient line brush :D

UEZ

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users