It's a large grid. You set a bunch of dots to a different color.
If there are less than 2 or more than 3 neighbors that are colored dots (touching in any direction including diagonal) the dot goes away. If there's 2 or 3 neighbors and the dots already filled in nothing happens. If there's exactly 3 neighbors and there's no dot to begin with a dot is created.
More here: http://en.wikipedia.org/wiki/Conway's_Game_of_Life
I'm attempting to make a version of this for Rainmeter.
A 7x7 grid. But before I go make 49 squares... I started with 2x5 (5x2?) with only 10.
Now, how I wrote it I think it's correct... but it doesn't always work as it should.
The only thing I can think of is since Rainmeter does everything in order rather than all simotaneously some measures get updated sooner and throws the others off.
Here's the code:
Code: Select all
[Rainmeter]
BackgroundMode=2
SolidColor=00000001
Update=1000
[Variables]
ColorLive=000000
ColorDead=FFFFFF
FontColor=FFFFFF
Sq1=0
Sq2=0
Sq3=0
Sq4=0
Sq5=0
Sq6=0
Sq7=0
Sq8=0
Sq9=0
Sq10=0
Color1=FFFFFF
Color2=FFFFFF
Color3=FFFFFF
Color4=FFFFFF
Color5=FFFFFF
Color6=FFFFFF
Color7=FFFFFF
Color8=FFFFFF
Color9=FFFFFF
Color10=FFFFFF
[mtStart]
Meter=String
Text=[Start]
FontColor=#FontColor#
SolidColor=#FontColor#01
Antialias=1
X=0
Y=30
LeftMouseUpAction=!Execute [!RainmeterEnableMeasure msSq1][!RainmeterEnableMeasure msSq2][!RainmeterEnableMeasure msSq3][!RainmeterEnableMeasure msSq4][!RainmeterEnableMeasure msSq5][!RainmeterEnableMeasure msSq6][!RainmeterEnableMeasure msSq7][!RainmeterEnableMeasure msSq8][!RainmeterEnableMeasure msSq9][!RainmeterEnableMeasure msSq10]
[msTotal]
Measure=Calc
Formula=#Sq1#+#Sq2#+#Sq3#+#Sq4#+#Sq5#+#Sq6#+#Sq7#+#Sq8#+#Sq9#+#Sq10#
DynamicVariables=1
[mtTotal]
Meter=String
MeasureName=msTotal
DynamicVariables=1
FontColor=#FontColor#
SolidColor=#FontColor#01
Antialias=1
X=50
Y=30
[mtSq1]
Meter=Image
SolidColor=#Color1#
DynamicVariables=1
W=10
H=10
X=0
Y=0
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq1 1][!RainmeterSetVariable Color1 #ColorLive#][!RainmeterRedraw]
[msSq1]
Measure=Calc
Formula=(#Sq2#+#Sq6#+#Sq7#) < 2 || (#Sq2#+#Sq6#+#Sq7#) > 3 ? 0 : (#Sq2#+#Sq6#+#Sq7#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq1 0][!RainmeterSetVariable Color1 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq1 1][!RainmeterSetVariable Color1 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq2]
Meter=Image
SolidColor=#Color2#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq2 1][!RainmeterSetVariable Color2 #ColorLive#][!RainmeterRedraw]
[msSq2]
Measure=Calc
Formula=(#Sq1#+#Sq3#+#Sq6#+#Sq7# +#Sq8#) < 2 || (#Sq1#+#Sq3#+#Sq6#+#Sq7# +#Sq8#) > 3 ? 0 : (#Sq1#+#Sq3#+#Sq6#+#Sq7# +#Sq8#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq2 0][!RainmeterSetVariable Color2 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq2 1][!RainmeterSetVariable Color2 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq3]
Meter=Image
SolidColor=#Color3#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq3 1][!RainmeterSetVariable Color3 #ColorLive#][!RainmeterRedraw]
[msSq3]
Measure=Calc
Formula=(#Sq2#+#Sq4#+#Sq7#+#Sq8# +#Sq8#) < 2 || (#Sq2#+#Sq4#+#Sq7#+#Sq8# +#Sq8#) > 3 ? 0 : (#Sq2#+#Sq4#+#Sq7#+#Sq8# +#Sq8#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq3 0][!RainmeterSetVariable Color3 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq3 1][!RainmeterSetVariable Color3 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq4]
Meter=Image
SolidColor=#Color4#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq4 1][!RainmeterSetVariable Color4 #ColorLive#][!RainmeterRedraw]
[msSq4]
Measure=Calc
Formula=(#Sq3#+#Sq5#+#Sq8#+#Sq9# +#Sq10#) < 2 || (#Sq3#+#Sq5#+#Sq8#+#Sq9# +#Sq10#) > 3 ? 0 : (#Sq3#+#Sq5#+#Sq8#+#Sq9# +#Sq10#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq4 0][!RainmeterSetVariable Color4 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq4 1][!RainmeterSetVariable Color4 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq5]
Meter=Image
SolidColor=#Color5#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq5 1][!RainmeterSetVariable Color5 #ColorLive#][!RainmeterRedraw]
[msSq5]
Measure=Calc
Formula=(#Sq4#+#Sq9#+#Sq10#) < 2 || (#Sq4#+#Sq9#+#Sq10#) > 3 ? 0 : (#Sq4#+#Sq9#+#Sq10#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq5 0][!RainmeterSetVariable Color5 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq5 1][!RainmeterSetVariable Color5 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
;----Row 2-------------------
[mtSq6]
Meter=Image
SolidColor=#Color6#
DynamicVariables=1
W=10
H=10
X=0
Y=2R
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq6 1][!RainmeterSetVariable Color6 #ColorLive#][!RainmeterRedraw]
[msSq6]
Measure=Calc
Formula=(#Sq1#+#Sq2#+#Sq7#) < 2 || (#Sq1#+#Sq2#+#Sq7#) > 3 ? 0 : (#Sq1#+#Sq2#+#Sq7#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq6 0][!RainmeterSetVariable Color6 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq6 1][!RainmeterSetVariable Color6 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq7]
Meter=Image
SolidColor=#Color7#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq7 1][!RainmeterSetVariable Color7 #ColorLive#][!RainmeterRedraw]
[msSq7]
Measure=Calc
Formula=(#Sq1#+#Sq2#+#Sq3#+#Sq6#+#Sq8#) < 2 || (#Sq1#+#Sq2#+#Sq3#+#Sq6#+#Sq8#) > 3 ? 0 : (#Sq1#+#Sq2#+#Sq3#+#Sq6#+#Sq8#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq7 0][!RainmeterSetVariable Color7 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq7 1][!RainmeterSetVariable Color7 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq8]
Meter=Image
SolidColor=#Color8#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq8 1][!RainmeterSetVariable Color8 #ColorLive#][!RainmeterRedraw]
[msSq8]
Measure=Calc
Formula=(#Sq2#+#Sq3#+#Sq4#+#Sq7# +#Sq9#) < 2 || (#Sq2#+#Sq3#+#Sq4#+#Sq7# +#Sq9#) > 3 ? 0 : (#Sq2#+#Sq3#+#Sq4#+#Sq7# +#Sq9#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq8 0][!RainmeterSetVariable Color8 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq8 1][!RainmeterSetVariable Color8 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq9]
Meter=Image
SolidColor=#Color9#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq9 1][!RainmeterSetVariable Color9 #ColorLive#][!RainmeterRedraw]
[msSq9]
Measure=Calc
Formula=(#Sq4#+#Sq5#+#Sq6#+#Sq8#+#Sq10#) < 2 || (#Sq4#+#Sq5#+#Sq6#+#Sq8#+#Sq10#) > 3 ? 0 : (#Sq4#+#Sq5#+#Sq6#+#Sq8#+#Sq10#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq9 0][!RainmeterSetVariable Color9 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq9 1][!RainmeterSetVariable Color9 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
[mtSq10]
Meter=Image
SolidColor=#Color10#
DynamicVariables=1
W=10
H=10
X=2R
Y=0r
LeftMouseUpAction=!Execute [!RainmeterSetVariable Sq10 1][!RainmeterSetVariable Color10 #ColorLive#][!RainmeterRedraw]
[msSq10]
Measure=Calc
Formula=(#Sq4#+#Sq5#+#Sq9#) < 2 || (#Sq4#+#Sq5#+#Sq9#) > 3 ? 0 : (#Sq4#+#Sq5#+#Sq9#) = 3 ? 1 : 2
DynamicVariables=1
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterSetVariable Sq10 0][!RainmeterSetVariable Color10 #ColorDead#][!RainmeterRedraw]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterSetVariable Sq10 1][!RainmeterSetVariable Color10 #ColorLive#][!RainmeterRedraw]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterRedraw]
Disabled=1
Clicking on a square changes it's variable to 1 and sets it's color to black. The calcs add up the surronding squares by using their variables and that's how the rules above are implemented.
Since a square can become active or not by other squares AND you clicking, I have it so it sets the variable to 1 if it's 3 neighbors or 0 if it's 2<x>3. I think it's all correct.
Since if everything was happening as you clicked you would get nowhere, unless your super fast, all measures are disabled at first (aside from the total) and Start enables all the measures.