Generate Random Domino Tiles

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
odinsdream
Posts: 12
Joined: Sat Jul 09, 2005 2:18 pm

Generate Random Domino Tiles

Post by odinsdream »

Here's some code to generate random horizontal and vertical domino tiles. I wish I were saavy enough to make this draw a whole domino game with the tiles, but I'm not that far ahead yet.

Code: Select all

startshape DOMINOES

rule DOMINOES {
DOMINO{}
}

rule DOMINO{
HORIZONTAL{}
}

rule DOMINO{
VERTICAL{}
}

rule HORIZONTAL{
VERTICAL { rotate 90 }
}

rule VERTICAL{
V_OUTLINES{}
U_V_DOTS{}
L_V_DOTS{}
}

rule V_OUTLINES{
SQUARE { x 1 y 1 s 1 b 0 }
SQUARE { x 1 y 2 s 1 b 0 }
SQUARE { x 1 y 1 s .95 b 1 }
SQUARE { x 1 y 2 s .95 b 1 }
}

rule U_V_DOTS{
}

rule U_V_DOTS{
CIRCLE { x 1 y 2 size .17 }
}

rule U_V_DOTS{
CIRCLE { x .8 y 2 size .17 }
CIRCLE { x 1.2 y 2 size .17 }
}

rule U_V_DOTS{
CIRCLE { x .8 y 2.2 size .17 }
CIRCLE { x 1 y 2 size .17 }
CIRCLE { x 1.2 y 1.8 size .17 }
}

rule U_V_DOTS{
CIRCLE { x .8 y 2.2 size .17 }
CIRCLE { x 1.2 y 2.2 size .17 }
CIRCLE { x 1.2 y 1.8 size .17 }
CIRCLE { x .8 y 1.8 size .17 }
}

rule U_V_DOTS{
CIRCLE { x .8 y 2.2 size .17 }
CIRCLE { x 1.2 y 2.2 size .17 }
CIRCLE { x 1 y 2 size .17 }
CIRCLE { x 1.2 y 1.8 size .17 }
CIRCLE { x .8 y 1.8 size .17 }
}

rule U_V_DOTS{
CIRCLE { x .8 y 2.2 size .17 }
CIRCLE { x 1.2 y 2.2 size .17 }
CIRCLE { x .8 y 2 size .17 }
CIRCLE { x 1.2 y 2 size .17 }
CIRCLE { x 1.2 y 1.8 size .17 }
CIRCLE { x .8 y 1.8 size .17 }
}

rule L_V_DOTS{
}

rule L_V_DOTS{
CIRCLE { x 1 y 1 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1 size .17 }
CIRCLE { x 1.2 y 1 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1.2 size .17 }
CIRCLE { x 1 y 1 size .17 }
CIRCLE { x 1.2 y .8 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1.2 size .17 }
CIRCLE { x 1.2 y 1.2 size .17 }
CIRCLE { x 1.2 y .8 size .17 }
CIRCLE { x .8 y .8 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1.2 size .17 }
CIRCLE { x 1.2 y 1.2 size .17 }
CIRCLE { x 1 y 1 size .17 }
CIRCLE { x 1.2 y .8 size .17 }
CIRCLE { x .8 y .8 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1.2 size .17 }
CIRCLE { x 1.2 y 1.2 size .17 }
CIRCLE { x .8 y 1 size .17 }
CIRCLE { x 1.2 y 1 size .17 }
CIRCLE { x 1.2 y .8 size .17 }
CIRCLE { x .8 y .8 size .17 }
}

User avatar
aaronstj
Posts: 66
Joined: Wed Jul 06, 2005 11:34 am
Location: Seattle

Post by aaronstj »

Here's code to "play" a domino game. Of course, I don't actually know how to play the real game of dominos, and I'm sure this is knowhere like a real game. A lot of times the game will either be way to big or way to small, so you'll have to render it several times to get a nice one. Try XVQ.

Code: Select all

startshape DOMINOES

rule DOMINOES 1.75 {
	DOMINO{}
}

rule DOMINOES 5 {
	DOMINO{}
	DOMINOES {y 2.05}
}

rule DOMINOES 4 {
	DOMINO{ y -1 x -0.5 r 90}
	DOMINO{ y 1.05}
	DOMINOES {y 3.1}
	MAYBEDOMINOES {r 90 x -2.6 y -1}
	MAYBEDOMINOES {r -90 x 2.6 y -1}
}

rule MAYBEDOMINOES 3 { }

rule MAYBEDOMINOES { DOMINOES {} }

rule DOMINO{
	VERTICAL{ x -1 y -2}
}

rule VERTICAL{
	V_OUTLINES{}
	U_V_DOTS{}
	L_V_DOTS{}
}

rule V_OUTLINES{
	SQUARE { x 1 y 1 s 1 b 0 }
	SQUARE { x 1 y 2 s 1 b 0 }
	SQUARE { x 1 y 1 s .95 b 1 }
	SQUARE { x 1 y 2 s .95 b 1 }
}

rule U_V_DOTS{
}

rule U_V_DOTS{
	CIRCLE { x 1 y 2 size .17 }
}

rule U_V_DOTS{
	CIRCLE { x .8 y 2 size .17 }
	CIRCLE { x 1.2 y 2 size .17 }
}

rule U_V_DOTS{
	CIRCLE { x .8 y 2.2 size .17 }
	CIRCLE { x 1 y 2 size .17 }
	CIRCLE { x 1.2 y 1.8 size .17 }
}

rule U_V_DOTS{
	CIRCLE { x .8 y 2.2 size .17 }
	CIRCLE { x 1.2 y 2.2 size .17 }
	CIRCLE { x 1.2 y 1.8 size .17 }
	CIRCLE { x .8 y 1.8 size .17 }
}

rule U_V_DOTS{
	CIRCLE { x .8 y 2.2 size .17 }
	CIRCLE { x 1.2 y 2.2 size .17 }
	CIRCLE { x 1 y 2 size .17 }
	CIRCLE { x 1.2 y 1.8 size .17 }
	CIRCLE { x .8 y 1.8 size .17 }
}

rule U_V_DOTS{
	CIRCLE { x .8 y 2.2 size .17 }
	CIRCLE { x 1.2 y 2.2 size .17 }
	CIRCLE { x .8 y 2 size .17 }
	CIRCLE { x 1.2 y 2 size .17 }
	CIRCLE { x 1.2 y 1.8 size .17 }
	CIRCLE { x .8 y 1.8 size .17 }
}

rule L_V_DOTS{
}

rule L_V_DOTS{
	CIRCLE { x 1 y 1 size .17 }
}

rule L_V_DOTS{
	CIRCLE { x .8 y 1 size .17 }
	CIRCLE { x 1.2 y 1 size .17 }
}

rule L_V_DOTS{
	CIRCLE { x .8 y 1.2 size .17 }
	CIRCLE { x 1 y 1 size .17 }
	CIRCLE { x 1.2 y .8 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1.2 size .17 }
CIRCLE { x 1.2 y 1.2 size .17 }
CIRCLE { x 1.2 y .8 size .17 }
CIRCLE { x .8 y .8 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1.2 size .17 }
CIRCLE { x 1.2 y 1.2 size .17 }
CIRCLE { x 1 y 1 size .17 }
CIRCLE { x 1.2 y .8 size .17 }
CIRCLE { x .8 y .8 size .17 }
}

rule L_V_DOTS{
CIRCLE { x .8 y 1.2 size .17 }
CIRCLE { x 1.2 y 1.2 size .17 }
CIRCLE { x .8 y 1 size .17 }
CIRCLE { x 1.2 y 1 size .17 }
CIRCLE { x 1.2 y .8 size .17 }
CIRCLE { x .8 y .8 size .17 }
}

romulusnr
Posts: 13
Joined: Wed Jul 06, 2005 2:50 pm
Location: Seattle

Post by romulusnr »

In the real game, the count of dots in touching squares of different tiles have to match.

(Also tiles should never overlap :) )

No idea how CFDG could do that elegantly.

User avatar
aaronstj
Posts: 66
Joined: Wed Jul 06, 2005 11:34 am
Location: Seattle

Post by aaronstj »

I know that tiles needs to match. I have a vague idea how that might be done elegantly, but I'm way too lazy.

Post Reply