-
Notifications
You must be signed in to change notification settings - Fork 61
New extension: Pseudo random #1645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting an extension. Extensions are meant to be editable by anyone. This means that:
|
!update PseudoRandomExtension.zip |
✅ Successfully updated the extension. |
Hi Davy @D8H, I replaced the minified library code with the non-minified one and added the repository link to the extension description, thanks. |
|
The Math.random() function is overridden only in the visibility zone after calling seedrandom(), that is, in the event where it is called and in subevents, in the rest of the game Math.random() works as before (randomly), usually I use it only once when starting a scene to build a level and the rest of the game works as before. |
I didn't quite understand the question, but neither the sound reproduction nor the creation of particle emitters affected the game's reproductive ability. |
!update PseudoRandomExtension.zip |
❗ No updates found. Please check your file. |
!update PseudoRandomExtension.zip |
❗ No updates found. Please check your file. |
!update PseudoRandomExtension.zip |
✅ Successfully updated the extension. |
I moved the repository link from the description to the js comment |
Hi Davy @D8H, I updated the example by adding random value generation next to pseudo random values, this can also be combined into one event if necessary, but then it will be unclear when which sound plays |
Yes, it can break certain processes in your game if you call "set seed" for the whole scene or the whole game, but you can easily control it by calling it only in one event (for example when starting a scene), that's why I set the extension category to "advanced", maybe a warning should be added, what do you think? |
What do you do to enable it only for 1 event and its sub-events? |
Just call the set seed function, in the event where it is called there will be a pseudo random, in all other events there will be a regular random |
How does the extension make it works? |
!update PseudoRandom.zip |
Can't update the extension, as it doesn't pass automatic tests:
|
I was wrong, it overrides the Math.random() function globally, not just in the event and sub-event, it seemed to me that this is because gdevelop itself returns the Math.random() function to its original form after some time (about a second). |
I would be more at ease with functions like |
Then it won't be so clean, for each generation of one number you will need to have a unique seed, that is, each time after calling the generation you will have to add 1 to the seed, in my opinion this is extra work, if you use it as I showed in the last message, then there should be no side effects, since Math.random returns to its original form in the same frame |
!update PseudoRandomExtension.zip |
Can't update the extension, as it doesn't pass automatic tests:
|
Hi @D8H , I updated the extension by removing the global override of |
Updated example if needed, but everything should be intuitive, you don't even have to call "Set seed" if you don't call it then the default seed will be 1, and each call to the expression will return the next step of the randomness |
The feature from this other PR could be integrated into your extension: It will add a new This Godot class has the same kind of features if you want to take some ideas from it: |
Hi, it seems Godot calls all generations pseudo-random because numbers will never be truly random unless the generator depends on external factors such as nature. |
I don’t see why the normal distributed random should not be made reproducible. In Godot, it’s the |
I don't fully understand how this is implemented in Godot, but as far as I understand you have a choice to reproduce randomness or not, you want to add a normal distributed random function to this extension, does this mean that it should always be reproducible unless you use a timestamp as a seed? Will there be a non-reproducible analogue? For example, now there are 5 expressions of reproducible randomness in the extension and 5 similar expressions of non-reproducible randomness are built into the engine |
You can add a normal distributed random function if you want, I just don't fully understand how it will look. |
I can add it at some point, it will just add a small function that relies on your random function. If someone uses your extension without knowing that the randomness is reproducible or what it means, they won't save the seed nor the state and it will just be common randomness to them. By the way, how can users:
Is the seed generated at the start to avoid users to be confused by always getting the same series (unless they set the seed of course)? |
After calling set seed, the series will be restarted, this means that if you specify the same seed, you will get the same values every restart. |
What about starting back from a save where N numbers have already been generated and you want the next number without calling the random function N times to skip them?
Yes, I think it will be more user-friendly to generate a seed. |
So far this is not implemented, I see that the library has the ability to save and restore states, I can add this, it will complicate the extension a little, but nothing, what do you think is better to use the built-in ability to save / restore, which is an object with the parameters of the current random, or is it better to make your own restoration based on iterations, for example through a loop that will be called n times? |
!update PseudoRandomExtension.zip |
Can't update the extension, as it doesn't pass automatic tests:
|
!update PseudoRandomExtension.zip |
Can't update the extension, as it doesn't pass automatic tests:
|
Hi, I decided to make my own implementation of saving and restoring state since the built-in solution returns a large data object that will be difficult for a regular gdevelop user to understand, I decided to call it "Step" instead of "State", I'm not sure if this is correct, and also about the wording of the descriptions, it should be pretty simple now, you can specify the step from which the generation should start in the "Set seed" action, I also added an expression that returns the last step, you can even specify this expression in the "Set seed" action to continue generation from another part of the game without having to declare a variable for this. |
Hello Jurfix, the bot has been fixed, you should now be able to update the extension. It will be easier for me to follow the changes you do. |
!update PseudoRandomExtension.zip |
Extension updated with errors:
|
Description
Set seed to generate pseudo-random numbers in sub-events.
This extension will be useful for:
How to use the extension
How to use:
Example:
Checklist
What tier of review do you aim for your extension?
Community (Unreviewed)
Example file
PseudoRandomExample.zip
Extension file
PseudoRandomExtension.zip
Extension by @Jurfix
You can update the extension on this "Pull Request" by commenting the update command: in the comment field, type
!update
, then drag and drop a zip file with your extension file in the commenting field, like how you initially submitted the extension. It should look like this:It can take a few seconds for the file to fully upload and show as the above. Once it is like shown above, click "Comment" and let the bot do the rest!