Program of bug simulation , JAVA Programming

Assignment Help:

You will be creating a World that consists of ants and doodlebugs. Each time you click the board each bug will do some of the following: move, bread, eat, and starve.

Ants will function in a certain way, and doodlebugs in another.

This assignment is based on Absolute Java.

900_Bug Simulation 1.png

Bug Rules

Ants

Move

  1. Every time step the ant will attempt to move.
  2. Pick a random direction using a random generator (up, right, down, or left).
  3. If the space is on the grid, and not occupied then the ant will move there.

Breed

  1. If an ant survives 3 time steps he will attempt to breed.
  2. He breeds by creating a new ant in a space adjacent to himself.
  3. If there is no empty space adjacent to himself to breed then he will not do so.
  4. He will then wait 3 more time steps until tries to breed again.

Doodlebugs

Move

  1. Every time step the doodlebug will move.
  2. First he will check out each direction. If there is an ant in an adjacent space he will move there (consequently taking up the ants space and eating him!)
  3. If there was no ant in an adjacent space he will move just like ants do.
  4. Note: doodlebugs can't eat other doodlebugs

Breed

  1. If a doodlebug survives 8 time steps he will attempt to breed.
  2. He breeds in the same manner as an ant.

Starve

  1. If an ant has not eaten an ant within the last 3 time steps, then at the end of the last time step he will die of starvation. You will remove him from the grid.

UML

Ants and Doodlebugs will extend from a generic Organism.

Create a UML diagram for the Organism, Ant and Doodlebug. This diagram may change as you develop your design, but having a basic flow will greatly help in the implementation.

Provided Files

  1. World.java
  2. Organism.java
  3. Ant.java
  4. Doodlebug.java
  5. ant.png
  6. doodlebug.png

Word

Methods you will use in your classes. Don't modify this class.

public Organism getAt(int x, int y)

  1. Returns the Organism at the x, y position in the grid.
  2. If there is no organism it returns null

public void setAt(int x, int y, Organism bug)

  1. Sets the entry at the x, y position in the grid to the specified organism

public boolean pointInGrid(int x, int y)

  1. Returns true if the point x, y is in the grid and false if it goes beyond the grid space (e.g. if x = -1 that is not in the grid)

Images

  1. Put the two images in an images folder within your src

What you need to edit

  1. Organism.java
  2. Ant.java
  3. Doodlebug.java

Organims

Here are the methods that the World calls on the Organisms. I assume you will want to make more methods, such as move...

Organism(World world, int x, int y)

  1. Creates a new Organism
  2. The coordinates in the grid (X and Y) are required so you can pick a new location relative to its current to move to, and breed at.
  3. The World is required so you can call methods like getAt(x, y), setAt(x, y), and pointInGrid(x, y) on it.

public abstract String toString()

  1. This method is written for you
  2. Returns the string representation of the organism ("ant", "doodlebug"). Used by the World to determine which type of organism it is.

public void resetSimulation()

  1. This method has been written for you
  2. You will need to keep track of weather the organism has simulated this time step or not in an attribute of the class. This is important as it stops an organism from moving to a new place in the grid and then simulating again.

public boolean simulate()

  1. This will set the attribute that keeps track of weather it has simulated to true. This method returns true if it simulates, and false if it doesn't (has already simulated)
  2. If the organism was created this time step don't do the rest
  3. Call move, then breed, then starve (only for doodlebugs).
  4. You will then increment a time step counter

Ant and DoodleBug

  1. I want you to figure out what goes here

Related Discussions:- Program of bug simulation

How much cpu time does an applet get, How much CPU time does an applet get?...

How much CPU time does an applet get? One of the few legitimate concerns about hostile applets is excessive use of CPU time. It is possible on a non-preemptively multitasking s

What is the data normalization also define its goal, What is the Data Norma...

What is the Data Normalization? Also define its goal. Data normalization is to sort out complex data within easy form. It uses to simplify the complex information to form it mo

Android app development, Android App Development Project Description: ...

Android App Development Project Description: I am seeking a developer who can start an app from scratch and get it delivered to me as soon as possible. It is a minute android

Simple Tasks, Use a FOR loop and give me the largest number divisible by 7 ...

Use a FOR loop and give me the largest number divisible by 7 11 13 17 use the number from 1 to 10000 (or even 100000)

What is a local member and a class variable, What is a local, member and a ...

What is a local, member and a class variable? Variables declared within a method are "local" variables. Variables declared within the class i.e not within any methods are "m

What is the function of network interface card, What is the function of Net...

What is the function of Network Interface Card? NIC is an I/O device which plugs within the computer and it enables it to communicate over a network.

Explain the term- strings, Explain the term- Strings A string is genera...

Explain the term- Strings A string is generally considered to be a sequence of characters stored in memory and accessible as a unit. Strings in java are signified as objects

Write complete application to play game tic-tac-toe, (Tic-Tac-Toe)  Create...

(Tic-Tac-Toe)  Create class TicTacToe that will enable you to write a complete application to play the game of Tic-Tac-Toe. The class contains a private 3-by-3 rectangular array o

Describe about the term access protection, Describe about the term Access P...

Describe about the term Access Protection ? Global variables are a typical cause of bugs in most programming languages. A few unknown function can modify the value of a variabl

Write Your Message!

Captcha
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