Skip to content

Commit

Permalink
Merge pull request pichenettes#38 from float32/master
Browse files Browse the repository at this point in the history
Marbles: Fix bug where a random event could happen with deja vu = 0.5
  • Loading branch information
pichenettes authored Jul 3, 2021
2 parents 3c3d177 + cf45887 commit 6e5ea98
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions marbles/random/random_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class RandomSequence {
const float p = p_sqrt * p_sqrt;
float rho = random_stream_->GetFloat();

if (rho <= p && deja_vu_ <= 0.5f) {
if (rho < p && deja_vu_ <= 0.5f) {
// Generate a new value and put it at the end of the loop.
redo_write_ptr_ = &loop_[loop_write_head_];
*redo_write_ptr_ = deterministic
Expand All @@ -179,7 +179,7 @@ class RandomSequence {
// Do not generate a new value, just replay the loop or jump randomly.
// through it.
redo_write_ptr_ = NULL;
if (rho <= p) {
if (rho < p) {
step_ = static_cast<int>(
random_stream_->GetFloat() * static_cast<float>(length_));
} else {
Expand Down

0 comments on commit 6e5ea98

Please sign in to comment.