Just looking for some advice on how to tackle this problem. I'm currently writing a program to simulate Conway's Game of Life using Atari 68k ASM
A brief summary of the Game of Life:
- Given starting points pixels on the screen are set to become "alive" ( in my case, characters in my 2D array are changed from a '-' to a '@'
- Based on how many "living" neighbors are located in the 8 spaces around each spot in the array will determine if that pixel becomes alive or dead in the next generation
Basically what I need help with is that I start out with an empty 2D array initialized as '-'
To start the first generation the points to be switched as alive('@'') are located in a .txt file
Just needing some help on how to read this .txt and swap according spaces from '-' to '@'
**************************************************************************************************************************
The user is to be prompted for the path to the data file; the maximum length of this path, including
the filename itself, is to be 50 characters. Atari filenames are at maximum 12 characters, which
includes the dot and 3-character extension. Remember that this string MUST be null-terminated.
would like to use GEMDOS commands if possible
data in the .txt file comes in as
row<space>column<CR><LF>
Working C++ Code Here:
void load_array (char startboard[MAX_ROWS][MAX_COLS], char filename[])
{
bool success = true;
char row;
int col;
int row_num;
ifstream infile;
cout << "Please enter the filename to open: <<endl;
cin >> filename;
infile.open(filename);
if(infile.fail.())
{
success = false;
cout << "File Not Opened." << endl;
}
else
{
while(!infile.eof())
{
infile >> row;
row_num = row - 'a'; // converts the character used as a coordinate for the "row number" into an actual number by subtracting from ASCII 'a'
infile.ignore();
infile >> col;
infile.ignore();
infile.ignore();
startboard[row_num][col] = ALIVE // ALIVE is a constant set to equal '@'
}
}
}
TY MUCH
This post was edited by SoF_Legacy2 on Dec 7 2013 03:50pm