Download presentation
Presentation is loading. Please wait.
1
Programming Assignment #6
Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan and Ritchie, Absolute C++, by Walter Savitch, The C++ Programming Language, Special Edition, by Bjarne Stroustrup, and from C: How to Program, 5th and 6th editions, by Deitel and Deitel) CS-2303, A-Term 2012 Programming Assignment #6
2
Programming Assignment #6
Design and implement a simple predator-prey simulation At least one abstract base class and at least two derived classes Virtual functions in the base calls Concrete implementations in each of the derived classes This is Project #3 of Chapter 15 of Absolute C++ CS-2303, A-Term 2012 Programming Assignment #6
3
Programming Assignment #6
Simulation N-by-N grid of cells Each cell may be occupied by at most one organism Two types of organisms Ants Doodlebugs Simulate a sequence of steps Each step represents an action by each organism CS-2303, A-Term 2012 Programming Assignment #6
4
Programming Assignment #6
Simulation steps Ants Doodlebugs Move:– Try to move in random direction Up, down, left, righ If occupied, stay put No moving off edge of grid Breed:– If survive >= 3 steps Give birth to new ant in adjacent cell No empty cell, no birth Move:– Move to adjacent cell with ant Eat ant If no ant, move to empty cell If no empty cell, stay put Breed:– If survive >= 8 steps Give birth in adjacent cell No empty cell, no birth Starvation:– If no eat in 3 steps, die CS-2303, A-Term 2012 Programming Assignment #6
5
Programming Assignment #6
Implementation Any design for implementing grid E.g., array of C++ vectors C-style 2-D array (as in Game Of Life) Anything else appropriate Size determined at run time Grid elements are organism * Null pointer empty cell Invoke move() method of non-empty cell move() method may invoke other methods E.g., eat, breed, etc. CS-2303, A-Term 2012 Programming Assignment #6
6
Implementation (continued)
Command Line arguments ./PA5 gridSize #doodlebugs #ants seed for random # gen.Need a way to stop simulation Need a way to have simulation pause and print in real time CS-2303, A-Term 2012 Programming Assignment #6
7
Programming Assignment #6
Teams Optional two-person teams May not be same teams as previous projects Due Sunday, October 11:59 PM CS-2303, A-Term 2012 Programming Assignment #6
8
Programming Assignment #6
Questions? CS-2303, A-Term 2012 Programming Assignment #6
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.