C++ Game of Life Project
$30-250 USD
Bezahlt bei Lieferung
A variation on the Conway's Game of Life
In this assignment you will implement a variation of Conway's Game of Life, let's call it the CIS330 Game of Livestock. You do not have to reuse any of the farming-related code from lectures, a much simpler representation would suffice.
Here is a description of the rules:
The universe of the Game of Livestock is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of four possible states.
A cell can be empty or dead
A cell can have a sheep in it
A cell can have a wolf in it
A cell can have a farmer in it
Every cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
If a cell contains a sheep and is surrounded by more than three sheep neighbors, the cell dies (becomes empty) by overpopulation.
If a cell contains a sheep and has at least one wolf as neighbor, the cell dies (becomes empty) by predation.
If a cell is empty and surrounded by exactly two neighbors of the same species, it is modified to contain a new instance of that species (reproduction). If a cell has two neighbors of more than one species, then the order in which they should be considered is sheep, wolf, and finally farmer.
If a cell contains a wolf and has at least one neighbor who is a farmer, the cell dies (becomes empty).
If a cell contains a farmer and has at least one empty neighbor cell, it moves to a randomly selected empty neighbor cell. If there is no empty neighbor cell, the farmer cell remains the same.
Problem 1
Implement the Game of Livestock by defining a Game class in files [login to view URL] and game.cpp. Your class should include methods for
Create an initial set of randomly selected cell values in the 2-D rectangular grid: empty, sheep, wolf, farmer.
Perform a transition according to the rules above for each time step.
Run the game by performing a certain number of steps, which are specified as a parameter.
You can add any other methods or additional classes that you may need.
Use STL containers to represent the grid, for example a vector of vectors of char, where 'S' designates a sheep, 'W' designates a wolf, and 'F' designates a farmer (and '.' designates an empty cell).
Create a Makefile to compile your source files into .o files.
Required files: Makefile, [login to view URL], [login to view URL]
Problem 2
Implement a test program in a file called [login to view URL] and update the Makefile to build a test-game executable. The program should prompt for user input as follows:
./test-game
Please enter the size of the grid (int int): 20 20
Please enter the number of steps (int): 10
then instantiate and initialize a Game object with the user-provided parameters and run the game for the number of steps given, printing the grid at each step.
Required files: [login to view URL], Makefile
Projekt-ID: #5487134
Über das Projekt
5 Freelancer bieten im Durchschnitt $110 für diesen Job
I'm fluent in C++ and can do this project in 1 or 2 days. Let me know if you have any extra details on the project and the deadline.
Hello, I'm 7 years experience in PHP and 5 years experience in C/C++, so I can lead this project quickly and reliably. Thank you to hire me :)