• Welcome to Dark Bit Factory & Gravity.
 

Short Intro Challenge - Game Of Life

Started by Tetra, June 10, 2006

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Tetra

 :||

Thought i'd get the ball rolling with this one. Here's my first entry, although its already disqualified as I have 21 lines of codeÃ,  :'(
and thats with using
If <statement> then doThis() else doThat()Ã,  Ã, >:DÃ,  no colon :P

I could infact squash more onto an if statement line but it starts getting messy, for the sake of Flip and Cls using up a whole 2 linesÃ,  :whack:

Its not my idea at all but that of John Conway, who it the mathematician that came up with this great little system in 1970.

I wrote it in blitz, and it run the same way every time. I would have added SeedRnd Millisecs() but that was taking up a precious line!

Download code and exe: www.tetrahedron.me.uk/GameOfLife.rar


Graphics 640,480,32,2

Dim Lives(126,96,2)

For i = 0 To 9876
Lives( Rand(123)+1, Rand(93)+1, 0 ) = 1
Next

SetBuffer( BackBuffer() )

While Not KeyDown(1)

For x = 1 To 124
For y = 1 To 95
cell = ( Lives( x-1, y, 0 ) + Lives( x+1, y, 0 ) + Lives( x, y-1, 0 ) + Lives( x, y+1, 0 ) + Lives( x-1, y-1, 0 ) + Lives( x+1, y+1, 0 ) + Lives( x-1, y+1, 0 ) + Lives( x+1, y-1, 0 ) )
If ( cell = 3 )Or( cell + Lives( x, y, 0 ) = 3) Then Lives( x, y, 1 ) = 1 Else Lives( x, y, 1 ) = 0
Next
Next


For x = 0 To 125 * 95
Lives( (x Mod 125), (x / 125), 0 ) = Lives( (x Mod 125), (x / 125), 1 )
If Lives( (x Mod 125), (x / 125), 0 ) Then Rect (x Mod 125) * 5, (x / 125) * 5, 4,4
Next

Flip
Cls
Wend




:cheers:
Challenge Trophies Won:

Shockwave

Cool :)
By the way, you can make the entry legal by discarding;


Color 255,255,255


As White is the default colour :)
Shockwave ^ Codigos
Challenge Trophies Won:

Tetra

#2
YeyÃ,  :D Thanks ShockwaveÃ,  O0
Challenge Trophies Won:

Rbz

Challenge Trophies Won:

asdflkj

Wow what's well cool, what is/are they doing?

Mark-O

Shockwave

They are living, reproducing  and dying depending on the cells next to them mate :)
Shockwave ^ Codigos
Challenge Trophies Won:

Optimus

Challenge Trophies Won: