Fix #3: Add random number generator#31
Open
leftibot wants to merge 3 commits intoChaiScript:masterfrom
Open
Conversation
Add chaiscript::extras::random providing rand(), rand(max), rand(min, max), and srand(seed) functions using C++11's <random> facilities (std::mt19937 with std::uniform_int_distribution). The engine state is shared via std::shared_ptr so srand() produces deterministic sequences. Also add CATCH_CONFIG_NO_POSIX_SIGNALS to test files to fix SIGSTKSZ build errors on newer glibc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
|
@leftibot make this more like the C++ interface, where the user has to have the random number generator engine, and they can copy / seed it / etc, and then ask for values from it from a range, etc. |
…rface Replace free functions (rand/srand) with a Random_Engine class that wraps std::mt19937. Users construct engine objects, copy them, seed them, and generate values via random_int(min, max) and random_float(min, max). Requested by @lefticus in PR ChaiScript#31 review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Addressed review feedback from @lefticus. New commits: |
Member
|
@leftibot make it clear what random device is being used in the name of the random device. |
Make the underlying random device (std::mt19937) explicit in the type name, so users know which engine they are working with. Requested by @lefticus in PR ChaiScript#31 review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Addressed review feedback from @lefticus. New commits: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated fix by @leftibot.
What changed
Files
Closes #3
Triggered by @lefticus.