Translating python golly script to lua with ChatGPT

For general discussion about Conway's Game of Life.
Post Reply
User avatar
simsim314
Posts: 1823
Joined: February 10th, 2014, 1:27 pm

Translating python golly script to lua with ChatGPT

Post by simsim314 » January 20th, 2023, 1:55 am

I've installed a new golly on a new computer, and needed to convert LifeHistory state to Life. Golly has no LifeHistory2Life converter built-in at all, so I remembered my long ago written python script that creates a simple rule to convert LifeHistory to Life (and thus using golly computational power instead of doing it from inside the script), and running the Rule for one generation.

Obviously I was too lazy to download python39.dll to run python scripts from golly, so instead I used ChatGPT to convert the python script to lua. ChatGPT knows well about golly. Here is it reaction to the post of the script mentioned above:

ChatGPT: This script is written in Python and is intended to be used with the Golly cellular automaton software. It creates a new rule file called "LifeHistory2Life.rule" in the Golly "rules" directory and sets the current rule to this new rule. The new rule has 7 states and uses the von Neumann neighborhood. It then runs the simulation for one generation. After that, it sets the rule to "B3/S23" (Conway's Game of Life) and sets the algorithm to "HashLife" and preserves the step. The purpose of this script is to convert a cellular automaton simulation that uses the "LifeHistory" rule to the standard "Life" rule.

Pretty impressive I would say. Yet the lua conversion didn't went smooth, I needed to build a query format, the one that worked looks as follows:

My prompt: create golly lua script from python:
python script:
<Your Script Here>
----
lua syntax example:
<Any lua script from golly (Golly->Scripts->Lua->Right Click)>

And the result for the mentioned script in lua (it was the first output from ChatGPT posted as code snippet) - you can run it in lua as it came out from chatGPT in the code snippet using golly->file->run clipboard:

Code: Select all

local g = golly()
local fname = g.getdir("rules").."LifeHistory2Life.rule"

if not(string.sub(g.getrule(),1,11)=="LifeHistory" or g.getrule()=="HistoricalLife" or g.getrule()=="CBRLife") then
   g.exit()
end

local file = io.open(fname, "w")
file:write("@RULE LifeHistory2Life\n")
file:write("\n")
file:write("@TABLE\n")
file:write("n_states:7\n")
file:write("neighborhood:vonNeumann\n")
file:write("symmetries:none\n")
file:write("\n")
file:write("var a={0,1,2,3,4,5,6}\n")
file:write("var b={a}\n")
file:write("var c={a}\n")
file:write("var d={a}\n")
file:write("var f={a}\n")
file:write("\n")
file:write("1,a,b,c,d,1\n")
file:write("2,a,b,c,d,0\n")
file:write("3,a,b,c,d,1\n")
file:write("4,a,b,c,d,0\n")
file:write("5,a,b,c,d,1\n")
file:write("6,a,b,c,d,0\n")
file:close()

g.setrule("LifeHistory2Life")
g.run(1)
local step = g.getstep()
g.setrule("B3/S23")
g.setalgo("HashLife")
g.setstep(step)
ChatGPT:
It is worth noting that the Golly Lua API provides similar functionality to the Golly Python API, so most of the code can be copy-pasting...


It's clear that ChatGPT is aware of golly and some tools of this community, including golly api. It's also clear it can translate python to lua, given lua example, but not without it.

This thread could be both a beginning of discussion about using ChatGPT for other needs and scripts and tools we have. Like maybe we can convert the golly scripts to calcyman's script library in c++, that works faster. Or we can also convert some python scripts to lua, that were long needed and no one had time to convert.

Other more advanced version of the idea might be fine tune gpt2/gptj on calcyman's API with several samples etc. etc.

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Translating python golly script to lua with ChatGPT

Post by dvgrn » January 20th, 2023, 8:32 am

Wow! I''ve been on the waiting list to talk to ChatGPT for a while now, but they haven't let me in yet -- too many interested people, I guess.
simsim314 wrote:
January 20th, 2023, 1:55 am
Golly has no LifeHistory2Life converter built-in at all, ...
It seems that ChatGPT doesn't know _quite_ enough about Golly to tell you what it would have told you if it was a superintelligent all-knowing AI.

Specific converters like LifeHistory2Life.py were made obsolete a few versions ago by a generalized "Super" algo that supports Super, History, and Standard versions of any isotropic Moore-neighborhood rule. That way you don't need separate converters for Life, HighLife, Snowflakes, etc., etc., and you can get multistate functionality for all rules without proliferating rule tables.

The built-in Lua script is called "toStandard.lua", and it does work on LifeHistory. If you have a new Golly installation rather than an upgrade, then the Alt+J keyboard mapping should be set up for you:

Code: Select all

-- Fast [Rule][History|Super] to [Rule] converter by Michael Simkin,
--   intended to be mapped to a keyboard shortcut, e.g., Alt+J
...

User avatar
simsim314
Posts: 1823
Joined: February 10th, 2014, 1:27 pm

Re: Translating python golly script to lua with ChatGPT

Post by simsim314 » January 20th, 2023, 10:29 am

dvgrn wrote:
January 20th, 2023, 8:32 am
Wow! I''ve been on the waiting list to talk to ChatGPT for a while now, but they haven't let me in yet -- too many interested people, I guess.
I think it's open and free for anyone. What happens when you enter here? You only need to login with google or wtr. You can also try openai's playground it should be free as well (for first several generations). It's a text completion tool, a little bit less fun than a chat but already exist more than a years in available to everyone format. Worst case you have meta's demo.
dvgrn wrote:
January 20th, 2023, 8:32 am
to tell you what it would have told you if it was a superintelligent all-knowing AI
Yes it has limitations, it doesn't know everything, but it's easy to know when it knows something. Like it knows you for example (I guess you have more trace on the internet than Alt+J shortcut):

Who is dvgrn?

Dvgrn is the online pseudonym of David Greene, a software engineer and hobbyist programmer who has made significant contributions to the field of cellular automata and Conway's Game of Life. He is a member of the LifeWiki community, where he provides advice and guidance to other users. He is also the creator of the popular "Life Lexicon," a comprehensive dictionary of terms related to Conway's Game of Life.


I think we can find a lot of uses to ChatGPT programming abilities, but maybe we can do something else with it as well...
dvgrn wrote:
January 20th, 2023, 8:32 am
Alt+J keyboard
Thanks for the tip.

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Translating python golly script to lua with ChatGPT

Post by dvgrn » January 20th, 2023, 11:27 am

simsim314 wrote:
January 20th, 2023, 10:29 am
I think it's open and free for anyone. What happens when you enter here? You only need to login with google or wtr.
You must have gotten in when they weren't "at capacity", and now you're recognized and allowed back in. Here's what I see at the moment:
ChatGPT is at capacity right now
Get notified when we're back
Write two truths and a lie about the status of ChatGPT.
1. ChatGPT is experiencing high traffic at the moment.
2. The developers are working hard to accommodate all users.
3. ChatGPT can predict the future with 100% accuracy.
I'm on the notification list, so we'll see how long it takes them to catch up with the surge in interest!
simsim314 wrote:
January 20th, 2023, 10:29 am
Dave Greene ... is also the creator of the popular "Life Lexicon," a comprehensive dictionary of terms related to Conway's Game of Life.
Heh, that shows up another imperfection or two in ChatGPT's source data. I wonder if the Life Lexicon can really be called "popular" any more... The LifeWiki is really the place to go these days, and the Lexicon is more just a handy lookup table inside Golly. (And I didn't create the Life Lexicon -- that was Stephen Silver.)

