This project continues the percolation simulation built in the
previous project.
Visualization
We are providing a simple graphical front end for you to visualize
your percolation simulation, a class called "GridViewer", to be
found in the usual location in the course Demos directory.
public GridViewer(int[][] grid).
Contructs a visualization of a simulation grid. Call the constructor
with your randomly constructed grid prior to percolation.
public void update(int row, int col, int color, boolean slowmo).
Updates an element of the grid at coordinates (row, col). Color 0 is white,
1 is black, and any other value is blue. Boolean slowmo causes a
perceptible delay in the visualization when true, proportional to the
size of the grid.
Modify your existing Percolate class to animate the process of percolation.
Percolation Variations
Create a copy of your Percolate class, called "Percolate2"
that percolates only vertically, not horizontally. Thus, flow from top to
bottom will occur only when a complete column is unblocked.
Create a copy of your Percolate class, called "Percolate3"
that percolates vertically, horizontally, and diagonally.
Create a copy of your Percolate class, called
"Percolate4" that percolates only vertically and horizontally
to cells with a row and column greater than or equal to the current
coordinates.
Notes
Test your classes with a wide variety of grid sizes and
probability threshholds. Next week's project will build a more complex
simulation on top of these.
The Professor has provided a reference implementation for you to
compare against. Change to
directory ~brylow/cosc1010/Demos/Project9/ on
Morbius, and run java RandomGrid or java Percolate, etc.
Note that as grids are randomized, answers will differ.
Back
[Revised 2010 Nov 29 11:22 DWB]