set number distribution?

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
ceee
Posts: 2
Joined: Wed Mar 09, 2011 5:55 pm

set number distribution?

Post by ceee »

Hi! I'm new and was playing around trying to create a certain distribution of rectangles on a grid - I was wondering if it's possible to set an absolute number to the different rectangles in my grid? I have, (and I'm probably overcomplicating this :) ) the following:

Code: Select all

startshape grid
 
rule grid {5* {y 1 } row{} }
rule row {5* {x 1 } shape{} }
 
//square  filled small vertical
rule shape 1 { SQUARE {x 1.3 s 0.2 0.4} }

//square filled small horizontal
rule shape 1 { SQUARE {x 1.3 s 0.4 0.2} }

//square filled big vertical 
rule shape 1 { SQUARE {x 1.3 s 0.3 0.6} }

//square filled big horizontal 
rule shape 1 { SQUARE {x 1.3 s 0.6 0.3} }

//square unfilled  small vertical 
rule shape  1 { SQUARE{x 1.3 size 0.6 0.3} SQUARE{x 1.3 size 0.4 0.2 b 0.99}  }

//square unfilled  small horizontal 
rule shape  1 { SQUARE{x 1.3 size 0.3 0.6} SQUARE{x 1.3 size 0.2 0.4 b 0.99}  }

//square unfilled big vertical 
rule shape  1 { SQUARE{x 1.3 size 0.4 0.2} SQUARE{x 1.3 size 0.2 0.1 b 0.99}  }

//square unfilled big horizontal 
rule shape  1 { SQUARE{x 1.3 size 0.2 0.4} SQUARE{x 1.3 size 0.1 0.2 b 0.99}  }

//square empty
rule shape  1 { SQUARE{x 1.3 size 0.2 0.4 b 0.99} }
I've read that the number after my rule "shape" can be used to assign a certain probability, and I've tried playing around with this, but it's not quite what I'm looking for, since I'm looking for a specific number of each specific square type? Any ideas? I'd be really grateful. Thank you!

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: set number distribution?

Post by MtnViewJohn »

The effect that you are trying to achieve cannot be done using a context free grammar, so Context Free (the program) cannot do it. Each shape is drawn without any knowledge of the other shapes.

ceee
Posts: 2
Joined: Wed Mar 09, 2011 5:55 pm

Re: set number distribution?

Post by ceee »

I was afraid this might be the case, but oh well. Thank you so much for clarifying and replying so quickly <3 That's lovely of you.
The program is still super fun and I'll be trying different things with it for sure! :)

(Not sure if this is allowed, but I'd be very grateful for alternate program suggestions that might be able to solve my idea with my minimal programming knowledge :) Thank you!)

Post Reply