Skip to content

Commit

Permalink
[orx-noise] isolated method for non-stateful rng (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardomatias authored Jan 3, 2021
1 parent b6dcfde commit c12a501
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions orx-noise/src/main/kotlin/Random.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ object Random {
seed = "${seedBase}-${seedTracking}"
}

fun isolated(fn: Random.() -> Unit) {
val state = rnd
val currentSeed = seed

resetState()

this.fn()

seed = currentSeed
rnd = state
}

fun double(min: Double = -1.0, max: Double = 1.0): Double {
return Double.uniform(min, max, rnd)
}
Expand Down

0 comments on commit c12a501

Please sign in to comment.