|
|
April 1, 1997
The Code
![]()
Team.java
A Virtual Ball Game
Simulating Away Baseball's Ennui
The Simulator
Test how different slugging percentages and times spent at bat affect the length of a baseball game with the baseball simulator.FAQ
How do the simulated players hit? What's wrong with this approximation? What about errors? Check the simulator FAQ.Last Time
For more on computer simulations, see New-Media Tools for Online Journalism, published Oct. 9, 1996.
This code simulates the hitting of a team. In this simulator, that isn't very sophisticated. The function rolls a random number generator and chooses an outcome based upon the statitical model it is using. You should try and modify this if you want to do a better job simulating the effects of the count on the ball game.Ballgame.java
This works through the nine innings of the game by counting the outs, the hits and the runs. It calls the functions from Team.java at each at bat and then uses the output to keep track of the runs. You may want to modify this class if you want to change the rules of how runners advance when hits come.Gamescore.java
This displays the current game score in the window. It is a bit more complex than usual because games can go into extra innings.DurationReporter.java
This displays the time of the last 10 games in a box. It also reports the minimum, maximum and average score.DurationHistory.java
The results of the last four simulations are kept here and displayed.TextWindow.java
The text window used in help simulations.BallGUI.java
The layout mechanism that loads the images and places the various parts on the screen.
|
|