Ask a question from expert

Ask now

Project on Critter Simulation

10 Pages3584 Words307 Views
   

Added on  2019-09-13

Project on Critter Simulation

   Added on 2019-09-13

BookmarkShareRelated Documents
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 and get started right away.Write one method at a time and compile as you go.Learning ObjectivesAfter completing this project you should be able to:use ArrayLists to maintain and process collections of objects use two-dimensional arrays to maintain and process collections of objects develop an application with multiple interacting classes describe the concept of inheritanceClass InheritanceYou need a basic understanding of class inheritance to complete this project. Inheritance is a programming 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, dogs and monkeys have similar traits shared by other mammals. Instance members and methods shared 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 implement CIS 162 Project 5 – Fall 2016Page 1 of 10
Project on Critter Simulation_1
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 one step at 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 Location Critters exist in a 2D world using a row/column position. The world has a specified number of rows and columns (e.g. 50x50). Consider Figure 1, critter A is at row=1 and column=1 (1,1), B is 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 possible actions: roar, scratch, pounce or forfeit. Fight results include: 1) pounce beats roar, 2) roar beats scratch 3) scratch beats pounce and 4) forfeit loses to everything. You may be familiar with the (r)ock, (p)aper (s)cissors game? Use the initials to help you remember which attack strategy wins. The losing critter is removed from the simulation.Two critters of the same species do not fight if asked to share a location. Instead, they maintain 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? The simulation picks a random winner between the two and the unlucky one dies. CIS 162 Project 5 – Fall 2016Page 2 of 10
Project on Critter Simulation_2
Adding CrittersCritters are added to the world at random locations. The biologist can insert multiple critters of the 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 GUI CIS 162 Project 5 – Fall 2016Page 3 of 10
Project on Critter Simulation_3

End of preview

Want to access all the pages? Upload your documents or become a member.