#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main() {
srand(time(NULL)); // GET RANDOME SLOTS EVERYTIME
char **arr; // 2D ARRAY
int m,n,g;
cout<<"Enter values *(m),(n),(g): ";
cin>>m>>n>>g; // GET INPUT
arr = new char *[m]; // SET ROWS
for(int i=0;i<m;i++){
arr[i]= new char[n]; // SET COLUMNS
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
arr[i][j]='.'; // INTIALIZING WHOLE AS DEAD
}
}
int extraM,extraN;// EXTRA VARAS
int count=0;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(count==g){ // IF IT IS EQUAL TO GENERATION BREAK THE LOOP
break;
break;
}
extraM= rand()%m; // GET RANDOME POSITIONS FOR GENERATIONS
extraN = rand()%n;
arr[extraM][extraN]='*'; // SET THEM
// cout<<"{"<<extraM<<" "<<extraN<<" }"<<endl;
count++;
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<arr[i][j]<<" "; // PRINT THE GAME
}
cout<<endl;
}
}
OUTPUT:
IF YOU HAVE ANY QUERY PLEASE COMMENT DOWN BELOW
PLEASE GIVE A THUMBS UP
using c++ program the following The Assignment For this assignment, we are asking you to implement...
Program in C++ Implement Conway's Game of Life using 2-dimensional arrays. All the tips, tricks, techniques we have been using in class are allowed. Nothing else. The program should read the initial state of the board by reading in "alive" cells from a user input data file. Meaning your program should ask the user the name of the data file. Assume all the other cells are "dead." Make sure to use modular coding techniques. The main program should be pretty...
I have a question about my assignment. Could you please make program and give me some explanation of codes? I need c++ codes. Conway's Game of Life is a game invented by mathematician John Conway in 1970. The rules are as follows: Each cell lives in a cell in a square (make it 10x10) grid. A cell can either be dead or alive. Before you start the game, you need to provide an initial state. You can do this by...
I have a question about my assignment. Could you please make program and give me some explanation of codes? Conway's Game of Life is a game invented by mathematician John Conway in 1970. The rules are as follows: Each cell lives in a cell in a square (make it 10x10) grid. A cell can either be dead or alive. Before you start the game, you need to provide an initial state. You can do this by randomly setting 20 of...
Write this Game of Life program in Java. The Game of Life is a well-known mathematical game that gives rise to amazingly complex behavior, although it can be specified by a few simple rules. Here are the rules. The game is played on a rectangular board. Each square can be either empty or occupied. At the beginning, you can specify empty and occupied cells using 1's and 0's; then the game runs automatically. In each generation, the next generation is...
Write this Game of Life program in Java. The Game of Life is a well-known mathematical game that gives rise to amazingly complex behavior, although it can be specified by a few simple rules. Here are the rules. The game is played on a rectangular board. Each square can be either empty or occupied. At the beginning, you can specify empty and occupied cells using 1's and 0's; then the game runs automatically. In each generation, the next generation is...
Please use Java for this question. Input Format Format for Custom Testing Input from stdin will be processed as follows and passed to the function In the first line, there is a single integer n. In the second line, there is a single integer m. In the ph of the next n lines there are m space-separated integers denoting the throw of the initial grid. In the next line, there is a single integer k. In the next line,...
Please use C++, thank you! The life game consists of a board with size of NxN cells and cells are occupied by creatures. Each cell can have at most one creature. The surrounding cells are called the neighbors of this cell Each game state is called "generation". The game progresses from one generation to the next according to the following rules: A creature that has more than 3 neighbors- dies of crowding. Its cell will be empty in the next...
Hi, PLEASE I need the code in C programming, (USING THE SAME INPUT AND OUTPUT FORMAT DESCRIBED BELOW). Title: Game of Life Description In this assignment, you will code a simulation called "Game of Life". It is a very famous 'game' and the formed the basis of an entire field of simulation models called "cellular automata". Before continuing reading this assignment, I suggest you read a bit more about Game of Life at: https://en.wikipedia.org/wiki/Conway's_Game_of_Life or http://www.math.com/students/wonders/life/life.html (the latter also has...
You are going to be implementing the classic computer science simulation, Conway's Game of Life. Conway's Life is played on a matrix of cells, kind of like a chess board but theoretically extending infinitely in every direction. Each individual cell in the matrix can either be alive or dead. A live cell in the matrix is shown in our simulation by printing an asterisk (*) to the screen. A dead cell is shown by leaving that area of the matrix...
Option 2: Conwav's Game of Life Your task is to write a program that plays Conway's Game of Life (for details and ex amples, see https://en.vikipedia.org/wiki/Convay's.Game of Life). The basic gam ts played on each generation, each cell changes according to the following instructions: nal grid of square cells, each of which is either alive or dead. With 1. Any dead cell with exactly three live neighbors (out of its eight nearest neighbors) comes to life [reproduction]. 2. Any live...