We all one way or another faced with the game "Life" Conway . Someone wrote himself, someone watched and marveled, someone played ...
On the new year, sitting with a colleague at the same computer and solving some problem at the end of the working day, we moved away a bit from the problem and somehow it came down to Mx life (we both use Emacs), whoever is unfamiliar with Emacs is the Emacs toy launch team.
')
Standard is not interesting
It seems to be something to talk about. Yes, only the implementation in Emacs has about 10 “embedded” initial positions, which, to put it mildly, are not interesting.
Do you know that:
Conway initially suggested that no initial combination could lead to unlimited breeding and offered a premium of $ 50 to someone who would prove or disprove this hypothesis.
My hands were itching to try some of the interesting forms of the game. But for this you need to do something so that the implementation of the life function perceives the current text in the text editor window, and not insert one of its “beautiful” templates.
And, looking at the life function code (by clicking on Emacs Chf life ), it turned out that everything is simple:
The xlife function is designed to bind the string-contents of the current buffer to the global dynamic variablelife-patterns , which is used by the life function. And then just do the last one.
No copying of the implementation, no hooks and hacks.
We load the code of our function in Emacs ( CMx ) and execute ( Mx xlife ): the text that was just the code of our function starts to “live”.