diff --git a/js/common/model/CAVSceneModel.ts b/js/common/model/CAVSceneModel.ts index 626435c4..83b9abd2 100644 --- a/js/common/model/CAVSceneModel.ts +++ b/js/common/model/CAVSceneModel.ts @@ -72,7 +72,7 @@ export default class CAVSceneModel implements TModel { // Starting at 0, iterate through the index of the kickers. This updates the SoccerPlayer.isActiveProperty to show the current kicker private readonly activeKickerIndexProperty: NumberProperty; - public constructor( options: { tandem: Tandem } ) { + public constructor( initialDistribution: ReadonlyArray, options: { tandem: Tandem } ) { const updateDataMeasures = () => this.updateDataMeasures(); @@ -177,7 +177,7 @@ export default class CAVSceneModel implements TModel { this.hasKickableSoccerBallsProperty = new DerivedProperty( [ this.numberOfUnkickedBallsProperty ], numberOfUnkickedBalls => numberOfUnkickedBalls > 0 ); - this.distributionProperty = new Property( CAVSceneModel.chooseDistribution(), { + this.distributionProperty = new Property( initialDistribution, { tandem: options.tandem.createTandem( 'distributionProperty' ), phetioValueType: ArrayIO( NumberIO ), phetioDocumentation: 'The distribution of probabilities of where the balls will land is represented as an un-normalized array of non-negative, floating-point numbers, one value for each location in the physical range', @@ -278,6 +278,8 @@ export default class CAVSceneModel implements TModel { * Resets the model. */ public reset(): void { + + // TODO: This should only be in MedianSceneModel and MeanAndMedianSceneModel this.distributionProperty.value = CAVSceneModel.chooseDistribution(); this.clearData(); @@ -384,7 +386,7 @@ export default class CAVSceneModel implements TModel { } } - private static chooseDistribution(): ReadonlyArray { + public static chooseDistribution(): ReadonlyArray { return dotRandom.nextBoolean() ? CAVConstants.LEFT_SKEWED_DATA : CAVConstants.RIGHT_SKEWED_DATA; } diff --git a/js/mean-and-median/model/MeanAndMedianModel.ts b/js/mean-and-median/model/MeanAndMedianModel.ts index eac8e747..e09aafed 100644 --- a/js/mean-and-median/model/MeanAndMedianModel.ts +++ b/js/mean-and-median/model/MeanAndMedianModel.ts @@ -27,7 +27,7 @@ export default class MeanAndMedianModel extends CAVModel { public constructor( options: { tandem: Tandem } ) { - const scene = new CAVSceneModel( { tandem: options.tandem.createTandem( 'sceneModel' ) } ); + const scene = new CAVSceneModel( CAVSceneModel.chooseDistribution(), { tandem: options.tandem.createTandem( 'sceneModel' ) } ); super( [ scene ], { ...options, instrumentMeanPredictionProperty: true diff --git a/js/median/model/MedianModel.ts b/js/median/model/MedianModel.ts index 3fa5773a..1f63bc5f 100644 --- a/js/median/model/MedianModel.ts +++ b/js/median/model/MedianModel.ts @@ -20,7 +20,7 @@ export default class MedianModel extends CAVModel { public readonly isSortingDataProperty: BooleanProperty; public constructor( options: { tandem: Tandem } ) { - const scene = new CAVSceneModel( { tandem: options.tandem.createTandem( 'sceneModel' ) } ); + const scene = new CAVSceneModel( CAVSceneModel.chooseDistribution(), { tandem: options.tandem.createTandem( 'sceneModel' ) } ); super( [ scene ], { ...options, instrumentMeanPredictionProperty: false diff --git a/js/variability/model/VariabilityModel.ts b/js/variability/model/VariabilityModel.ts index 135eebf3..78939718 100644 --- a/js/variability/model/VariabilityModel.ts +++ b/js/variability/model/VariabilityModel.ts @@ -35,21 +35,6 @@ export default class VariabilityModel extends CAVModel { public constructor( options: VariabilityModelOptions ) { - const sceneModels = [ - - // TODO: Each of these should have its own distribution - new VariabilitySceneModel( { tandem: options.tandem.createTandem( 'sceneModel1' ) } ), - new VariabilitySceneModel( { tandem: options.tandem.createTandem( 'sceneModel2' ) } ), - new VariabilitySceneModel( { tandem: options.tandem.createTandem( 'sceneModel3' ) } ), - new VariabilitySceneModel( { tandem: options.tandem.createTandem( 'sceneModel4' ) } ) - ]; - super( sceneModels, options ); - - this.initialized = true; - - this.variabilitySceneModels = sceneModels; - - // TODO: When the selected scene model changes, make the old one invisible and make the new one visible, see https://github.com/phetsims/center-and-variability/issues/164 // this.selectedDistributionProperty.link( distribution => { // @@ -62,6 +47,20 @@ export default class VariabilityModel extends CAVModel { // distribution === DistributionType.KICKER_3 ? [ 6, 9, 11, 14, 11, 8, 6, 5, 5, 5, 5, 5, 5, 5, 5 ] : // /*KICKER_4*/ [ 5, 5, 5, 5, 5, 5, 5, 5, 6, 8, 11, 14, 11, 9, 6 ]; // } ); + const sceneModels = [ + + // TODO: Each of these should have its own distribution + new VariabilitySceneModel( [ 0, 0, 0, 1, 3, 10, 18, 20, 18, 10, 3, 1, 0, 0, 0 ], { tandem: options.tandem.createTandem( 'sceneModel1' ) } ), + new VariabilitySceneModel( [ 5, 5, 10, 10, 25, 30, 40, 50, 40, 30, 25, 10, 10, 5, 5 ], { tandem: options.tandem.createTandem( 'sceneModel2' ) } ), + new VariabilitySceneModel( [ 6, 9, 11, 14, 11, 8, 6, 5, 5, 5, 5, 5, 5, 5, 5 ], { tandem: options.tandem.createTandem( 'sceneModel3' ) } ), + new VariabilitySceneModel( [ 5, 5, 5, 5, 5, 5, 5, 5, 6, 8, 11, 14, 11, 9, 6 ], { tandem: options.tandem.createTandem( 'sceneModel4' ) } ) + ]; + super( sceneModels, options ); + + this.initialized = true; + + this.variabilitySceneModels = sceneModels; + this.selectedVariabilityProperty = new EnumerationProperty( VariabilityMeasure.RANGE, { tandem: options.tandem.createTandem( 'selectedVariabilityProperty' ) diff --git a/js/variability/model/VariabilitySceneModel.ts b/js/variability/model/VariabilitySceneModel.ts index f27aa2a5..400c7a94 100644 --- a/js/variability/model/VariabilitySceneModel.ts +++ b/js/variability/model/VariabilitySceneModel.ts @@ -22,8 +22,8 @@ export default class VariabilitySceneModel extends CAVSceneModel { private readonly initialized: boolean = false; - public constructor( options: { tandem: Tandem } ) { - super( options ); + public constructor( distribution: ReadonlyArray, options: { tandem: Tandem } ) { + super( distribution, options ); this.maxValueProperty = new DerivedProperty( [ this.dataRangeProperty ], dataRange => { return dataRange === null ? null : dataRange.max;