Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / (DBPRO) Conway's Game of Life

Author
Message
Starshyne Emir
7
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 4th Jan 2019 16:17
After many attempts and mistakes, I finally managed to code my own Conway's Game of Life.
This snippet has variables to store the desired ruleset and you can customize it in the code, changing the variables right at the start of it.

It will calculate all the generations at once and store them into an array - I need to work on some way to take advantage of this array after being generated
Then, it shows the result onscreen and loops it from generation 1 to generation given. Pressing spacebar will reset the simulation.



Now, one question plain and simple:

Does anyone in here know other simple cellular automata that can be useful in procedural generation, like the firespread algorithm (that I still can't make work correctly) and others? Simple examples are welcome!
God is real - except if declared as integer.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 6th Jan 2019 23:04 Edited at: 6th Jan 2019 23:05
Hi, Starshyne Emir. Its been a while. Nicely Done!

I do not have the Matrix1 Utilities installed on my system. So, I had to make some modifications to your source to get it working. DBPro complained about the color parameter of the Box function. Removed the color parameter and started getting window not responding errors. I would assume IanM's Box function uses the same DirectX method as the native DBPro Box function, as it is the most optimized method, I'm aware of. If that's the case, locking the pixel buffer is not required and the app may crash on some systems. Well, guess what! LOL.

Then, I just went crazy. I structured your source to read a little nicer. I know, I'm anal. I removed some unnecessary code and reduced the array by utilizing index zero. Also, added my missing Wrap function. Lastly, I replace the Box function with Paste Image and wow, what a increase in your drawing routine.

Sorry, I don't know much about the cellular automaton stuff. Let us know how the fire spread algorithm is going. It sounds very useful.

Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 6th Jan 2019 23:30

Is it necessary to DIM/UNDIM the array or this just a convenient way to reset the values to zero?
Send your parents to noisy sprite demo hell... enter the D-Zone
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 6th Jan 2019 23:35
Convenient way to reset the values to zero.
Starshyne Emir
7
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 11th Jan 2019 01:41
Undim arrays and dim them again is useful when you need to change the array dimensions. In old QBASIC I used REDIM, that provided a way to change array size up or down without crashing (in DBPro it crashes when dim'ing an array down).

By the way, does anyone here knows how to use SORT ARRAY commands correctly?The help files isn't very specific and the syntax seems a bit confusing - and I'd love to be able to organize array items in order, it would be useful in many, many ways...
God is real - except if declared as integer.
Bored of the Rings
User Banned
Posted: 11th Jan 2019 05:52
YES I do
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Hannibal
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 16th Jan 2019 22:26 Edited at: 17th Jan 2019 10:56
Or go totally wild, there are many ways of handling arrays

Hannibal
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 19th Jan 2019 01:08
Working version (I think)

Login to post a reply

Server time is: 2024-04-24 14:54:07
Your offset time is: 2024-04-24 14:54:07