>>2
You can't actually fail with Satori, simply be very late in achieving it.
I know I probably shouldn't ask you about this (as you are oh so busy with discussing real programming) but you are one of the few that probably could give me a proper answer about this.
Oh wait... All I should need to do is flatten the whole list of lists into one list and then run something like a labels in-between (- pos-symbol 4) and (+ pos-symbol 4) and then remove the symbol.
Yeah... That should do it.
Hm, only problem is finding the symbol again, which I could do in a separate function.
This is probably not as fast as the whole PUSH-ONE-LOAD-OF-VALUES function but the code is far more interesting.
If anyone has any idea on how to find the symbols new position in the flattened list, it would be much appreciated.
I have a little idea of my own but it's kinda boring.
>>17
One also could also run a bit window against data and count matchin bits (modern CPU support bitcount function). A pretty general technique, you can use to pattern match any data.
;;
;; Observation: Entropy change survives for 21 generations in the particular test game above.
;; The 21st generation's state, namely
;; #(#(#f #t #f #f #t) #(#f #t #f #f #t) #(#f #f #t #t #f) #(#f #f #f #f #f) #(#f #f #t #t #f))
;; does not change.
;;
Name:
232011-04-13 8:30
>>1-san, see my-vector-ref (and the rest of the code) for your answer.
Note about this part:
(how-many-living
`(,(my-vector-ref (my-vector-ref game (- j 1)) (- i 1))
,(my-vector-ref (my-vector-ref game (- j 1)) i)
,(my-vector-ref (my-vector-ref game (- j 1)) (+ i 1))
,(my-vector-ref (my-vector-ref game j) (- i 1))
,(my-vector-ref (my-vector-ref game j) (+ i 1))
,(my-vector-ref (my-vector-ref game (+ j 1)) (- i 1))
,(my-vector-ref (my-vector-ref game (+ j 1)) i)
,(my-vector-ref (my-vector-ref game (+ j 1)) (+ i 1))))
I could have written it iteratively (and that would work in my game in particular), but I kept it expanded to demonstrate the idea the way you need it because otherwise it probably wouldn't work for you.
In other words, I could have made it iterate through a 2-dimensional array from (-1,-1) to (+1,+1) and add the numbers to i and j in a single my-vector-ref expression, except return a #f when both numbers equal 0 (the current cell). (And that would work in my game because an additional #f in the list fed to how-many-living will not change its output.)
>>23
Yeah, I skimmed through the code, I did my "implementation" in the same raw way that you did. Conway's Game of Life is actually what I'm implementing right now so how nice of you to show me your source!
I have one single question:
What the hell is up with the whole [game (next-generation game)] ?
I'm talking about [ and the other one, what are they doing there?
>>27
In Scheme, parenthesis and rectangular brackets are exchangeable. Racketeers in particular prefer to use the latter in certain positions to enhance readability. Particularly in expressions like let where you would otherwise end up with a salad of parenthesis when nesting them.
Name:
Anonymous2011-04-13 21:44
>>29
In CL I like to use [a b c] for (list a b c) and {a b c} for (progn a b c), but Scheme doesn't allow me. Stupid Scheme.
Name:
Anonymous2011-04-13 21:49
I also use [a b -> c d -> e f] for hashes in CL, but Scheme doesn't have macros, so it couldn't discern list from hash declaration at compile time.