Download the following files and place them in a folder called Movement
Create new LJHS project called HexGrid and store the project in the Movement folder. Move fish.dat into the HexGrid folder. Add all *.cpp files to your project then run the project. If you have warnings with RandGen, remove randGen.cpp from your project. You should get a two-dimensional array display.
Instead of displaying spaces between the fishes in the output, display a dot ('.') for the space. Determine which class needs to be editied and then edit the file so that dots '.''s are output instead of blank spaces.
In order to change the behavior of each fish as requested by the biologists, we need to modify the relationships among the positions. We also need to determine how we can compactly represent a hexagonal grid, where each position has six neighbors. It turns out that the idea of the representation is easy. We store the positions in a two dimensional array as we did before, but we interpret each position in the array differently. If we orient the hexagonal grid as shown below, then each position has one neighbor to the right and one to the left in its own row, but two neighbors in the row above and two neighbors in the row below in directions naturally designated Northeast, Northwest, Southeast and Southwest. For example, the 5 x 4 grid shown below has the odd numbered columns shaded for clarity. Notice how the indexing of the Northeast, Northwest, Southeast and Southwest neighbors of a position depends on whether that position is an even or an odd numbered row. The diagram has the position (2, 2) indicated by an X and its six neighbors designated by NE, E, SE, SW, W, NW.
If we examine the classes making up the fish simulation program, we see the the relationship between neighbors in the two dimensional grid is effectively defined by the four Position member functions North, East, South, West. These functions are called in the Fish class member function EmptyNeighbors, which constructs a Neighborhood containing the positions to which the fish can move. Consequently, we can change the internal representation of the fish grid to a hexagonal grid by simply changing these functions appropriately. In the course of doing this we note that a small change must be made in the Neighborhood class implementation to accomodate the larger number of neighbors now possible and an adjustment to the Display class is needed to represent the new grid on screen.
You will give me a oral presentation of your project. I will not being asking any questions, unless I have a question about your presentation.
Your presentation must prove that your program works. You need to explain how you set the the fish data, what specific fish positions were testing for, the expected output, and show me that the fish movement proves your expectations.
You will also need to show me all changes in all classes that you made, and how they affected the design and outcome of the project.