Write a program to simulate a fish randomly swimming around an aquarium. Below are
the details for the assignment:
Your program takes in two command-line arguments. One for an input
filename and one for an output filename.
The input file contains the state of the aquarium. Here is an
example. Details:
The first line contains N the size of the aquarium (N x N).
There are N lines following that, each with N characters.
'.' is water.
'O' is an obstacle, like a rock.
'F' is the position of the fish. There will only be one 'F'.
Simulate 100 steps of a simulation. Draw the state of the tank at each
step. The rules:
Put your name at the top left corner (left justified at (-1, N)) of the
aquarium.
Put your timestep at the bottom right corner (right justified at
(N, -1)) of the aquarium.
The ocean is blue. Draw white lines to show the grid cells
appropriately.
Obstacles are black circles (they should visibly be within a grid
cell).
Download a pretty picture for the fish. Show it as the size of a
single grid cell, or a little smaller.
The canvas is 500x500 pixels.
The X scale and Y scale are both (-1.5, N+0.5).
The fish randomly moves one cell east, south, west, or north.
The fish cannot move out of the tank.
The fish cannot move into an obstacle.
The fish must move each time step, it cannot sit still.
Pause for 100ms.
Remember that in order to draw the matrix from
the file, that columns are X coordinates (not Y), rows are Y coordinates
(not X), and rows should start from the top (not bottom)
At the end of the simulation write the state of the tank to the output
filename specified in the same format as the input.
Your program should be called aquarium.java. Implement your
code using functions (static methods). Some ideas on how to organize your
code into functions (these are not required only thoughts on the top of my
head):
ReadInputFile - A function that takes a parameter of a
String and creates the aquarium multiarray from the
information in the file.
WriteOutputFile - A function that takes parameters of a
String and the aquarium multiarray and writes the
multiarray to a file.
MoveFish - A function that takes as input the position
(row and column) of the fish and the multiarray and relocates the fish
to a new location.
DrawGrid - A function that takes N the size of the
aquarium and draws the grid lines.
DrawObstacles - A function that takes the multiarray of
the tank, searches for, and draws the obstacles.
Etc.
Press play to show example video. Note the video is stretched
width-wise and is not representative of the real example program.
Bonus. Add a shark to the aquarium. Details:
It will be denoted as an 'S' in the input and output files.
The shark randomly moves every other timestep. The shark moves after the
fish and cannot occupy the same cell as the fish.
The shark can only eat the fish if it is not moving (the fish runs into
the shark).
You can also earn bonus for making a prettier simulation.
This assignment will be graded as two separate programming assignments. Part
one of the grade focuses on the final product. Did you pay attention to detail
and implement the simulation/drawing as specified. Part two of the grade is
focused on implementing components of the program into functions. Each portion
is graded out of 100 points.