Giter Site home page Giter Site logo

Comments (10)

bkloster avatar bkloster commented on September 10, 2024

I'd like the game to be pretty deterministic, given a particular seed value. Otherwise, reliably reproducing bugs or other problems could become a nightmare.

To achieve determinism, we need to ensure that all events happen in the same order so that the random numbers related to those events are always the same. That means that we need at least two RNGs. One for generating random timer values and another one for generating the rest. The separate RNG for timers should guarantee that events happen in the same order (providing equal player input).

Related to determinism is the question of how the RNG seeds are handled by savegames. Repeatedly loading a savegame should always produce the same result (until the player input diverges). The easiest way to achieve that would be the following procedure when saving the game:

  1. Generate a new, random seed S
  2. Write S into the savegame
  3. Before resuming the game, reseed all RNGs based on S (obviously not with S itself, all RNGs need a different seed)

Loading essentially repeats step 3. A likely weak point of this approach is that the player could repeatedly save the game, each time generating a new S and potentially changing the outcome of the game.

from thrive.

jjonj avatar jjonj commented on September 10, 2024

I'm not sure i understand the need for two RNGs like that, could you do a quick case where a single RNG would fail to be deterministic?

And regarding save-games i would personally prefer as a player that games play out differently when i load, it's not a big deal in a pure singleplayer game. Your solution is nice, but has the problem you mentioned that i don't see a good solution to. Perhaps limiting how frequently you can save~

from thrive.

bkloster avatar bkloster commented on September 10, 2024

could you do a quick case where a single RNG would fail to be deterministic?

Of course... umhhh.... uhhhh... nevermind, one RNG is actually enough. For some reason, I thought that a single RNG plus randomized timer values would lead to different orders. Which I now realize is not the case.

And regarding save-games i would personally prefer as a player that games play out differently when i load

Depending on gameplay, non-deterministic savegames can be a tool for cheating. For example, the player found a thingamajig that will give him a random reward. The possible rewards range from useless to limited edition IWIN buttons. The player can save before gathering the reward, and repeatedly reload the game if it isn't good enough. (Here's where separate RNGs can be useful to prevent the player from manipulating the chances by changing up the input)

As I said, it is highly dependant on other design decisions whether this kind of "cheating" can actually become a concern. If we go with non-determinism, we definitely need to keep that in mind in the future.

Perhaps limiting how frequently you can save~

Maybe allow the players to save however often they want, but only generate a new seed if the last save is at least 10 seconds or so old.

from thrive.

jjonj avatar jjonj commented on September 10, 2024

But if you don't generate a new seed for a new save you would still get completely different result every time you load (unless you actually replay the last 10 seconds of gameplay to pull out the 'already-used random numbers)

from thrive.

patowen avatar patowen commented on September 10, 2024

In my opinion, quick saving and closing without saving is in itself a form of cheating (unless the game crashes or the computer loses power). While we shouldn't necessarily disallow the user from cheating in this way, we also should avoid planning around that. It's too much work for relatively little gain. If a player wants to cheat, let him cheat. The game is open-source, anyway.

In short, the question of whether to generate a new seed each time the game is loaded again should be based on which is more efficient or easier to do.

from thrive.

jjonj avatar jjonj commented on September 10, 2024

I agree with patowen about cheating, especially because i doubt there will be very much to gain by cheating this way. Sure you can try to use it for saving your lifeform/civilization but in that situation you would load a save anyway and play the game out differently.

Altough it i still think it is a good idea to generate new seeds every time the game is saved, to avoid some wierd behavior.

from thrive.

bkloster avatar bkloster commented on September 10, 2024

If a player wants to cheat, let him cheat.

That's actually a compelling argument. Point taken, no contortions to maintain determinism.

Altough it i still think it is a good idea to generate new seeds every time the game is saved, to avoid some wierd behavior.

Such as? I mean, generating a new seed is pretty much free compared to the heavy lifting of serializing all the components, but I'm curious what could go wrong when we don't generate a new seed.

Edit: By the way, what's the getRandom(vector) function supposed to do?

from thrive.

jjonj avatar jjonj commented on September 10, 2024

Such as

I was thinking that you would have to re-seed the RNG when loading a game, but i realize that this is only necessary if you want replay functionality so nvm~

By the way, what's the getRandom(vector) function supposed to do?

Was just thinking it would be a function making it easier to get a random element from a vector. Obviously not necessary.

from thrive.

jjonj avatar jjonj commented on September 10, 2024

Places in code to update to use RNGManager once complete - Please comment if you know more:

  • AgentEmitter in agent.cpp
  • Microbe in microbe.lua using rng for distributing agents
  • SpawnSystem (if done before this)

from thrive.

bkloster avatar bkloster commented on September 10, 2024

Closed with 7cea397

from thrive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.