User avatar
simsim314
Posts: 1823
Joined: February 10th, 2014, 1:27 pm

Re: Translating python golly script to lua with ChatGPT

Post by simsim314 » January 20th, 2023, 5:11 pm

dvgrn wrote:
January 20th, 2023, 11:27 am
I'm on the notification list
And how about gpt3? It's not a chat but a text completion engine, but it gives 95% similar results. ChatGPT is a little bit overhyped, openai gives you some credit for free to start playing around with gpt3.
dvgrn wrote:
January 20th, 2023, 11:27 am
shows up another imperfection or two in ChatGPT's source data
It's a text generator, it could know something but generating the correct text will take several trials. You can say it's a statistical guess based on texts with primer of dvgrn. Anyway the Life Lexicon page states it maintained by you.

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Translating python golly script to lua with ChatGPT

Post by dvgrn » January 21st, 2023, 7:53 pm

I found my way in to ChatGPT today:
What is the best way to find a period-19 oscillator in Conway's Game of Life?

There are different methods to find a period-19 oscillator in Conway's Game of Life, but some common approaches include:

Searching through known oscillator patterns: There are databases of oscillator patterns that have been discovered in the Game of Life, and you can search through them to see if any have a period of 19.

Using a computer program: There are various software programs that can be used to search for oscillator patterns in the Game of Life, such as Golly or LifeViewer. These programs can be set to search for patterns with a specific period, and they can also be used to visualize the patterns that are found.

Using a genetic algorithm: A genetic algorithm is a method of optimization that is inspired by the process of natural selection. It can be used to search for oscillator patterns by creating a population of randomly generated patterns, and then evolving the population over time by applying genetic operators such as crossover and mutation.

Manually: Some people find and discover oscillators just by experimenting with different starting patterns, and adjusting them until they reach the desired period.

Ultimately, the best approach depends on the specific requirements and resources you have.

It's worth noting that the task of finding a period-19 oscillator might be computationally expensive and might not be guaranteed to be found as the solution space is very large.
It's not exactly right, but it sure does seem to know some potentially useful stuff about Life -- though I guess it doesn't know that p19 hasn't been found yet. It's not that genetic-algorithm searches are a particularly promising approach for making a p19 oscillator, necessarily, but it's not a terrible idea to bring up as an option.

