Design

Simulator exercises the Roulette simulation with a given Player placing bets. It reports raw statistics on a number of sessions of play.

Fields

  • int initDuration = 250;

    The duration value to use when initializing a Player for a session.

  • int initStake = 100;

    The stake value to use when initializing a Player for a session.

  • int samples ;

    The number of game cycles to simulate. A default value of 50 makes sense.

  • List durations ;

    A list of lengths of time the Player remained in the game. Each session of play producrs a duration metric, which are collected into this list.

  • List maxima ;

    A list of maximum stakes for each Player. Each session of play producrs a maximum stake metric, which are collected into this list.

  • Player thePlayer ;

    The betting strategy we are simulating.

  • Game theGame ;

    The casino game we are simulating.

Constructors

  • Simulator(Game game,
              Player player);

    Saves the Player and Game instances so we can gather statistics on the performance of the player's betting strategy.

Methods

  • List session();

    Executes a single game session. The Player is initialized with their initial stake and initial cycles to go. An empty List of stake values is created. The session loop executes until the Player playing returns false. This loop executes the Game cycle; then it gets the stake from the Player and appends this amount to the List of stake values. The List of individual stake values is returned as the result of the session of play.

  • gather();

    Executes the number of games sessions in samples. Each game session returns a List of stake values. When the session is over (either the play reached their time limit or their stake was spent), then the length of the session List and the maximum value in the session List are the resulting duration and maximum metrics. These two metrics are appended to the durations list and the maxima list.

    A client class will either display the durations and maxima raw metrics or produce statistical summaries.