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

IN JAVA LANGUAGE: I NEED A WORKING GUI AS WELL The goal for this programming pro

ID: 3813056 • Letter: I

Question

IN JAVA LANGUAGE: I NEED A WORKING GUI AS WELL

The goal for this programming project is to create a Predator-Prey Simulation in a two-dimensional ecosystem based on agent-based modeling. The Predator and Prey will act as agents in an ecosystem in this simulation.

The ecosystem should be modeled as an N x N grid of cells. Only one prey can occupy a cell at a time. The grid is enclosed, so a prey always stays inside the grid of cells. A prey is not allowed to move outside of the eco-system.

Time is simulated in time steps. Each prey and predator agent performs some action in every time step.

The Prey follows the following rules at each time step:

Move: Every time step, randomly try to move up, down, left, or right. If the cell in the selected direction is occupied or would move the prey off the grid then the prey stays in the current cell.

Breed. If a prey survives for three time steps, then at the end of the third time step (i.e., after moving), the prey will breed. This is simulated by creating a new prey in an adjacent (up, down, left, or right) cell that is empty. If there is no empty cell available, no breeding occurs. Once an offspring is produced, the prey cannot produce an offspring until three more time steps have elapsed.

A Predator behaves according to the following model:

Move. Every time step, if there is an adjacent cell (up, down, left, or right) occupied by a prey, then the predator will move to that cell and eat the prey. Otherwise, the predator moves according to the same rules as the prey. Note that a predator cannot eat other predator objects.

Breed. If a predator survives for eight time steps, then at the end of the time step, it will spawn off a new predator in the same manner as the prey.

Starve. If a predator has not eaten a prey within the last three time steps, then at the end of the third time step, it will starve and die. The predator should then be removed from the grid of cells. During one turn, all the predators should move before the preys.

Before the simulation begins, the initial positions of all Preys should be randomly assigned first. Then the initial positions of the Predators should be assigned next. Note that the Simulation stops when the number of time steps ends or when one or both species population become zero.

Implement a java GUI that will allow the user to interact with the system. A suggested GUI is given below. User should be able to enter the following through the GUI:

Initial Predator count

Initial Prey count

No. of row cells in the ecosystem

No. of column cells in the ecosystem

No. of time steps.

The user clicks the “Simulate” Button and this should run the simulation. Once the simulation is over, a separate window should be shown that shows how the population of predator and prey with respect to time (x-axis: time and y-axis: No. of predator and prey). Most likely, you should see a cyclical pattern between the population of predators and prey, although random perturbations may lead to the elimination of one or both species. The GUI should also have a button (“Positions”) which when clicked will simply print to the console the grid of cells as ASCII characters (‘x’: if cell is occupied by a Predator, ‘o’: if cell is occupied by a Prey, and ‘.’ If cell is empty).

General guidelines: In this class project, you are encouraged to follow the general guideline to an object-oriented design:

Identify the classes in the system.

Identify the responsibilities (attributes and methods) for each class.

Identify any class interactions or hierarchy to understand the order of implementation of the classes. Remember important class interactions (inheritance, aggregation, and composition).

Note that you might have to come back to your class definitions and add, remove, or adjust the responsibilities. You might even need to add or remove classes.

Create a UML class diagrams and class interactions (For this purpose, you can use regular pencil and paper since most likely you might edit your diagrams as your project progresses).

Implement the individual classes. While implementing the individual classes, don’t worry too much about the simulation of the system. The simulation should be implemented as a separate demo class (a GUI) at the end.

Explanation / Answer

.ent exc_pulse
exc_pulse:
la t0, time
la t1, x_q
la t2, light
lw t3, 0(t0) //Load time (t3)
lw t4, 0(t1) //Load x_q (t4)
lw t5, 0(t2) //Load lightweight (t5)
addi t6, t3, one //Increment time by one   
sw t6, 0(t0)
addi t7,zero,10 //Time before lightchangage
blt t6, t7, ls //If time < ten - long skipout
move t3, zero //time = 0;
sw t3, 0(t0)
beq t4, zero, ls //If x_q == zero - long skipout
bne t5, zero, ss //If lightweight == one - short skipout
addi t5, zero, one //light == one
sw t5, 0(t2)
lui t8, LEDZ
addi t9, zero, a hundred thirty //Turn on some lights!
sb t9, 0(t8)

j ls
ss:
move t5, zero //light = zero
sw t5, 0(t2)
addi t9, zero, 65
sb t9, 0(t8) //Turn on/off lights!
move t4,zero //empty queue
sw t4, 0(t1)
ls:

.end exc_pulse