![]() After each time step, prompt the user to press Enter to move to the next time step. Initialize the world with 5 doodlebugs and 100 ants. You may need additional data structures to keep track of which critters have moved. This class should have a virtual function named move that is defined in the derived classes of Ant and Doodlebug. Create a class named Organism that encapsulates basic data common to both ants and doodlebugs. Write a program to implement this simulation and draw the world using ASCII characters of “o” for an ant and “X” for a doodlebug or "-" for an empty space. ![]() The doodlebug should then be removed from the grid of cells.ĭuring one turn, all the doodlebugs should move before the ants do. If a doodlebug has not eaten an ant within the last three time steps, then at the end of the third time step it will starve and die. If a doodlebug survives for eight time steps, then at the end of the time step it will spawn off a new doodlebug in the same manner as the ant. Note that a doodlebug cannot eat other doodlebugs.īreed. Otherwise, the doodlebug moves according to the same rules as the ant. Every time step, if there is an adjacent ant (up, down, left, or right), then the doodlebug will move to that cell and eat the ant. The doodlebugs behave according to the following model: Once an off-spring is produced, an ant cannot produce an offspring until three more time steps have elapsed. If there is no empty cell available, then no breeding occurs. This is simulated by creat-ing a new ant in an adjacent (up, down, left, or right) cell that is empty. If an ant survives for three time steps, then at the end of the time step (that is after moving) the ant will breed. ![]() If the neighboring cell in the selected direction is occupied or would move the ant off the grid, then the ant stays in the current cell.īreed. Every time step, randomly try to move up, down, left, or right. The ants behave according to the following model: Each critter performs some action every time step. The grid is enclosed, so a critter is not allowed to move off the edges of the world. Only one critter may occupy a cell at a time. These critters live in a world composed of a 20 × 20 grid of cells. In this simulation the prey are ants and the pred-ators are doodlebugs. "The goal for this Project is to create a simple two-dimensional predator-prey simulation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |