Project - different forms of life in the amazon jungle

Assignment Help JAVA Programming
Reference no: EM131842980

Project: Circle of Life

1. Problem Description

This project simulates (although unrealistically) interactions among different forms of life in the Amazon jungle. The rainforest jungle is represented by an NxN grid that changes over a number of cycles. Within a cycle, each square is occupied by one of the following five life forms:

Jaguar (J), Puma (P), Deer (D), Grass (G), and Empty (E)

An Empty square means that it is not occupied by any life form. Below is a jungle example as a 6 × 6 grid.

P5 E E P0 E E
J3 P1  J0 D0 G D0
D0 E D2 J0 J2 G
J0 E E D1 P0 E
J1 E E G E D0
G G E J0 D2 E

Both row and column indices start from 0. In the example, the (1, 1)th square is occupied by a 1-year-old Puma. It has a 3 × 3 neighborhood centered at the square:

P5  E  E

J3  P1  J0

D0  E  D2

The (0, 0)th square P5 (a 5-year-old Puma) has only a 2 × 2 neighborhood:

P5  E
J3  P1

Meanwhile, the (2, 0)th square D0 (a newborn Deer) has a 3 × 2 neighborhood:

J3  P1
D0  E
J0  E

Generally, the neighborhood of a square is a "3 × 3" grid which includes only those squares lying within the intersection of the jungle with a 3 × 3 window centered at the square. When a square is on the border, the dimension of its neighborhood reduces to 2 × 3, 3 × 2, or 2 × 2.

2. Survival Rules

The jungle evolves from one cycle to the next one. In the next cycle, the life form to reside on a square is decided by those life forms in the current cycle who live in the 3 × 3 neighborhood centered at the square, under a set of survival rules. These rules are specified according to the life form residing on the same square in the current cycle. Jaguars, pumas, and deers will grow one year older in the next cycle.

2.1 Jaguar

A jaguar dies of old age or hunger, or from an attack when jaguars are considerably outnumbered by pumas in the neighborhood. The life form on a Jaguar square in the next cycle will be

a) Empty if the Jaguar is at age 5 in the current cycle;
b) otherwise, Puma, if there are at least twice as many Pumas as Jaguars in the neighborhood;
c) otherwise, Empty, if Jaguars and Pumas together outnumber Deers in the neighborhood;
d) otherwise, Jaguar (the Jaguar will live on).

The new life form taking over the square, if a Puma, will have age 0 when the next cycle starts. For example, in the following neighborhood of a Jaguar at age 2:
D0 G D0 J0 J2 G D1 P0 E

there are two Jaguars (including self), one Puma, and three Deers. Going down the rule list, rule d) applies. According to this rule, the central element (square) will still be J (Jaguar) --- one year older--- in the next cycle. In other words, J2 will be replaced with J3.

2.2 Puma

A Puma dies of old age, hunger, or a Jaguar attack. The life form on a Puma square in the next cycle will be

a) Empty if the Puma is currently at age 4;
b) otherwise, Jaguar, if there are more Jaguars than Pumas in the neighborhood;
c) otherwise, Empty, if Jaguars and Pumas together outnumber Deers in the neighborhood;
d) otherwise, Puma (the Puma will live on).

The new life form, if a Jaguar, will have age 0 when the next cycle begins.

For example, in the following neighborhood of a Puma at age 1:
P5  E  E

J3  P1  J0

D0  E  D2

there are two Pumas, two Jaguars, and two Deers. Rule c) applies. The central square will become E in the next cycle.

2.3 Deer

A Deer dies of old age or hunger. It may also be eaten by a Jaguar or a Puma. More specifically, the life form on a Deer square in the next cycle will be

a) Empty if the Deer's current age is 6;
b) otherwise, Empty if there is no Grass in the neighborhood (the Deer needs food);
c) otherwise, Puma if in the neighborhood there are more Pumas and Jaguars together than Deers, and furthermore, if there are at least twice as many Pumas as Jaguars;
d) otherwise, Jaguar if there are more Pumas and Jaquars together than Deers, and if there are at least as many Jaguars as Pumas;
e) otherwise, Deer (the Deer will live on).

If the new life form is a Jaguar or Puma, it will have age 0 when the next cycle starts. In the following neighborhood of a Deer at age 2:
P1  J0  D0

E  D2  J0

E  E  D1

lives two Jaguars, one Puma, and three Deers. Rule a) does not apply because the Deer is only 2-years old. Rule b) does since there is no Grass in the neighborhood. The central element (square) will be E in the next cycle according to this rule.

2.4 Grass

Grass may be eaten out by overcrowded Deers. Deers may also multiply fast enough to take over the Grass square. In the next cycle, the life form on a Grass square will be

a) Empty if at least three times as many Deers as Grasses in the neighborhood;
b) otherwise, Deer if there are at least four Deers in the neighborhood;
c) otherwise, Grass.

If the new life form is a Deer, it will be aged 0 when the next cycle starts. For example, if the neighborhood of a Grass is
P0  E  E

D0  G  D0

J0  J2  G

the central element will be G in the next cycle under rule c).

2.5 Empty

Empty squares are competed by other life forms. More specifically, the life form on an Empty square in the next cycle will be

a) Deer, if more than one neighboring Deer;
b) otherwise, Puma, if more than one neighboring Puma;
c) otherwise, Jaguar, if more than one neighboring Jaguar;
d) otherwise, Grass, if at least one neighboring Grass;
e) otherwise, Empty.

