Author Topic: Game of Life  (Read 1399 times)

Jordan

  • Newbie
  • *
  • Posts: 11
  • Kudos: 0
Game of Life
« on: 18 May 2003, 11:58 »
I, along with ArmTheHomeless, am taking a really dumb Visual Basic programming class. (Its the school's fault for not offering C++ or similar). We have to make a similar rendition of John Conway's Game of Life. And since I am completely unmotivated in this horrible pro-Microsoft class, I have no idea about anything. Does anyone have source code or tips, etc? Thanks-
Whine-doze = bad & evil. Its as simple as that.

Faust

  • Member
  • **
  • Posts: 1,223
  • Kudos: 0
Game of Life
« Reply #1 on: 18 May 2003, 12:38 »
This is the one where there are lots of little squares yeah?  Theres a "creature" in each square and if it has above x members it dies, if it has below y neighbours it also dies?  Find a way to represent a 2 dimensional "array" called field or something of "creatures" where creatures are a new class holding a boolean called "alive" and a function, "neighbours," that returns the number of neighbours in integer format.  Also the routines "live" and "die" to flick the boolean should be in the new class. Then have something like-

if array.item(creature).neighbours < y OR array.item(creature).neighbours > x then
  array.item(creature).die
else
  array.item(creature).live
end

If you were to loop through that every 20 seconds, and apply the if part to each seperate creature each time with a sub loop then you would be right.  Probably also a display routine in the array to show the field after each loop...  I'm sure with VB it will be a point and click afair so hopefully they have some quik and easy way to display 2D arrays, because I have no idea how (unless you make like one array for each row...)  
Yesterday it worked
Today it is not working
Windows is like that
 -- http://www.gnu.org/fun/jokes/error-haiku.html

Faust

  • Member
  • **
  • Posts: 1,223
  • Kudos: 0
Game of Life
« Reply #2 on: 18 May 2003, 12:39 »
I'm sure your teacher will be more help etcetera...
Ah stuff it I'll have a quick go tonight once I find how to make a 2D array.  
Yesterday it worked
Today it is not working
Windows is like that
 -- http://www.gnu.org/fun/jokes/error-haiku.html

Faust

  • Member
  • **
  • Posts: 1,223
  • Kudos: 0
Game of Life
« Reply #3 on: 18 May 2003, 12:41 »
Hmmm...  Just thought that if you have a straight array of 9 items that could be represented as a field by printing 3 items a line...  Then all you have to do is tell the program what neighbours what.  
Yesterday it worked
Today it is not working
Windows is like that
 -- http://www.gnu.org/fun/jokes/error-haiku.html

shuiend

  • Member
  • **
  • Posts: 250
  • Kudos: 0
    • http://stuff4fools.topcities.com
Game of Life
« Reply #4 on: 18 May 2003, 16:19 »
Well I made that in c++ a good while ago. But for vb i am not sure. If you would like the c++ source code i could look for it. Jus pm me.
you know its a bad day when you look more sober then usual

Jordan

  • Newbie
  • *
  • Posts: 11
  • Kudos: 0
Game of Life
« Reply #5 on: 18 May 2003, 20:15 »
quote:
Originally posted by wild_jester / BOB:
Well I made that in c++ a good while ago. But for vb i am not sure. If you would like the c++ source code i could look for it. Jus pm me.

That'd be great! Thank you. And thank you too Faust
Whine-doze = bad & evil. Its as simple as that.

shuiend

  • Member
  • **
  • Posts: 250
  • Kudos: 0
    • http://stuff4fools.topcities.com
Game of Life
« Reply #6 on: 18 May 2003, 21:41 »
ok this is the c++ code for it i beileve. I could not find mine so i got this from a friend. For apmatrix.h u will need to search on google for it.
http://mattnash.150m.com/Life2d.cpp

go there and downloaqd it.
you know its a bad day when you look more sober then usual

LordWiccara

  • Member
  • **
  • Posts: 138
  • Kudos: 0
    • http://imdeadinside.servehttp.com
Game of Life
« Reply #7 on: 18 May 2003, 22:44 »
the link doesnt work, it gives u an error telling u that u cant link directly to a file.

sorry, just copy and paste it into the address bar...sorry

[ May 18, 2003: Message edited by: ArmTheHomeless ]

"One World, One Web, One Program " --Microsoft AD
"Ein Volk, Ein Reich, Ein Furher" (One World, One Realm[or country], One leader) --Adolf Hitler

http://imdeadinside.servehttp.com

-Mike-