Deterministic Behavior... is it possible?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello!

    As title says, I wonder if it's possible for a Clickteam Fusion Game to have a deterministic behavior, i.e., if I set the randomize seed to a fixed value at the "Start of Frame" , the game should behave exactly in the same way.
    I removed everything that's time based and I'm using a frame counter. Also, I set vsync on and set the frame rate to 30 fps. Any thoughts?


    Thanks for your time.

  • I can attest to a manual seed not generating the same thing every time. I generate a massive gameworld at random, and tried finding a level generation crash by inputting a manual seed instead of a random one, and thus regenerate the same world every time, to be able to analyze from a debug document what was generated. Even with a manual seed the gameworld is not generated in exactly the same way, albeit fairly similar.

    So let me explain: I generated random seed in start menu, and furthermore did not affect the random seed generator once the frame was changed to the "gameplay" frame. I printed out the seed every time, and regenerated levels until I got a crash, then I manually wrote down the seed that I had displayed on the screen at the time of the crash, inputted this seed manually into fusion, instead of randomizing the seed, and most of the time the world would not crash with that seed. In my mind this must mean that the output was not the same, even though the randomizer seed was unchanged.

  • In my mind this must mean that the output was not the same, even though the randomizer seed was unchanged.

    That's probably not correct in terms of the random numbers generated. A crash could be from memory that's not always initialised correctly. C/C++ doesn't require the code to set the initial value of variables, so it'll inherit whatever the last program using that section of RAM left there. Freeing or creating memory without consistent initialization will make an occasional crash.

    As an aside, if you put latest version of DebugObject in frame, it can often tell you what extension is causing the crash.

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • That's probably not correct in terms of the random numbers generated. A crash could be from memory that's not always initialised correctly. C/C++ doesn't require the code to set the initial value of variables, so it'll inherit whatever the last program using that section of RAM left there. Freeing or creating memory without consistent initialization will make an occasional crash.

    I am not entirely sure what you meant, but sounds like you meant there is some sort of memory reading difference that could cause the crash, even though the events are the same.

    Quote

    As an aside, if you put latest version of DebugObject in frame, it can often tell you what extension is causing the crash.

    I don't use any extensions though, except mouse object and window control object.

  • I don't use any extensions though, except mouse object and window control object.

    Alright, so pop it in and see what it says. You could get a popup like this:

    Please login to see this picture.

    As you see it shows it was Box2D in this case.

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • Alright, so pop it in and see what it says. You could get a popup like this:

    Please login to see this picture.

    As you see it shows it was Box2D in this case.

    I am sorry, thank you for the tip. I will definitely be checking out this debugging tool, just because yay to debugging. I was just explaining my experience with the random seeding. I don't actually have the crashing problem anymore with my level generation, or at least I think so. I have different biomes in my game, and one I think crashed due to sheer number of objects during generation, but I have changed it now to be less and the crash seems to have disappeared. I didn't even do it out of necessity, it ended up being a better map type, gameplay-wise. So I never had to look into it that hard. But I for sure loaded a frame that crashed previously, using the same seed. I am sorry, I didn't really understand your other explanation about memories and stuff.

  • In my current project, it generates a large procedurally generated map, locations, and "ad-lib" flavour text from a seed value. I can attest that in my project at least, if I use the same seed, everything is always the same!

    I use the randomizer object to generate a seed (Ultimately, the user can input their own seed value if they want as well), and then use the "randomize" special action to use that seed for Clickteam's randomizer

    The top (deactivated) line is how I manually set the seed for debugging. the bottom one is how I generate it.

    Once the world and everything is generated, I will randomize the seed again, I suppose, because I don't want outcomes for combat rolls and other chance based player actions to be the same every time.

    Later when the user is able to set their own random seed value, I have a little algorithm that converts whatever they type into a number, and then puts that value into the "set randomizer seed" seen in the deactivated line below:


    Please login to see this attachment.

  • The important thing to remember when using seeds and random generation is that only random actions that is the same AND runs in the same order will turn out the same way.

    So for example if set seed to 123, then do random(5), and random(70), these will always turn out the same.

    BUT if instead does set seed to 123, then do random(13) and random(70), these will turn out different, since the random actions and/or the order is different.

    So to get deterministic results, both the order and content of each random action must be the same, otherwise the result will differ.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!