Skip to content

Commit

Permalink
create dotRandom and use instead of phet.joist.random, phetsims/joist…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jan 22, 2021
1 parent 4e90ec2 commit 6741151
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion js/common/model/Ball.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import Emitter from '../../../../axon/js/Emitter.js';
import dotRandom from '../../../../dot/js/dotRandom.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import plinkoProbability from '../../plinkoProbability.js';
import PlinkoProbabilityConstants from '../PlinkoProbabilityConstants.js';
Expand Down Expand Up @@ -74,7 +75,7 @@ class Ball {

// the path of the balls through the pegs of the galton board is determined
for ( rowNumber = 0; rowNumber <= numberOfRows; rowNumber++ ) {
direction = ( phet.joist.random.nextDouble() > probability ) ? 'left' : 'right';
direction = ( dotRandom.nextDouble() > probability ) ? 'left' : 'right';
peg = {
rowNumber: rowNumber, // an integer starting at zero
positionX: getPegPositionX( rowNumber, columnNumber, numberOfRows ),
Expand Down
3 changes: 2 additions & 1 deletion js/common/model/Histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import Emitter from '../../../../axon/js/Emitter.js';
import dotRandom from '../../../../dot/js/dotRandom.js';
import plinkoProbability from '../../plinkoProbability.js';
import PlinkoProbabilityConstants from '../PlinkoProbabilityConstants.js';

Expand Down Expand Up @@ -73,7 +74,7 @@ class Histogram {
let columnNumber = 0;
// the path of the balls through the pegs of the galton board is determined for the prepopulated balls only
for ( let rowNumber = 0; rowNumber <= this.numberOfRowsProperty.get(); rowNumber++ ) {
const direction = ( phet.joist.random.nextBoolean() ? 'left' : 'right' );
const direction = ( dotRandom.nextBoolean() ? 'left' : 'right' );

// increment the column number of the next row, but not for the last row
if ( rowNumber < this.numberOfRowsProperty.get() ) {
Expand Down
3 changes: 2 additions & 1 deletion js/intro/model/IntroBall.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @author Martin Veillette (Berea College)
*/

import dotRandom from '../../../../dot/js/dotRandom.js';
import Ball from '../../common/model/Ball.js';
import plinkoProbability from '../../plinkoProbability.js';

Expand Down Expand Up @@ -40,7 +41,7 @@ class IntroBall extends Ball {

// Ball makes probabilistic decision whether to end in left or right horizontal position in the bin
case 1:
this.binOrientation = ( phet.joist.random.nextBoolean() ? 1 : -1 );
this.binOrientation = ( dotRandom.nextBoolean() ? 1 : -1 );
break;

// the ball must take the opposite orientation than the last ball
Expand Down

0 comments on commit 6741151

Please sign in to comment.