This implementation improves over this implementation, demonstrated in this video.
Valid user commands are:
- empty string (just pressing Enter) - proceed to the next generation
clear
- clear the boardrandom
- set the board to a random statex y
where x and y are numbers - toggle the cell at position (x, y) on/off (the coordinates are 0-based)
Also, a name of a predefined state can be used as a command - the predefined states are:
block
beehive
blinker
toad
beacon
glider
pentomino
TODO: add more predefined patterns
See the list here for the patterns.
Pressing F3 closes the program. Pressing F1 opens help screen.
- Allocate two 1D integer arrays of size WxH, one for the current state and one for the next state. Floating point matrices did not work because they introduce rounding errors.
- Initialize the current state with empty values.
- Display the current state.
- Wait for user input. Because of the platform limitations, user can enter only text. So the user can manually toggle on/off a given cell, clear the board, set the board to a predefined or random state, or just press Enter (no command) to proceed to the next generation. If the pressed key is not Enter but F3, the program exits.
- For each generation, calculate the next state based on the current state.
- Swap the current state with the next state. This is very fast because the arrays are accessed by reference.
- Go to step 3.
Cells out of the board are considered unpopulated.
You can use the FTP feature of Hercules to upload the code to MVS TK5. The code can be uploaded as a text file, and then you can use the RX
command to run it.
To start FTP on TK5, after the OS starts, run /s ftpd
command in the Hercules main console. Then duplicate the life.rexx
file into life
(without extension) and upload the file using FTP in ASCII mode. In the Linux command-line FTP client, this is done by:
- To duplicate the file
life.rexx
intolife
:cp life.rexx life
- To open the FTP client:
ftp localhost 2121
(after running this command, you should be prompted for username and password) - To list content of the currently active directory (or the root of the file system):
ls
- To enter the BREXX samples directory:
cd BREXX.V2R5M3.SAMPLES
- To set ASCII mode:
asci
- To upload the file with the game:
put life
. If the file already exists on the MVS system, this file will be overwritten. Uploading a file with.rexx
extension fails. - To close the FTP client:
quit