Lisp in Life - Lisp Interpreter in Conway's Game of Life
Posted: December 22nd, 2021, 10:58 am
Hi everyone, it's my first time posting here.
I created Lisp in Life, a Lisp interpreter that runs on Conway's Game of Life.
The pattern is available at my GitHub repo: https://github.com/woodrush/lisp-in-life
The Lisp program is provided by editing certain cells in the pattern to represent the ASCII encoding of the program.
Therefore, the pattern can be programmed so that it runs your own Lisp program.
The standard output is written at the very end of the RAM module in binary ASCII format, which can easily be located and be directly examined in Golly.
In the GitHub repo, there are scripts for loading custom Lisp programs, and for viewing the output text.
The overall architecture is based on the Quest For Tetris project (https://codegolf.stackexchange.com/ques ... 673#142673).
This project uses an 8-state Life-like rule called VarLife as an intermediate layer, and encodes patterns created in VarLife to Conway's Game of Life (b3/s23) using OTCA Metapixels to create the Game of Life patterns.
Since the ROM and RAM sizes are both about 10 times larger than the original project, to let patterns to run in a reasonable amount of time, Lisp in Life involves lots of modifications over the original architecture. Some examples are: introducing a new lookup table architecture for the ROM, removing and adding new opcodes, extending the ROM and RAM address space, changing the ROM word size, etc.
The VarLife patterns can also be run in Golly. Short programs such as `(print (* 3 14))` runs in about 1 minute, and even more sophisticated programs such as object-oriented-like.lisp (https://github.com/woodrush/lisp-in-lif ... -like.lisp) can be run in about 20 minutes.
On the other hand, for the Game of Life version, due to the heavy use of OTCA Metapixels, `(print (* 3 14))` takes about 6 hours to evaluate. I'm currently running another short example (https://github.com/woodrush/lisp-in-lif ... ambda.lisp) but it is currently taking over 14 hours.
To make everything closed in the Game of Life space, I also included a script that can directly write Lisp programs into the metafied Conway's Game of Life pattern. This script directly edits the meta-states of the OTCA Metapixels in the Game of Life pattern to load the Lisp programs.
The Lisp interpreter is written in C, and is compiled using a modified version of the QFTASM backend of ELVM (the Esoteric Language Virtual Machine) (https://github.com/shinh/elvm).
The QFTASM backend in the original ELVM project was implemented by myself as well.
A large room for improvement and limitations is the running time, due to the heavy use of OTCA Metapixels.
If we could use a more simple and compact Game of Life-based architecture, I believe the running time could be significantly improved.
However, I believe that the technique of using ELVM to create simple assembly code and allowing access to C is powerful for letting Game of Life computers doing sophisticated tasks.
I created Lisp in Life, a Lisp interpreter that runs on Conway's Game of Life.
The pattern is available at my GitHub repo: https://github.com/woodrush/lisp-in-life
The Lisp program is provided by editing certain cells in the pattern to represent the ASCII encoding of the program.
Therefore, the pattern can be programmed so that it runs your own Lisp program.
The standard output is written at the very end of the RAM module in binary ASCII format, which can easily be located and be directly examined in Golly.
In the GitHub repo, there are scripts for loading custom Lisp programs, and for viewing the output text.
The overall architecture is based on the Quest For Tetris project (https://codegolf.stackexchange.com/ques ... 673#142673).
This project uses an 8-state Life-like rule called VarLife as an intermediate layer, and encodes patterns created in VarLife to Conway's Game of Life (b3/s23) using OTCA Metapixels to create the Game of Life patterns.
Since the ROM and RAM sizes are both about 10 times larger than the original project, to let patterns to run in a reasonable amount of time, Lisp in Life involves lots of modifications over the original architecture. Some examples are: introducing a new lookup table architecture for the ROM, removing and adding new opcodes, extending the ROM and RAM address space, changing the ROM word size, etc.
The VarLife patterns can also be run in Golly. Short programs such as `(print (* 3 14))` runs in about 1 minute, and even more sophisticated programs such as object-oriented-like.lisp (https://github.com/woodrush/lisp-in-lif ... -like.lisp) can be run in about 20 minutes.
On the other hand, for the Game of Life version, due to the heavy use of OTCA Metapixels, `(print (* 3 14))` takes about 6 hours to evaluate. I'm currently running another short example (https://github.com/woodrush/lisp-in-lif ... ambda.lisp) but it is currently taking over 14 hours.
To make everything closed in the Game of Life space, I also included a script that can directly write Lisp programs into the metafied Conway's Game of Life pattern. This script directly edits the meta-states of the OTCA Metapixels in the Game of Life pattern to load the Lisp programs.
The Lisp interpreter is written in C, and is compiled using a modified version of the QFTASM backend of ELVM (the Esoteric Language Virtual Machine) (https://github.com/shinh/elvm).
The QFTASM backend in the original ELVM project was implemented by myself as well.
A large room for improvement and limitations is the running time, due to the heavy use of OTCA Metapixels.
If we could use a more simple and compact Game of Life-based architecture, I believe the running time could be significantly improved.
However, I believe that the technique of using ELVM to create simple assembly code and allowing access to C is powerful for letting Game of Life computers doing sophisticated tasks.