And ChatGPT definitely knows some things that I didn't know:
What does RCT mean in the context of Conway's Game of Life?

In the context of Conway's Game of Life, RCT stands for "Random Cataclysmic Thunderstorms". This term is used to refer to a type of rule that is applied to the Game of Life, which randomly kills a certain percentage of cells in each generation. This is done in addition to the normal rules of the Game of Life, which determine how the state of the cells will change based on the number of live neighbors they have. The RCT rule is usually used to introduce randomness and diversity in the patterns that form in the Game of Life, and can result in more chaotic and unpredictable behavior.

RCT rule is used as a way to break the symmetry of patterns and prevent patterns from stabilizing and finding a equilibrium state. It can also be useful in the context of genetic algorithms to avoid local optima and find novel solutions.
... And it will tell you some things that aren't true, like
What is a "reverse caber tosser" in Conway's Game of Life?

A "reverse caber tosser" in Conway's Game of Life refers to a specific type of oscillator pattern. An oscillator is a pattern in the Game of Life that repeatedly changes over time, but always returns to its original configuration.

A reverse caber tosser is a period-60 oscillator that is made of several smaller oscillators, including beehives, blinkers, and other simple patterns. These smaller oscillators are arranged in such a way that they interact with each other to create the overall period-60 oscillation. The name "reverse caber tosser" refers to the overall shape of the pattern, which is said to resemble the motion of a caber (a long tapered pole) being thrown in the opposite direction.

Reverse caber tosser is known for its relatively big size and relatively big period which makes it a relatively rare pattern to be found in the Game of Life. It's also considered as a complex pattern and it's hard to construct it from scratch.

hkoenig
Posts: 259
Joined: June 20th, 2009, 11:40 am

Re: Translating python golly script to lua with ChatGPT

Post by hkoenig » January 21st, 2023, 8:58 pm

The fact that there is no known Period-19 oscillator is missing from all that, especially in the first case. Seems like it should be mentioned there.

Here's someone else's experience in the medical field: Dr. OpenAI Lied to Me. I find it interesting that it was useful for something simple like a chart writeup, but got worse the more challenging the task.

There's also something really bland about all the writeups I've seen. Too many sound like reading a corporate website's mission statement written by someone paid by the word.

User avatar
simsim314
Posts: 1823
Joined: February 10th, 2014, 1:27 pm

Re: Translating python golly script to lua with ChatGPT

Post by simsim314 » January 21st, 2023, 10:36 pm

dvgrn wrote:
January 21st, 2023, 7:53 pm
I found my way in to ChatGPT today
Great!
dvgrn wrote:
January 21st, 2023, 7:53 pm
It's not exactly right, but it sure does seem to know some potentially useful stuff about Life
I tried to ask it for a full list of oscillators, and it wasn't able to. It brought some strange variations, confusing period with number of cells, glider synth, and even inventing nonexistent patterns. Here is an example:
Period 2: blinker, toad, beacon
Period 3: pulsar
Period 4: glider
Period 5: pentomino
Period 6: hexomino
Period 8: octomino
Period 15: pentadecathlon
I would guess this is one of the cases we would need to fine tune a smaller language model with lifeWiki and maybe this forum. Do we have a giant text files for lifewiki or all the conwaylife data? Like we have a wikipedia dump?
dvgrn wrote:
January 21st, 2023, 7:53 pm
What is the best way to find a period-19 oscillator in Conway's Game of Life?
Generally speaking it's not that clever yet, and not so knowledgeable. But we can think of a ways it can benefit us still. Like it can convert from one language to another, ChatGPT does it pretty good. Maybe we can show example of some tools syntax, and then use ChatGPT for other cases, like preparing input files to catforce or catgl or wtr. Maybe it can suggest some possible search configuration not sure yet, but I do believe there is a lot of potential there without the fine tune as well.
hkoenig wrote:
January 21st, 2023, 8:58 pm
Dr. OpenAI Lied to Me.
Google have trained a large language model on all pubmed. The results looks good, the accuracy is still well behind professional clinicians (67% accuracy for the model vs. 90% of the human expert), but we are slowly getting there.
hkoenig wrote:
January 21st, 2023, 8:58 pm
Too many sound like reading a corporate website's mission statement written by someone paid by the word.
I would say it can be pretty fun and creative.
Write a poem in dr. Seuss style, about Conway's game of life research, emphasize the rhyme and the rythm of the poem. Mention new discoveries and novelties done in the past 50 years, like Gosper Glider gun, Hershel conduits, constructable spaceships

In a world of cells and grids and dots,
Lies a game of life that never stops.
It starts with Conway's simple rule,
But now it's grown to be quite cool.

With Gosper's glider gun we shoot,
Sparks of life that never hoot.
Hershel conduits, they're quite a treat,
A new discovery that can't be beat.

Spaceships that can be built with care,
A novel idea that's beyond compare.
The game of life is always new,
With discoveries that will astound you.

So come and play, it's lots of fun,
In the world of Conway's game, the race has just begun.

Post Reply