cs162_group_15_project_1's People
Forkers
scifanaticcs162_group_15_project_1's Issues
DoodleBug Move Function
For every time step, the doodlebug will firstly try to move to an adjacent cell containing an ant and eat the ant (you can decide if there are several ants in the adjacent cells, how the doodlebug will choose to move). If there are no ants in adjacent cells, the doodlebug moves according to the same rules as the ant. Note that a doodlebug cannot eat other doodlebugs.
- Determine Space to move to.
- Get Space from Board
- Check if Space is Occupied
- Check if Valid Space on Board
- Get Space from Board
- Remove Critter from Spaces
- Switch Spaces on Critter
Application Driver Function (Main Function)
Initialize the world with 5 doodlebugs and 100 ants. You will randomly place them on the grid. You will prompt the user to enter the number of time steps to run.
For each time step, do the following in your program: after moves, when breeding, eating, and starving are resolved, display the resulting grid. Draw the world using ASCII characters of “O” for an ant, “X” for a doodlebug and blank space for an empty space (the characters should be arranged to look like a grid). The doodlebugs will move before the ants in each time step. When you reach the time steps entered by the user, ask them to enter another number and start to run the simulation again or to exit the program. You must maintain the state of the current grid while creating the next display.
You should use a dynamic array to represent the grid. Each array element will be a pointer to a Critter. Get your program running and tested. You should see a cyclical pattern between the population of predators and prey, although random perturbations may lead to the elimination of one or both species.
For debugging your program, you should save the random placement until you have everything else working properly. In general, “random” is bad for testing and debugging.
DoodleBug Starve Function
Starve: If a doodlebug has not eaten an ant within three time steps, at the end of the third time step it will starve and die. The doodlebug should then be removed from the grid of cells.
DoodleBug Starve Function
DoodleBug Breed Function
If a doodlebug survives for eight time steps, at the end of the time step, it will spawn off a new doodlebug in the same manner as the ant (the Doodlebug will only breed into an empty cell).
- Figure out the location of the new Critter
- Create the Critter using the Board create Critter function. (Critter->GetSpace()->GetBoard()->createCritter())
Design, Reflection, and Test Cases
I think everyone should contribute to the test cases.
Create removeCritter function on Board
- Remove Critter from Space
- Remove Space from Critter
- Delete Critter from Board
- Downsize Critter Array
Ant Breed Function
If an ant survives for three time steps (not been eaten by doodlebugs), at the end of the time step (i.e., after moving) the ant will breed. This is simulated by creating a new ant in an adjacent (up, down, left, or right) cell that is empty randomly. If the cell that is picked is not empty, randomly attempt to pick another one. If there is no empty cell available, no breeding occurs. Once an offspring is produced, an ant cannot produce an offspring again until it has survived three more time steps.
getCritter function
A space should be able to contain a pointer to the Critter instance
Ant Breed Function
Remove Critter from Board
Ant Move function
For every time step, the ants randomly move up, down, left, or right. 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.
User input validation (utility function)
Whoever takes this card should also take the main function. It would be nice to contain all user input and validation in the main function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.