Folks,
please find attached the promised implementation of Conway's "Game of Life" in the StarSqueak framework (as mentioned on the "Lots of concurrency" thread).
I have also just published it as a project on Bob's SuperSwiki. Since this is the first time I've gone through the chore, I'm not sure whether it has worked out OK or not. I'd be grateful for reports to that end. (It was published from a 3.1a4332 image.)
As for what is different about this implementation, feel free to skip forward.
---
In case you want to load it manually: You'll need two of the changesets I posted a couple of minutes ago, before filing in this one. They are:
* StarSqueakFixes.3.cs -- "[FIX] Assorted StarSqueak Fixes" * StarSqueakEnh.1.cs -- "[ENH] Faster StarSqueak patch variables"
With these under your image's belt, file in this one (StarSqueakLife.12.cs) and open a StarSqueakLife with
StarSqueakLife new openInWorld
Next, get a menu on that Morph (from the red halo), and keep it up. Maybe set the scale to 4 (from the menu). Now you can start, stop and step the Life from the menu.
Note how cells change colour with age, i.e. the number of generations they survived. They are, as specified in LifeTurtle>>ageColor and LifeTurtle class>>ageColors, going through
Color showColors: (Color hotColdShades: 100).
You can change this to e.g. the gradient
Color showColors: (Color smoothShades: 50)
but don't forget to zap LifeTurtle's class variable AgeColors (easiest from a Browser, select LifeTurtle's class declaration and evaluate "AgeColors _ nil").
---
Further fun: Get an Explorer on Life (don't you wish) from the gray halo ("explore morph"), and from its lower pane, send it the messages
self deleteTurtles. self putForm: Form fromUser at: 5@20
Or. Define custom Forms like
form _ Form extent: 37@10. y _ 0. ' .........................*.......... ......................****....*..... .............*.......****.....*..... ............*.*......*..*.........** ...........*...**....****.........** **.........*...**.....****.......... **.........*...**........*.......... ............*.*..................... .............*......................' linesDo: [:line | line withIndexDo: [:c :x | c = $. ifFalse: [form colorAt: x@y put: Color black]]. y _ y+1]. GliderGun _ form
and in the Explorer do
self deleteTurtles. self putForm: GliderGun at: 20@20.
and start.
---
Implementation Notes
LifeTurtles play the role of cells, while patches keep track of neighbor counts. LifeTurtles keep track of their age, and change color accordingly. If StarSqueak places more than one LifeTurtle in a patch, the LifeTurtles will wander to find an empty patch.
There are a lot of Life implementations out there (including Dan's bitblt wizardry) that are a lot faster. Don't expect 100s of generations per second, expect more like 5-7 per second. Why? Each "cell" is actually an object with more state than 1 bit, and birth is handled by a global demon that examines each cell for birth conditions.
See LifeTurtle>>live for the algorithm that cells follow. This method runs for each cell during each turn. See StarSqueakLife>>giveBirth for the demon that creates new cells. That method runs once for each turn.
Questions? Post away.
Enjoy, Helge
Helge,
I was able to load and run this from Bob's SuperSwiki without incident or difficulty, on a 3.2a/4467 image. So your publishing foray was clearly successful.
This is very beautifully done, and fun, and I love the support materials you prepared!
-- Scott
At 3:15 AM +0100 11/3/01, Helge Horch wrote:
Folks,
please find attached the promised implementation of Conway's "Game of Life" in the StarSqueak framework (as mentioned on the "Lots of concurrency" thread).
I have also just published it as a project on Bob's SuperSwiki. Since this is the first time I've gone through the chore, I'm not sure whether it has worked out OK or not. I'd be grateful for reports to that end. (It was published from a 3.1a4332 image.) ...
Scott,
At 18:36 02.11.2001 -0800, you wrote:
I was able to load and run this from Bob's SuperSwiki without incident or difficulty, on a 3.2a/4467 image. So your publishing foray was clearly successful.
I'm *ever so glad* to hear that. Thanks for trying it. My working image is of the 2.7 variety carried through rough times and many-a changeset, with custom default fonts and all that. I was anxious that some of it might show through...
This is very beautifully done, and fun, and I love the support materials you prepared!
Aww, thanks! There is one thing that seems (to me, at least) incredibly difficult to get across, and it's *how* this "Life" is different. I wrote it right after finishing Resnick's "Turtles, Termites and Traffic Jams," and its theme still rings through the code, I hope.
In contrast to the standard implementation, it separates cell activity from (uh) tissue/cell activity. The recipe of sustained life is separated from the recipe for birth. Cells are scripted standalone through their individual demons, and they might well do much more than in the current demo. I experimented with "birth scents" and "death scents," and had them evaporate by StarSqueak, and even while no earth-shattering patterns emerged, it was an interesting journey (something I'd never even considered given my old TRS-80 bitwise implementation). And no, I still can't describe the "click" I got.
I encourage interested parties to explore StarSqueak, and the ideas behind it. And I thank John Maloney for the Squeak implementation of StarLogo, easy to comprehend, fast, and easy to tweak as it is. Great stuff.
Cheers, Helge
On Fri, 2 Nov 2001, Scott Wallace wrote:
Helge,
I was able to load and run this from Bob's SuperSwiki without incident or difficulty, on a 3.2a/4467 image.
Me too, only on a plugin, Squeakland 3.1.4253, update #69. Havne't beat on it too hard, but it loaded *very* quickly and is running fine!
I love the Squeak plugin.
So your publishing foray was clearly successful.
Yes.
This is very beautifully done, and fun, and I love the support materials you prepared!
These may be Scott's words, but they flow from my lips as well.
Cheers, Bijan Parsia.
squeak-dev@lists.squeakfoundation.org