If the new life form is a Jaguar, Puma, or Deer, it will have age 0 when the next cycle begins.

3. Task

You will implement an abstract class Living to represent a generic life form. It has three subclasses Animal, Empty, and Grass. The first subclass, implementing the interface MyAge, is abstract, and needs to be extended to three subclasses: Jaguar, Puma, and Deer. You also need to implement a Jungle class which has a public member Living[][] to represent a grid jungle.

The class CircleOfLife repeatedly simulates evolutions of input jungles, which are either randomly generated or read in from files. In each iteration, the class interacts with the user who chooses how the input jungle will be generated, and enters the number of cycles to simulate.
The iteration prints out the initial jungle and the final jungle.

Your random jungle generator may follow the uniform probability distribution so that Deer, Empty, Grass, Jaguar, and Puma have equal likelihoods to occupy every square. Or you may use a different distribution, as long as no life form has zero chance to appear on a square.

Java provides a random number generator. To use it, you need to import the package
java.util.Random. Next, declare and initiate a Random object like below

Random generator = new Random(); Then, every call below generator.nextInt(5)
will generate a random number between 0 and 4 that corresponds to one of the five life forms.

Jungle creation from an input file will weigh more than random creation in our grading. When zero or a negative number of cycles is entered by the user, your code does nothing but waits for a positive input.

A new living form, if a Jaguar, Puma, or Deer, always has age 0 at its creation, whether initially by the class Jungle or later on under a survival rule. After surviving a cycle, its age increases by one.

Templates are provided for all classes. Be sure to use the package name edu.iastate.cs228.hw1 for the project.

Below is a sample simulation scenario over three initial jungles. In the first iteration, the user entered 1 for a randomly generated jungle, 3 to specify the grid to be 3×3, and 1 to simulate just one cycle. The simulator printed out the initial and final jungles. The second iteration simulated a randomly generated 6×6 grid over 8 cycles. In the third iteration, the user typed 2 for a file input, entered the file name "public3-10x10.txt", and specified 6 cycles. (The file public3- 10x10.txt, describling a 10 x 10 grid, resides in the same folder containing the src folder.) After the third iteration, the user typed 3 to end the simulation. (Any number other than 1 and 2 could have ended the simulation.)

4. Input/Output Format

The format for jungles is shown in the sample runs above subject to the following rules.

a) Every square occupies two spaces starting with one of the letters 'D', 'E', 'G', ‘J', and 'P'.

b) If the letter is ‘D', 'J', or 'P', then it is followed by a digit representing the animal's age; otherwise, it is followed by a blank.

c) There is exactly one blank between two squares, whether represented by a letter and a digit, or a letter and a blank. No blank lines.

You may assume all input files to be correctly formatted, containing ‘D', 'E', 'G', 'J', 'P', and digits up to 6 as the only non-blank characters. A digit will not exceed the lifespan of the animal represented by its preceding letter.

5. Junit Classes

JUnit classes include AnimalTest, CircleOfLifeTest, DeerTest, EmptyTest, GrassTest, JaguarTest, JungleTest, LivingTest, and PumaTest. You need to implement all these classes.

Attachment:- Data Files.zip

Verified Expert

This project is about creating a game on circle of animals in Amazon jungle. animals are represented in NxN matrix.Program is implemented using java programming language. Junit test cases also written for all the class files.

Reference no: EM131842980

Questions Cloud

Ticking bombs-torutre and the analogy : Both Shue, in 'Torture', and Hill, in 'Ticking Bombs, Torutre, and the Analogy with Self-Defense' discuss situations under which torture may be morally justifie
The corresponding capitalization rate : the corresponding capitalization (cap) rate selected to determine its present value?
What is the definition of critical thinking : In philosophical terms, What is the definition of Critical Thinking. Describe how your definition of Critical Thinking differs from the definition of "truthines
Failures of the dominant view of terrorism : In 'Is Terrorism Distinctively Wrong?', Lionel K. McPherson concludes by insisting that "the failures of the dominant view of terrorism
Project - different forms of life in the amazon jungle : Com S 228 - Project simulates interactions among different forms of life in the Amazon jungle - lifespan of the animal represented by its preceding letter
Define key terms and concepts the author references : State the author's thesis and/or argument. Define key terms and concepts the author either references or introduces.
Unsuspecting people in interviews : A number of popular TV shows and films in recent years (e.g., The Daily Show, The Colbert Report, Da Ali G Show, Borat) have gotten big laughs by involving
Analyze a security issue surrounding globalization : Analyze a security issue surrounding globalization. Describe the security issue provide at least two probable solutions to this global security problem.
Identity is defined by repeated self-identification : How does John Locke, In his Essay Concerning Human Understanding, explains that the personal identity is defined by repeated self-identification?

Reviews

inf1842980

3/13/2018 6:10:46 AM

Can I get the solution by 11:00 pm? It is not an easy assignment to do expert need at least 40 to 45 hours to do this assignment but please try to deliver as soon as you can. Shall i use existing code or did you want new prog use the existing code plz Everything that need to write is given as a skeleton in the template (after //TODO). It is permitted to add things such as helper methods; and it would be best access modifier is set to 'private.' How is the assignment going? Could you send what the expert did so far to me? Since I need to submit the assignment one and half hour later. And the expert can send the complete draft after he finish. Can the thing to be done like this? Please find the attached part of the assignment.This is a game development not a simple project, I will send the remaining complete solution soon,Thanks! 27325287_1EM131842980_Part_Work.zip

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd