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)
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.