Dark Bit Factory & Gravity

GENERAL => Challenges & Competitions => Topic started by: Tetra on June 10, 2006

Title: Short Intro Challenge - Game Of Life
Post by: Tetra on June 10, 2006
 :||

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 (http://www.tetrahedron.me.uk/GameOfLife.rar)

Code: [Select]
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

(http://www.tetrahedron.me.uk/golss.png)

 :cheers:
Title: Re: Short Intro Challenge - Game Of Life
Post by: Shockwave on June 10, 2006
Cool :)
By the way, you can make the entry legal by discarding;

Code: [Select]
Color 255,255,255

As White is the default colour :)
Title: Re: Short Intro Challenge - Game Of Life
Post by: Tetra on June 10, 2006
Yey  :D Thanks Shockwave  O0
Title: Re: Short Intro Challenge - Game Of Life
Post by: Rbz on June 10, 2006
Pretty smart, welldone :)
Title: Re: Short Intro Challenge - Game Of Life
Post by: asdflkj on June 10, 2006
Wow what's well cool, what is/are they doing?

Mark-O
Title: Re: Short Intro Challenge - Game Of Life
Post by: Shockwave on June 11, 2006
They are living, reproducing  and dying depending on the cells next to them mate :)
Title: Re: Short Intro Challenge - Game Of Life
Post by: Optimus on June 11, 2006
I love this one!