Project on Critter Simulation

Added on - 13 Sep 2019

  • Dissertation

    type

  • 10

    pages

  • 3584

    words

  • 179

    views

  • 0

    downloads

Showing pages 1 to 3 of 10 pages
Critter SimulationProject Due DateThe latest submission for this project is the last day of classesBefore Starting the ProjectThis is a complex project! It is important that you read this entire project description andget started right away.Write one method at a time and compile as you go.Learning ObjectivesAfter completing this project you should be able to:useArrayLists to maintain and process collections of objectsusetwo-dimensional arrays to maintain and process collections of objectsdevelopan application with multiple interacting classesdescribethe concept of inheritanceClass InheritanceYou need a basic understanding of class inheritance to complete this project. Inheritance is aprogramming strategy used when multiple classes are similar to each other. For example, trucks,cars and dune buggies all have similar characteristics shared by many vehicles. Elephants, dogsand monkeys have similar traits shared by other mammals. Instance members and methodsshared by all classes are combined into a special class called the base class.public class DerivedClass extends BaseClass{// define instance variables shares by all derived classes// define methods shared by all derived classes// define virtual methods if a derived class must implementCIS 162 Project 5 – Fall 2016Page1of10
Our Critter SimulationComputers are often used to simulate complex scenarios such as weather patterns, nuclearreactions, climate change and potential spread of infectious diseases. For this project you willcreate an application to simulate critters moving, fighting and dying in a two-dimensional world.A biologist can use the simulation to study migration patterns in natural habitats. The simulationsupports five species: ants, birds, hippos, vultures and a species of your own design. Eachspecies moves in a unique pattern and it fights to the death when encountering other species.The simulation moves forward onestepat a time. During each step, every critter has anopportunity to move one space and fight if it encounters another critter. Once started, thesimulation continues forever but the biologist can pause and resume the simulation as desired.Critter LocationCritters exist in a 2D world using a row/column position. The world has a specified number ofrows and columns (e.g. 50x50). Consider Figure 1, critter A is at row=1 and column=1 (1,1), Bis at location (5,4) and C is at location (2,5).01234501A2C34D5BFigure 1. 2D simulation worldCritter MovementCritters attempt to move to a neighboring location during each simulation step. Possibledirections include north, south, east and west. For example, a move to the east increases thecritter's column position by one. A move to the west decreases the column position by one. If acritter attempts to step off the world's edge it reenters from the opposite edge. For example,critter C is currently at location (2,5). Moving East would cause the critter to leave the worldand reenter from the left at location (2,0).Critter FightsCritters of different species fight if they share a location. They attack using one of four possibleactions: roar, scratch, pounce or forfeit.Fight results include: 1) pounce beats roar, 2) roar beats scratch 3) scratch beats pounceand 4) forfeit loses to everything. You may be familiar with the (r)ock, (p)aper (s)cissorsgame? Use the initials to help you remember which attack strategy wins. The losingcritter is removed from the simulation.Two critters of the same species do not fight if asked to share a location. Instead, theymaintain their current locations and do not move during the current step.But what if two critters use the same attack strategy and are from different species? Thesimulation picks a random winner between the two and the unlucky one dies.CIS 162 Project 5 – Fall 2016Page2of10
Adding CrittersCritters are added to the world at random locations. The biologist can insert multiple critters ofthe same species. For example, ten birds could be added followed by thirty hippos.Simulation ResultsAt every step during the simulation, multiple critters will be seen in the world along with up-to-date statistics for each species (Figure 2).Figure 2. Simulation GUICIS 162 Project 5 – Fall 2016Page3of10
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document