Skip to content

Commit

Permalink
Marbles: Fix bug where the loop could jump with deja vu < 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
float32 committed Jul 3, 2021
1 parent 84f4f67 commit fc88883
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions marbles/random/random_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ class RandomSequence {

const float p_sqrt = 2.0f * deja_vu_ - 1.0f;
const float p = p_sqrt * p_sqrt;
float rho = random_stream_->GetFloat();

if (random_stream_->GetFloat() <= 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 @@ -178,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 (random_stream_->GetFloat() <= p) {
if (rho <= p) {
step_ = static_cast<int>(
random_stream_->GetFloat() * static_cast<float>(length_));
} else {
Expand Down

0 comments on commit fc88883

Please sign in to comment.