I'm currently attempting simulation of the game of life, and what I have so far isn't detecting when it has numbers.
when gf clicked set [paused v] to [yes] clear hide delete (all v) of [oldgrid v] delete (all v) of [newgrid v] set [pixradius v] to [160] set [cellradius v] to [4] set [placementscale v] to (((2) * (pixradius)) / ((2) * (cellradius))) repeat (((cellradius) * (cellradius)) * (4)) add [0] to [oldgrid v] add [0] to [newgrid v] end forever if <(paused) = [yes]> set [out of bounds v] to [no] go to x: (((round (((mouse x) + ((placementscale) / (2))) / (placementscale))) * (placementscale)) - ((placementscale) / (2))) y: ((((round (((mouse y) + ((placementscale) / (2))) / (placementscale))) * (placementscale)) - ((placementscale) / (2))) + (1)) if <( [abs v] of (x position)) > (pixradius)> set [out of bounds v] to [yes] if <(x position) > (pixradius)> set x to (pixradius) else set x to ((0) - (pixradius)) end end if <( [abs v] of (y position)) > ((pixradius) + (1))> set [out of bounds v] to [yes] if <(y position) > ((pixradius) + (1))> set y to ((pixradius) + (1)) else set y to ((0) - (pixradius)) end end if <mouse down?> if <(out of bounds) = [no]> if <(round ((((round (((x position) + ((placementscale) / (2))) / (placementscale))) * (placementscale)) - ((placementscale) / (2))) / (placementscale))) > [0]> set [mouse column v] to ((4) + (round ((((round (((x position) + ((placementscale) / (2))) / (placementscale))) * (placementscale)) - ((placementscale) / (2))) / (placementscale)))) else set [mouse column v] to ((5) + (round ((((round (((x position) + ((placementscale) / (2))) / (placementscale))) * (placementscale)) - ((placementscale) / (2))) / (placementscale)))) end set [mouse row v] to ( [abs v] of ((4) - (round (((((round (((mouse y) + ((placementscale) / (2))) / (placementscale))) * (placementscale)) - ((placementscale) / (2))) + (1)) / (placementscale))))) if <touching color [#000008]?> switch to costume [background2 v] replace item ((( [sqrt v] of (length of [oldgrid v] )) * (mouse row)) + (mouse column)) of [oldgrid v] with [0] else switch to costume [background1 v] replace item ((( [sqrt v] of (length of [oldgrid v] )) * (mouse row)) + (mouse column)) of [oldgrid v] with [1] end stamp wait until <not <mouse down?>> end end else set [currentrowcheck v] to [0] set [currentcolumncheck v] to [1] repeat (length of [oldgrid v] ) set [temporaryneighborvalue v] to [0] if <(currentrowcheck) = [0]> set [tempscanrow v] to (( [sqrt v] of (length of [oldgrid v] )) - (1)) else set [tempscanrow v] to ((currentrowcheck) + (1)) end if <(currentcolumncheck) = [1]> set [tempscancolumn v] to ( [sqrt v] of (length of [oldgrid v] )) else set [tempscancolumn v] to ((currentcolumncheck) - (1)) end if <(item (((tempscanrow) * ( [sqrt v] of (length of [oldgrid v] ))) + (tempscancolumn)) of [newgrid v] ) = [1]> change [temporaryneighborvalue v] by (1) end set [tempscancolumn v] to (currentcolumncheck) if <(item (((tempscanrow) * ( [sqrt v] of (length of [oldgrid v] ))) + (tempscancolumn)) of [newgrid v] ) = [1]> change [temporaryneighborvalue v] by (1) end if <(currentcolumncheck) = ( [sqrt v] of (length of [oldgrid v] ))> set [tempscancolumn v] to [1] else set [tempscancolumn v] to ((currentcolumncheck) + (1)) end if <(item (((tempscanrow) * ( [sqrt v] of (length of [oldgrid v] ))) + (tempscancolumn)) of [newgrid v] ) = [1]> change [temporaryneighborvalue v] by (1) end set [tempscanrow v] to (currentrowcheck) end end endIf anyone could help, that would be amazing.
Last edited by zubblewu (2012-10-28 19:06:22)
Offline
notaloser wrote:
Oh My God!!!! you actually type that: ^^^?
I don't understand the script, im sorry. it will be better if you just uploaded what you have made so far.
Nope . But it's a lot easier imho for people to reply with the script right there. And if you want' the project so far is uploaded as my newest one.
Offline
Seems like CAs are a new trend.
This shows how to use variable size arrays to make a CA.
Offline
Just a small piece of advice: I wouldn't do it with a bunch of "rows," but with a long array that "wraps around" at the end of each line (sort of like the level storing system in Music Marathon). When you check cell n's neighbors, you find the values of item n + 1, n - 1, n + width, and n - width of the data list.
Also, Life is played on a theoretically infinite grid, so you'll have to figure out a way to deal with edges - will cells adjacent to edges measure the edge as a live neighbor, or an empty cell? You'll have to decide a feasible size for the game (coincidentally, I was thinking of making one myself, but perhaps in C++ instead), taking into account the computation speed/rendering problem and the size of the Scratch viewing screen.
Anyway, good luck!
Last edited by amcerbu (2012-10-28 12:08:23)
Offline
amcerbu wrote:
Just a small piece of advice: I wouldn't do it with a bunch of "rows," but with a long array that "wraps around" at the end of each line (sort of like the level storing system in Music Marathon). When you check cell n's neighbors, you find the values of item n + 1, n - 1, n + width, and n - width of the data list.
Also, Life is played on a theoretically infinite grid, so you'll have to figure out a way to deal with edges - will cells adjacent to edges measure the edge as a live neighbor, or an empty cell? You'll have to decide a feasible size for the game (coincidentally, I was thinking of making one myself, but perhaps in C++ instead), taking into account the computation speed/rendering problem and the size of the Scratch viewing screen.
Anyway, good luck!
Thanks! And yeah, I was thinking of using one long list, but I didn't for computational reasons. Looks like I'll have to anyway. In terms of edges, I was just going to have them wrap around (like taking into account cells adjacent to it on the other side).
Offline
Yeah. In fact, I had been thinking of what the Game of Life would look like played on the surface of a torus (basically, a square where the edges would wrap around). Anyway, I look forward to seeing it!
Last edited by amcerbu (2012-10-28 13:10:59)
Offline
Thanks! I've already finished positioning and I'm halfway done with a versatile script that should pretty much work for all perfect squares, as long as you fill in a few parameters.
Offline
That's exactly what I said.
EDIT: Wait, who am I talking to?
Last edited by Molybdenum (2012-10-28 13:22:53)
Offline
Molybdenum wrote:
That's exactly what I said.
EDIT: Wait, who am I talking to?
I don't know. And I'm to lazy to download anything. [mindblown]Also, I clicked the quote button exactly when you edited (or within 1 second) [/mindblown]
Last edited by zubblewu (2012-10-28 13:24:49)
Offline
I've totally rescripted it now. However, the part of it I have done (1/2 of the checking for neighbors I believe) isn't working. It's not finding that it has any neighbors, even when it does.
Offline