Author Topic: Short Intro Challenge - Game Of Life  (Read 4973 times)

0 Members and 1 Guest are viewing this topic.

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Short Intro Challenge - Game Of Life
« 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

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



 :cheers:
« Last Edit: June 10, 2006 by Tetra »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Short Intro Challenge - Game Of Life
« Reply #1 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 :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Short Intro Challenge - Game Of Life
« Reply #2 on: June 10, 2006 »
Yey  :D Thanks Shockwave  O0
« Last Edit: June 10, 2006 by Tetra »
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Short Intro Challenge - Game Of Life
« Reply #3 on: June 10, 2006 »
Pretty smart, welldone :)
Challenge Trophies Won:

Offline asdflkj

  • C= 64
  • **
  • Posts: 45
  • Karma: 2
    • View Profile
Re: Short Intro Challenge - Game Of Life
« Reply #4 on: June 10, 2006 »
Wow what's well cool, what is/are they doing?

Mark-O

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Short Intro Challenge - Game Of Life
« Reply #5 on: June 11, 2006 »
They are living, reproducing  and dying depending on the cells next to them mate :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Re: Short Intro Challenge - Game Of Life
« Reply #6 on: June 11, 2006 »
I love this one!
Challenge Trophies Won: