Question

Game Of life

1. Change the size of the arrays:

const int MAX_ROW = 40;
const int MAX_COL = 80;

***Make sure that only global variables you have in your program are Max_ROW and MAX_COL. Move any global variables you declared to a function or functions.

***Make sure to update setNextGenArray(). Use the variable names, not 40 or 80.

***For testing, I will be changing the array size. Your program should work by only modifying the array size.

2. Use two-dimensional arrays (tempArray, currentArray) of type char, instead of type int.

3. Choose a character for live cells, and a character for dead cells.

4. When you start your program, it should display only dead cells.

5. Modify the menu to include the followings (you may change the menu and descriptions, but must contain all the following options):

Initial - 'I' to load the 'U' pattern.

Play - 'P' to play the game.

Stop - 'S' to stop the game.

Clear - 'C' to set the arrays to the dead cells.

Quit - 'Q' to exit the program

1) pattern1 name - '1' to load the pattern1.txt file to the screen. (Replace pattern1 name with an actual pattern name you have, ex: 1) spaceship ). The location of the loaded pattern should be randomized.

2) pattern2 name - '2' to load the pattern2.txt file to the screen. (Replace pattern2 name with actual pattern name you have, ex: 2) snake ).   The location of the loaded pattern should be randomized.

3) pattern3 name - '3' to load the pattern3.txt file to the screen. (Replace pattern3 name with actual pattern name you have, ex: 3) phython ).   The location of the loaded pattern should be randomized.

Custom - 'T' to create a pattern from the user's input (collect row and column numbers) and set each cell to a live cell.

Save - 'A' to save the current live cell pattern of the currentArray to a file; save the row and column numbers of the live cells. (You may allow the user to type a file name.)

Load - 'L' to load a saved file. (You may allow the user to type the file name the user wish to load.)

***Allow the user to type uppercase or lowercase characters.

6. Add three more patterns except the 'U' pattern. See the file below (do not use block and tub), or you may create your own patterns.   Present the different patterns (at least 3 using files - pattern1.txt, pattern2.txt, pattern3.txt) to the user in the menu (see 5), then allow the user to load those files; create a function to access each file (pass filename as a parameter to the function). Each file contains the row and column numbers of live cells.

block tub snake ship aircraf carrier beehive barge Python long boar eater, fishhook loaf

7. Define variables and functions as necessary.

OutPut:

After pressing "I" to load initial Pattern

After pressing "P" for play sets different type of pattern.

It randomizes pattern after pressing "play".

cleared the pattern by pressing "C" then 1 chose another pattern "1" spaceship

does the same after pressing "p" for play, creates a different space ship pattern and randomizes it.

The patterns can be different doesn't have to be the same with spaceship and diamond pattern. We get to choose w.e pattern we like; however, the initial patterns have to be the same, just randomized.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code:

// Header file section #include <iostream> #include <stdlib.h> #include <conio.h> #include <stdio.h> #include <ctime> // Decl

// Check the condition, if choice is p // then the followig methods will be called and executed accordingly. if (choice p) c// Define the setZeroArray( void setZeroArray (int arr[] [MAX_COL]) int i, j; j = 0; j < MAX-COL; j++) arr[i] [j]-o; // Defin

srand (time (NULL)); // Use rand() row = rand ( ) % 15; col = rand () % 30; // Use srand ) srand (1); int i; int j; for(1 = r

Add a comment
Know the answer?
Add Answer to:
Game Of life 1. Change the size of the arrays: const int MAX_ROW = 40; const...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Objective: Write a program that implements the Game of Life cellular automata system invented by John...

    Objective: Write a program that implements the Game of Life cellular automata system invented by John Conway. 1. Create two game grids of size at least 50x50. These grid cells can be either Boolean or integer. In the following, I’ll refer to these as gridOne and gridTwo. 2. Set all cells in both grids to false. 3. Start by initializing gridOne. Allow the user to specify two different ways of initializing the grid: 1) by specifying a pattern file to...

  • Using python 3.7.3 Challenge: Rock, Paper, Scissors GamePDF Description: Create a menu-driven rock, paper, scissors game...

    Using python 3.7.3 Challenge: Rock, Paper, Scissors GamePDF Description: Create a menu-driven rock, paper, scissors game in Python 3 that a user plays against the computer with the ability to save and load a game and its associated play statistics. Purpose: The purpose of this challenge is to assess the developer’s ability to create an interactive application with data persistence in Python 3. Requirements: Create a Rock, Paper, Scissors game in Python named rps.py according to the requirements specified in...

  • Program in C++ Implement Conway's Game of Life using 2-dimensional arrays. All the tips, tricks, techniques...

    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...

  • Option 2: Conwav's Game of Life Your task is to write a program that plays Conway's...

    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...

  • I am really struggling with how to approach this program. Conway's Game of life, whereby, 1....

    I am really struggling with how to approach this program. Conway's Game of life, whereby, 1. Any live cell with fewer than two live neighbours dies, as if caused by under-population. 2. Any live cell with two or three live neighbours lives on to the next generation. 3. Any live cell with more than three live neighbours dies, as if by over-population. 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. Submit...

  • Java Inventory Management Code Question

    Inventory ManagementObjectives:Use inheritance to create base and child classesUtilize multiple classes in the same programPerform standard input validationImplement a solution that uses polymorphismProblem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes...

  • I'm working on the following: Write a python program: 1. Write the definition of the function...

    I'm working on the following: Write a python program: 1. Write the definition of the function displaySubMenu that displays the following menu; this function doesn't collect the user's input; only display the following menu.: [S]top – Press 'S' to stop. 2. Write the definition of the function setNextGenList that creates a pattern of next generation (tempGen) based on the current generation (currentGen); modify the tempGen based on the currentGen by applying the rules of Game of Life. Conway's Game of...

  • DO NOT use #include <cstdlib> , iterate, and list. USE pointers and arrays. 1.Define a class...

    DO NOT use #include <cstdlib> , iterate, and list. USE pointers and arrays. 1.Define a class named Family in a header file named: family.h (5 points) This file acts as a prototype. 2.Create the implementation file family.cpp (15 points total) a.The class will have the following members 1.Family name (5 points) 2. Parent (array of 2) (5 points) a.First Name b.Last Name c. Age (you must validate the age is the proper data type. You can use the code from...

  • InventoryManagement

    Problem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes re-ordering the menu items and making changes to the description of a menu item without having to change the code.Security:The company has...

  • Many of us have large digital music collections that are not always very well organized. It...

    Many of us have large digital music collections that are not always very well organized. It would be nice to have a program that would manipulate our music collection based on attributes such as artist, album title, song title, genre, song length, number times played, and rating. For this assignment you will write a basic digital music manager (DMM). Your DMM program must have a text-based interface which allows the user to select from a main menu of options including:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT