JMSL Tutorial: Weighted Object Chooser

The WeightedObjectChooser supports a next() method which returns a randomly chosen Object whose probability of being chosen is weighted. In this applet, a WeightedObjectChooser implement the Behavior interface and so, can be used to choose a random Composable every time a SequentialCollection repeats. Note that the SequentialCollection itself contains no children (!), as it depends entirely on its Behavior to provide it with the next Child to launch every time it repeats.
Scrollbars are provided to set the relative weights of the three MusicShapes used here.
Thanks to Larry Polansky for suggesting that WeightedObjectChooser be part of JMSL.

You need a Java-enabled browser to view this applet. 
See complete applet source here.
Previous Tutorial Index Tutorial Contents Next

  (C) 2004 Phil Burk and Nick Didkovsky, All Rights Reserved
  JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.