Hi Michael,
Larry recently posted something similar
http://groups.google.com/group/clojure/browse_thread/thread/773e628953b40d9f
Which generated also quite a lot of discussion which you might also be
interested in.
(def matrix #{[-1 -1] [-1 0] [-1 1] [0 -1] [0 0] [0 1] [1 -1] [1 0] [1 1]})
Thanks for the great feedback.
Michael
Am 19.04.2009 11:33 Uhr, schrieb Timothy Pratley:
Hi Michael,
Larry recently posted something similar
http://groups.google.com/group/clojure/browse_thread/thread/773e628953b40d9f
Which generated also quite a lot of discussion which you might also be
As I'm currently trying to learn clojure I wrote a game of life to get a
feeling for the concepts.
It would be great if some of you could point out areas for improvement or
unused idioms or patterns.
Thanks alot
Michael
here is the code:
(ns gol)
(comment a board only contains
to experiment
with different automata such as gliders.
Larry Sherrill
On Mar 16, 9:33 am, Kyle R. Burton kyle.bur...@gmail.com wrote:
On Mon, Mar 16, 2009 at 12:31 AM, Scott Fraser scott.e.fra...@gmail.com
wrote:
I have taken Larry's Game of Life example that he originally posted
here
Nice! A few more days of work and I've time to play with these kind of
things again. Here are some comments, based on your description.
As game of life is a cellular automata, you do not need any blocking
at all, so you could use agents, rather than refs. It does become an
asynchronous CA
days of work and I've time to play with these kind of
things again. Here are some comments, based on your description.
As game of life is a cellular automata, you do not need any blocking
at all, so you could use agents, rather than refs. It does become an
asynchronous CA then, but that fits
Hello,
2009/3/16 bOR_ boris.sch...@gmail.com
Nice! A few more days of work and I've time to play with these kind of
things again. Here are some comments, based on your description.
As game of life is a cellular automata, you do not need any blocking
at all, so you could use agents, rather
Very cool. Thanks for the tip. I didn't know a type hint would make
that much difference.
Another possible speedup would be to use send/actor to take advantage
of multiprocessor machines. Would be curious if the overhead would pay
for itself in this situation.
Thanks, Larry
On Mar 14, 8:03 pm,
On Mon, Mar 16, 2009 at 12:31 AM, Scott Fraser scott.e.fra...@gmail.com wrote:
I have taken Larry's Game of Life example that he originally posted
here:
http://groups.google.com/group/clojure/msg/fdfc88f1ba95bdee
...and updated it to use all the CPU's your JVM has access to...
Scott,
Your
, Kyle R. Burton kyle.bur...@gmail.com wrote:
On Mon, Mar 16, 2009 at 12:31 AM, Scott Fraser scott.e.fra...@gmail.com
wrote:
I have taken Larry's Game of Life example that he originally posted
here:
http://groups.google.com/group/clojure/msg/fdfc88f1ba95bdee
...and updated it to use all
I'm not very used to concurrent programming, so I have a few questions you
may find naïve, but well, let's just pretend they're interesting ... :
Learning here as well :).
It seems to me that the game of life works in increments of its world.
So I don't see at first what can be gained
to experiment
with different automata such as gliders.
Larry Sherrill
On Mar 16, 9:33 am, Kyle R. Burton kyle.bur...@gmail.com wrote:
On Mon, Mar 16, 2009 at 12:31 AM, Scott Fraser scott.e.fra...@gmail.com
wrote:
I have taken Larry's Game of Life example that he originally posted
here
Hi Larry
I have a performance tweak, that gives about an order of magnitude
speedup to paint-cells when running this with a large grid and no or
little (Thread/sleep life-delay) in toggle-thread. That is how I am
running it now - 128 x 192 cells with no delay! It is also noticeably
faster on the
I have taken Larry's Game of Life example that he originally posted
here:
http://groups.google.com/group/clojure/msg/fdfc88f1ba95bdee
...and updated it to use all the CPU's your JVM has access to. My
first attempts ran into the classic map - pmap slowdown. My next
attempt had too much dosync
I've incorporated everyone's suggestions and thought I would post the
resulting smaller code. I refactored init-cells away and just pass in
an init or new function to calc-state to reuse the for loop. I made
determine-next-state a little more verbose than technically necessary
to make conway's
In my experience, life is a bit more interesting if the field wraps
and it is square.
Here are some mods to your most recent version that does this. I've
also parameterized the field size, the delay, and the initial
probability of a cell being occupied.
Thanks for sharing this - it's fun.
I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.
http://lpsherrill.blogspot.com/2009/02/conways-game-of-life.html
Thanks,
Larry
--~--~-~--~~~---~--~~
You received this message because you
lps540 lps...@gmail.com writes:
I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.
Interesting program!
(for [x (range 32) y (range 48)]
(ref-set cells
(assoc (deref cells) [x y] (= 0 (rand-int
a Java idiom. I'll read up on binding.
Thank again!
Larry
On Mar 3, 1:30 pm, Phil Hagelberg p...@hagelb.org wrote:
lps540 lps...@gmail.com writes:
I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.
Interesting program!
(for [x
On Tue, Mar 3, 2009 at 2:03 PM, lps540 lps...@gmail.com wrote:
I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.
http://lpsherrill.blogspot.com/2009/02/conways-game-of-life.html
The paint-cells function can be shorted by using
On Tue, Mar 3, 2009 at 2:03 PM, lps540 lps...@gmail.com wrote:
I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.
Instead of all the uses of (- x 1), (- y 1), (+ x 1) and (+ y 1), I
think it's more idiomatic to use (dec x), (dec y
On Mar 3, 2009, at 3:03 PM, lps540 wrote:
I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.
Very nice example!
Here's a more compact determine-new-state:
(defn determine-new-state [x y]
(let [count (reduce + (for [dx [-1 0 1
Thanks everyone for the suggestions. Very helpful.
On Mar 3, 2:03 pm, Stephen C. Gilardi squee...@mac.com wrote:
On Mar 3, 2009, at 3:03 PM, lps540 wrote:
I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.
Very nice example
Hello Larry,
is there a reason why the code of this port of Game of Life does not seem to
be under an open source license (e.g. EPL, etc.) ?
I was interested in playing with your code, but I'm a bit reluctant when I
see an all rights reserved in the top of the file ...
It seems to me like your
On Mar 3, 2009, at 4:03 PM, Stephen C. Gilardi wrote:
(defn determine-new-state [x y]
(let [count (reduce + (for [dx [-1 0 1] dy [-1 0 1]]
(if (cells [(+ x dx) (+ y dy)]) 1 0)))]
(or (and (cells [x y]) ( count 2) ( count 5))
(= count 3
I'm guessing
Just because there is always another way :P
(defn determine-new-state [x y]
(let [alive (count (for [dx [-1 0 1] dy [-1 0 1]
:when (cells [(+ x dx) (+ y dy)])]
:alive))]
(if (cells [x y])
( 2 alive 5)
(= alive 3
laurent.pe...@gmail.com wrote:
Hello Larry,
is there a reason why the code of this port of Game of Life does not seem to
be under an open source license (e.g. EPL, etc.) ?
I was interested in playing with your code, but I'm a bit reluctant when I
see an all rights reserved in the top
On Mar 3, 2009, at 11:01 PM, Timothy Pratley wrote:
Just because there is always another way :P
(defn determine-new-state [x y]
(let [alive (count (for [dx [-1 0 1] dy [-1 0 1]
:when (cells [(+ x dx) (+ y dy)])]
:alive))]
(if (cells [x y])
28 matches
Mail list logo