Just for Fun. John Conway's Game of Life
Some weeks ago, I was reading a book by Stephen Hawking and Leonard Mlodinow, The Grand Design. At a certain point, trying to define why do we exist? , why do we use the models we use in physics?, ...those kind of things you know... they pointed at the Game of Life example invented by the mathematician John Coward in 1970... Basically he wanted to show that a system with really basic fundamental laws (Physics) could evolve and "live" to become a more complex system (Chemistry) in which "something" (humans) could work out its own model and complex rules to explain its reality… the rules for this deterministic model that he exposed were so basic that I thought it could be funny to implement them in ObjectScript when I had some spare time... there are others implementations in JavaScript and other languages... but not in ObjectScript... and that had to be corrected!!… so here you are!
Here you have a link to the class that simulate the Game of Life (OPNLib.Game.ConwayLifeGame). Just load, compile it and execute the Test() method from your terminal and you'll see how a world full of life arises and evolves in front of your eyes. Internally it creates a matrix using globals, where each node of level 1 is a row in which we'll have a bit string as long as the columns of the matrix we want to represent. Each bit will be the value of the cell: alive (1), dead (0)… but you have more details in the doc and the class itself in GitHub.
First of all, change your terminal settings to allow more columns (~132 or more) and rows (~48 or more).
If you want to set different initial settings you can do it. Just call the test method passing a JSON object as a parameter. Within the class you'll find more information, but for example, you could do:
set pTest = {
"ID":1,
"From":0, "To":200,
"Iterations":200,
"InitialConfig":5,
"Rows":80, "Columns":150, "Vector0":"1,1", "VectorN":"120,47",
"AliveChar": ($c(4)), "DeadChar":"-"
}
do ##class(OPNLib.Game.ConwayLifeGame).Test(pTest)
And then, you can play with InitialConfig, changing its value from 1 to 5, to change the initial state of the universe….
![]() |
![]() |
![]() |
![]() |
There is additional doc about this class in GitHub.
Enjoy!
Thanks Salva!
A real Xmas posting! For me. I like it!
Regards and best wishes, Robert
Thanks Robert... Happy Xmas
Great game!
Does not work, as object with that ID does not exist
I added this code after read and it works:
Thanks Eduard. You are right. Test() method assumed that the ID refers to an object (world) already defined… but I like more your suggestion. I've uploaded a new release to GitHub. Now, if you execute the Test() and the World doesn't exist, it creates one for you... also we can choose the char to represent alive or dead blocks and get the iteration we're seeing...
Neat :)
I also just recently implemented it as part of the adventofcode puzzles (2015,day18) https://adventofcode.com/2015/day/18
My code's here: https://github.com/kazamatzuri/AoC/blob/master/AoC/y2015/Day18.cls
my code of day 18
John Conway died of Covid-19. RIP.
Yes... those were really very sad news. Damn virus! 😢. Conway was one of the greatest mathematicians. RIP.
Yes. Great that ideas never die, and your implementation in IRIS is vivid evidence!
I thought the XKCD tribute was perfect
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue