## Cornmaze applet v2.1

### Instructions

#### Overview

Cornmaze is a Java Applet written by myself, Ben McIlwain, in response to an interesting activity we did in Statistics class. We were playing a "game" with two players. The board is an array of spaces, some of which are blockades, which block movement and view. The object of the game is to see how long it takes the two different players, who move randomly, to be able to see each other. They can only see other across straight horizontal or vertical lines. When we played it in class, we were moving randomly by hand, so it took two people up to ten minutes to finish a single game. Thus, I decided I would make this applet, which can simulate thousands of games per second.

#### Play dynamics

The game is played out in a series of turns. Each turn, each player moves exactly once. A direction is randomly decided to move in, and if that direction is blocked, more directions are generated until a valid move is found. Since the players are considered to be moving simultaneously, it is possible for them to be briefly in sight in the middle of a move. For game purposes this is not counted: each game only ends once both players are in sight of each other at the end of that turn, after they have both moved. If the players move into the same space, a purple circle will be used to illustrate where the red and blue players have overlapped, and this is counted as them being able to see each other. After each game the number of moves it took for the players to see each other is recorded.

#### Critical blockades

A blockade (black square on the map) is considered critical if, it weren't there, the game would've already ended. It is the only cell blocking the line of sight between the two players. Only the first such square to block movement counts as the critical square. An indicator starts counting up the number of turns the game continues after the critical blockade has been encountered. It is useful as a visual device for the user to be able to see which blockades have the greatest effect on the game, and how much of an effect they have by keeping track of the number of moves they prolonged the game by.

#### Interface

The interface has a variety of textfields, labels, and buttons. The first three fields are used to set the parameters of the maze. The user can set the probability that each cell is a blockade (the default is 10%), and the width and height of the maze. Making bigger mazes will require more turns for each game to complete. Press the "Make New Maze" to set up a maze after the desired numbers have been input. After randomization of the blockades, the user may click on any cell individually to toggle between blockades and empty spaces. This is desired if the user wants to make a custom maze, or if a maze made with a high blockage randomization coefficient ends up being impossible to solve and the user must remove some walls to make sight between the two players possible.

The next textfield allows the user to set the number of trials. The default is one, which means the game is only run once. For a large number of trials, such as 100 or 10,000, the speed needs to be adjusted or the game will take forever. The dropdown speed menu allows the user to select between 7 different speeds. "Warp 10" means the players are redrawn only every fifteenth move to speed up gameplay, and "Instant" mode is useful for extremely large amounts of trials because the players are only redrawn each time a trial ends. The "Run Simulation" button will run the simulation according to the values that have been inputted. The program will keep track of the number of Turns in the current game, as well as the Average Number of Turns for multiple trial runs.

#### Statistics view

After multiple trials have been run a histogram will pop up above the maze. The number in black at the left edge of each histogram bin shows the lower bound of that bin. The upper bound of that bin is the lower bound of the next bin minus one. The frequency of each bin is shown by bin height, which calibrates automatically. To the right, the numbers in red show Max Frequency, which sets the scale by telling the frequency number of the largest column on the histogram. The Standard Deviation, a common statistical analysis, is shown as well.

#### Multiple Runs

When running multiple trials in a single run the results will accumulate. Only in this situation does the application of average, standard deviation, and histogram make any sense. As soon as another run is begun, the results are cleared out from the previous run. You cannot change any of the parameters while the run is in operation. You cannot choose to run 100 trials and then an additional 1000 with all the same parameters and combination of the results. Sorry, that's just the way the program is. If in doubt, run a larger amount of trials than you'll expect you'll need; you can always stop the simulation in mid-run. A purple bar scrolling across the top of the applet keeps track of how many trials are left to complete in the current run.