• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Hawkblood

Reversing a procedural generation

31 posts in this topic

This is a SUPER SIMPLE random number generator:

int RNSeed=12345;
int randomnum(void){
	RNSeed=abs(RNSeed*8786545643)%987654321;
	return RNSeed;
}

With this initial seed, the first time it's called it results in 770159010, and the second time it results in 808599291.

This will happen EVERY time I start with 12345. The problem with reversing the calculation is the modulus of 987654321. Any seed value greater than that number will be some value that can't be found and therefore the previous seed us unknown. The solution would involve a random number generator that can be reversed-- I don't know how to make that (or if it can be made at all).

 

All of you are either think I don't know how random generators work or you are missing my point entirely.

 

The modulus IS the problem with the whole thing...  It means that you have lost some piece of the information.  You can go one way, you can even go back, BUT which of the UNLIMITED number of combinations is the right one?  Oh shoot!  You can't go back anyway...

2

Share this post


Link to post
Share on other sites

You will need a change patch log system to record all the subsequent changes for the direct and indirect object your procedural system will initially create.   The changes get added ontop of the procedurally generated initial data set whenever the area is rebuilt.

 

Some changes will be trivial and not need to be added to the patch log. (like bullet hole decals that the elves come and cleanup while player isnt watching)

 

Some changes may themselves be a 'procedural' generation (ie- a pattern a fire event spreads) and alot of 'sub' detail might be expressed in only a small amount of patch data.

 

Some changes may 'heal' over time (possibly since some player last saw it)  and be able to eventually be removed from the patch log (reverting the change back to the initial generation state)

 

Some dynamic changes created 'on the fly' to match a game situation  may be regrouped/nullified and regenerated newly when the area is rebuilt (matching a newer game situation).

 

Sometimes its possible (depending on game mechanics) to have catastrophic events periodicly overwhelm a location and wipe clean/consume  more than a few accumulated changes.

 

Many times a procedural generation cycle is based on more than just a random number and additional information used in activating its 'subprocedures'  will also have to be saved.

 

Sometimes there are 'in the area' significant objects whichhave been custom built (with too many variable attributes and states) and they have to be preserved with much greater detail saved. 

 

Some world systems mutate (faction entities with spheres of influence move around, or seasonal variations) and areas can rebuild somewhat differently and any change log data may have to be checked/arbitrated if their are dependencies that cause them to mutate (or become irrelevant)

0

Share this post


Link to post
Share on other sites

This is a SUPER SIMPLE random number generator:
//...snip...

With this initial seed, the first time it's called it results in 770159010, and the second time it results in 808599291.
This will happen EVERY time I start with 12345. The problem with reversing the calculation is the modulus of 987654321. Any seed value greater than that number will be some value that can't be found and therefore the previous seed us unknown. The solution would involve a random number generator that can be reversed-- I don't know how to make that (or if it can be made at all).


Maybe I'm misunderstanding your original question, but I thought you were wanting to reverse player actions, and the effects of a complex system being fed with input data that comes from player actions.

Players aren't random number generators. You can't reverse player actions backwards, because you can't predict player actions forward. Instead, you save the result of those actions (the current game state) or save the actions themselves (like undo/redo frameworks), and re-apply them later.

"This process could be very useful in games that have a huge amount of "object states". Like a planet with mineral deposits. If the player collects a certain amount of them, it would be silly for the player to be able to come back to the planet and get those deposits again. And saving the state of each mineral deposit on every planet in every solar system would be crazy!"

Every object state is either generated solely by the simulation (procedural generation, later simulations that aren't affected by the game world, ...), prefabricated by the developer (manually made maps and game events, even some of the pre-written code and scripts), resulting from direct player actions (my character has blue eyes, I choose to mine this ore deposit), or affected by the complex simulation that is fed input from player actions, the passage of time, and other inputs (Enemy223 lobs a grenade in direction XYZ at Ally17 because the player told Ally17 to guard the mobile Entity452 which wandered in that direction because it needs sunlight for power and the weather simulation was cloudy at that point in time).

The isolated simulations (procedural generation, and self-contained non-influenced simulations like weather systems) can be re-simulated.
The prefabricated data must be reloaded, and cannot be generated (though theoretically you could use really good compression and pattern-matching to semi-generate parts of it, or maybe even to lossy-generate the whole imperfectly).
The player actions must be saved and re-applied or else the result of those actions (just the states you care about).
The complex whole simulation cannot be re-ran, unless the above three areas are also precisely reran (with recorded player actions, not just recorded results).

Edited by Servant of the Lord
0

Share this post


Link to post
Share on other sites
The main reason I started this post was to flesh out an idea to limit save game data for a huge scale game. I think I would like to have a "player profile" instead of a save game. I would create a seperate file for each solar system (or something like that) and save it with some standard convention within the player profile folder.....
0

Share this post


Link to post
Share on other sites

I think this might actually be possible without having to save a bunch of states for the window. What you need is some kind of "random.previous" function (as opposed to the traditional "random.next" function found in most languages). However as far as I know no programming language supports this. I would recommend programming your own PRNG from scratch for this task. Assign each window it's own random class and once it needs to be put back together just throw the PRNG in reverse.

0

Share this post


Link to post
Share on other sites

Be sure you carefully review the limitations of any compression algorithm you consider. Some compression schemes can be lossy (jpeg); some (lossless) preserve the original data.

1

Share this post


Link to post
Share on other sites

I think this might actually be possible without having to save a bunch of states for the window. What you need is some kind of "random.previous" function (as opposed to the traditional "random.next" function found in most languages). However as far as I know no programming language supports this. I would recommend programming your own PRNG from scratch for this task. Assign each window it's own random class and once it needs to be put back together just throw the PRNG in reverse.

 

Any where exactly are you planning to get the random number to reverse from, given the existing game state?

 

Plus of course any random number generator using a modulus can't have a previous method, since data is lost at each iteration.

Edited by Aardvajk
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0