Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This assignment you will create a simulation of lions hunting a gazelle on the S

ID: 655869 • Letter: T

Question

This assignment you will create a simulation of lions hunting a gazelle on the Serengeti. The rules for the simulation are:

Lions move up to 1 meter each time step.

The Gazelle moves up to 2 meters each time step.

The lions win if at the start of any turn there are 2 or more Lions adjacent to the Gazelle.

The Gazelle wins if it avoids the Lions for 50 time steps.

The Gazelle starts in the center of the board.

The Lions start in random locations at least 5 meters away from the Gazelle.

You may use any intelligence scheme you like for your lions and gazelle. A good first approximation is to have the lions move toward the gazelle, and the gazelle to move away from the nearest lion. You can add some randomness to the direction if you like, or use other strategies. The board size should be 20 rows by 30 columns.

You will need to implement this as a two-dimensional array of pointers to a Creature class. The Creature class should have some means of telling whether a given instance is a lion or a gazelle, and should store its own "location" on the grid (r,c). You could also have it simply store its maximum movement instead of its type. Another helpful class would be a Vector class that can do vector computations in either polar or cartesian coordinates.

Lions and gazelles move in real space. In other words, a creature's location could be something like (2.1, 3.4). This would place the creature in the (2,3) "cell", which is where you should print it on the map. When a creature moves, it's current cell should "release" it (by changing the pointer to NULL), and the destination should "receive" it by setting its pointer to point to the creature. If the cell is already occupied, then the creature doesn't move. This can be accomplished in a way very similar to the Robot World.

Finally, place all of the output in an NCurses output screen. You may use Josh's CursWin wrapper if you'd like. The links for the files are on the CursWin home page.

Specific requirements

Correctly implement the Serengeti simulation with the following constraints:

Lions move up to 1 meter per turn

Gazelle moves up to 2 meters per turn

Lions win if 2 are adjacent to the gazelle at the start of the turn.

Gazelle wins if it has not been eaten by the end of turn 51.

Gazelle starts in center, lions start in random locations at least 5 meters from the gazelle.

Creatures move in real space and then are printed on the grid based upon the integer part of their location.

Creatures cannot move into cells occupied by other cretures, and may not move over the border.

Curses library used for outputting the board each step.

Two dimensional array of pointers to creatures used to store the creatures.

Explanation / Answer

#include #define ROWS 4 #define COLS 3 int main () { // declare 4x3 array int matrix[ROWS][COLS] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}; for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote