It is currently June 23rd, 2024, 2:29 am

Conway's Game of Life Skin

Get help with creating, editing & fixing problems with skins
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Conway's Game of Life Skin

Post by JpsCrazy »

So I just found out about John Conway's Game of Life.
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
Sq is square and the numbers increase from left to right.
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.
Any idea why it's not working as I'd like it to?
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Conway's Game of Life Skin

Post by JpsCrazy »

I was messing around with it a bit, and noticed it seemed to always work when all the measures were enabled to start.

So, as far as I can tell, having all the calcs disabled at first then all enabled by !bangs isn't instant - they obviously go in the order they were written - the calcs that are activated first get incorrect values because of this and then throw the others off.

Basically, I need all the calcs to be enabled instantly, or at least update exactly at the same time.
I could use a larger UpdateDivider and have them all active to start, the calcs updating every 5 seconds or so to give the user time to click everywhere - but it ruins the point of the game in my mind. Worst comes to worst, I'll do this.

Is there any way around this? Possibly activate all Measures together with 1 click, kind of how you can do all Configs with !bangs with a *?

Also, slightly off topic. I remember being told awhile a go, when I was making my first skin that I should keep all the measures and corresponding meters close to eachother, because if they're too far away weird things would happen. Is there any legitimacy to this? Yes, I know it'll be weird having all the Measures together and all the Meters together, but since they're all almost identical I think it would be alright in this case.
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Conway's Game of Life Skin

Post by Alex2539 »

JpsCrazy wrote:Also, slightly off topic. I remember being told awhile a go, when I was making my first skin that I should keep all the measures and corresponding meters close to eachother, because if they're too far away weird things would happen. Is there any legitimacy to this? Yes, I know it'll be weird having all the Measures together and all the Meters together, but since they're all almost identical I think it would be alright in this case.
You may be misremembering. It's not that something weird will happen, it's just that when you're making a typical skin, it's easier to navigate the code when all of the meters and measures are together. It's just an organization thing. In the end, the only points where the order actually makes a difference are when the meters are actually being drawn (first in the file are on the bottom) and when you're using the value of another variable in the declaration of a variable (the one you're using has to be declared above the one that you're declaring).

Good luck with the game!
Image
ImageImageImageImage
User avatar
jsmorley
Developer
Posts: 22640
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Conway's Game of Life Skin

Post by jsmorley »

I sort of remember some advice to that effect as well, a while back. Something to do with having a long complicated skin that does a lot of things which are timing sensitive. So for instance if you had a CPU measure at the top and the display of the result in a meter 200 measures later in the skin, there could be some perceivable divorce from reality. I heard that, but can't say I can prove it one way or the other.
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Conway's Game of Life Skin

Post by Alex2539 »

I did a bit of checking and it turns out it can in fact make a difference with measures used as dynamic variables. Because dynamic variables used whatever the current value of the measure is and because Rainmeter gets those values in the order they appear, a calc using dynamic variables can in fact benefit from appearing below the measure it's referring to. Try running this and you'll see what I mean:

Code: Select all

[Rainmeter]
Update=1000

[Calc1]
Measure=Calc
Formula=[Calc2]
DynamicVariables=1

[Calc2]
Measure=Calc
Formula=Counter%10

[Calc3]
Measure=Calc
Formula=[Calc2]
DynamicVariables=1

[String]
Meter=String
MeasureName=Calc1
MeasureName2=Calc2
MeasureName3=Calc3
Text=%1 %2 %3
SolidColor=ffffff
ImageImageImageImage
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Conway's Game of Life Skin

Post by JpsCrazy »

Thanks for the responses! Luckily, I don't think I fit into either of these situations.
All my calcs just use Dynamic Variables and they don't display information, they just set variables. I'll switch some stuff around to make sure clicking a meter causes the variable to change before a calc gets to read it.

So I think the layout will be:
-Variables
-Options (meters and measures)
-Meters
-Calcs

Since there's 49 calcs which are pretty much the same and same for the meters I think it'll be alright this time. I wouldn't consider this if they all weren't so similar.

I'll let you know how it goes.


One question of opinion:
If the dots move to the edge of the screen should it seemingly wrap around to the other side or just disappear off the edge?