I am getting compiler errors
Really? That's too bad. Could you turn your screen a little left so I can see what the errors are?
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Okay. Here is what I currently got so-far:
...snipped...
Their is no errors.
With the code posted, there (note the spelling) is nothing for us to help with -- code-wise.BUT how do I do it like what the assignment says???
1) By thinking about the problem, coming up with questions that need to be answered, answering the questions,
2) understanding the project
3) designing a solution based on your understanding,
4) programming based on the solution,
5) killing any bugs because you missed something in the design.I know I am required to use 2D arrays and 3+ functions.
How many arrays do you think you need?
What would you use them for?
This is part of the design...
What does the program as a whole need to do -- from start to finish?
What steps can be logically done by functions?
Another part of the design.Conway's Game of Life
For this assignment your are to write a program, that plays Conway's game of Life. See the Wikipedia definition, if
you have never played the game: http://en.wikipedia.org/wiki/Conway's_Game_of_Life .
Here is how our implementation will work:
(1) The program will ask the user to enter a filename from the console. (Just like the last assignment).
(2) The initial configuration will be read in from a file, which will be a 12 by 30 two-dimensional array of characters. The game board will be surrounded by all O's.
(3) The game will be played on 10 by 28 two-dimensional array. (Can you guess why?). A period ('.') will represent a dead cell and an 'X' will represent a live cell.
You will be severely penalized if your program does not have at least three functions.
Part of the design (a small part) is listed here.
What tasks can be made into functions based on the above description?
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
I really need help finishing this assignment. I am really confused.
With what? Just posting your completely unformatted code and telling us you're confused gives us nothing to help you with.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
single
that is a single vairable called single
1dArray[x]
is a single element of 1dArray at index x, of whatever type is used to declare 1dArray
2dArray[r][c]
is a single element of 2dArray having indexes r and c (convenient shorthand for row and column). 2dArray can be declared using any valid type
If single, 1dArray and 2dArray were all declared with type char, then you could directly compare individual elements of any of them using the equality operator, or any other valid operator available to the char class. For example is is valid to do this:
if(single == 2dArray[r][c])
or this:
if(2dArray[r][c] == '.')
etc.
The rules of the game of life vary by who is implementing the strategy. All of the strategies involve looking at the "surrounding environment". Sometimes the surrounding environment is the cell above, below, to the right and to the left, and sometimes the surrounding element is any cell in the arrya that touches the current cell (the full face cells top/bottom/right/left and the 4 corners). There is a mathematical relationship between the current cell and the one above it: if the current cell has indexes r and c then the one immediately above it has indexes r - 1 and c. The one to left of current cell is r and c + 1.
I'll leave it to you figure out the indexes for the cell below, the cell to the left and the cells at the cornes of the current cell.
Once you can access the cells in the surrounding environment you need to access where the cells in the surrounding environment are valid and if so how to use the information contained within the valid surrounding cells in the current generation are used to determine the status of the current cell in the new generation.
You will want to determine if the new generation numbers come about as a static interaction from the prior generation or whether the new generation is influenced by the new members of the new generation as well as the unchanged old members of the currrent generation. One version needs two arrays, and the other only needs one.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396