Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: coolsnake on September 08, 2010, 10:30:09 am

Title: Procedural generation
Post by: coolsnake on September 08, 2010, 10:30:09 am
I've taken an interest in procedural generation lately. More specifically for the generation of areas in space.

Here's a snippet from wikipedia:

"The earliest computer games were severely limited by memory constraints. This forced content, such as maps, to be generated algorithmically on the fly: there simply wasn't enough space to store a large amount of pre-made levels and artwork. Pseudorandom number generators were often used with predefined seed values in order to create very large game worlds that appeared premade. For example, The Sentinel supposedly had 10,000 different levels stored in only 48 or 64 kilobytes. An extreme case was Elite, which was originally planned to contain a total of 248 (approximately 282 trillion) galaxies with 256 solar systems each."
http://en.wikipedia.org/wiki/Procedural_generation

I tried to do the same thing in TI-Basic. If my math is right, the size of the universe I've created on my calculator is in the magnitude of ~10^40 calc screens.
I did this by using the pseudorandom number generator of the calculator and by using predefined seed values.
The downside is, they aren't unique.
In other words, I want my calc-universe to be made up of unique calc screens only, I don't want to come through the same screen twice.
I've been thinking of a way to make this happen, but I didn't find one. Does anyone have an idea?

I've added the universe thing as "space2d.8xp". I did a quick optimisation with sourcecoder and the code itself could probably be more optimised but that isn't my main concern right now.
I've also included the individual subroutines in source.zip

ENGIN is the main game loop.
COLLIS checks for when you reach the edge of the screen and updates the X,Y coordinates, generates new seeds
NUMBERS puts the seeds into rand and generates a pseudorandom number from which the stars are generated.
CONV converts the pseudorandom number into individual numbers. e.g 123 becomes 1, 2 and 3.
COORD uses the individual numbers to generate the coordinates for each individual star while also providing collision detection.
Title: Re: Procedural generation
Post by: DJ Omnimaga on September 08, 2010, 01:32:09 pm
I tried doing dungeon randomizing in BASIC before but it seemed pretty hard. I never could figure out a good algorithm to draw walls without ending up with a dead end or something. It would be nice to see such game in BASIC, providing it runs fast enough. Also walls would have to be stored somewhere like strings, matrices, etc, to ensure fast collision detection (should be possible to do at least 3 frames per second unless there are plenty of enemies moving around)
Title: Re: Procedural generation
Post by: matthias1992 on September 08, 2010, 04:31:10 pm
A vastly intresting topic, not something I have experience in though. Reminds me of borderlands (a game) with its procedural gun generating system to make over 17.5 million guns (according to the last official count). Yep that is more then CoD has :P
Title: Re: Procedural generation
Post by: DJ Omnimaga on September 08, 2010, 04:33:07 pm
Yeah I noticed that game has so many x.x it's insane. I dislike how you need to be a certain level to use most, though. I miss the days where it was possible to 1-hit kill bosses at low level when you got powerful weaponds ;D
Title: Re: Procedural generation
Post by: meishe91 on September 08, 2010, 09:08:46 pm
This is really interesting. I'll check out your code and look into it. This is interesting :)