Stop Microsoft
Miscellaneous => Programming & Networking => Topic started by: Jordan 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-
-
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...) (http://smile.gif)
-
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. (http://smile.gif)
-
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. (http://smile.gif)
-
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.
-
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
-
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 (http://mattnash.150m.com/Life2d.cpp)
go there and downloaqd it.
-
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 ]