### Author Topic: Quasi-Random patterns  (Read 2554 times)

#### March

• Newbie
• Posts: 6
##### Quasi-Random patterns
« on: April 25, 2014, 06:45:08 PM »
There are lots of things that are designed to look random but actually aren't and I'm struggling with elegant solutions to these.  An example is the attached floor pattern.

The logic is:
1) There are three tile sizes that create varying row widths, never have the same size next to one another, and occur at about the same frequency.  This was manually created with the Sequence operator.
2) The joints are "randomly"staggered but the joints are always in 10 centimeter increments.  You can see in the diagram how this was done.  Artithmetic expresion is Input1*Input2 with input 1 being a random integer between 1 & 7 (tiles are .7meters long) and input 2 being a constant of 0.1 (Scene units is meters).

This works exactly how we want EXCEPT we would like to never have joints align with the row above or below it.  I feel like the answer lies with something like the SegmentYCounter in the expression editor to build an expression that looks "random" but is actually not and because it is somehow incremented with the SegmentYCounter, it never has adjacent repeats because it "knows" what number was used before.  I haven't had any luck with that line of thinking yet however.  The work around was to just manually offset each row the way I wanted  (screen03) and it worked but is not as elegant a solution.

I feel like this is a pretty common problem for anything that is designed to look random and I noticed another post where someone was struggling with a similar issue with material IDs.  Are there any good techniques in Rail Clone to accomplish these sorts of things and if not, perhaps there could be one day?  Any help would be greatly appreciated.

#### March

• Newbie
• Posts: 6
##### Re: Quasi-Random patterns
« Reply #1 on: April 25, 2014, 06:53:25 PM »
Just writing this made me think of the following but I'm sure how to write the expression for it or even if it is possible buy what if even rows were offset by even numbers and off rows were offset by odd numbers, you would in theory never have adjacent repeats.  The logic would be:

If row is odd (SegmentYCounter), translate by a random odd number between 1-7 * 0.1
If row is even (SegmentYCounter),  translate by a random even number between 2-6 * 0.1

In this case, 0 & 7 would yield the same results since the tiles are .7 meters long.
hmmmm, i have to see if there is a way to write this....

Edit:  Trying to wrap my head around the MOD function...
« Last Edit: April 25, 2014, 07:06:11 PM by March »

#### March

• Newbie
• Posts: 6
##### Re: Quasi-Random patterns
« Reply #2 on: April 25, 2014, 08:00:15 PM »
LOL, Problem solved...
My arithmetic expression is...

if (mod(SegmentYCounter,2),(Input1*2)*Input2,((Input1*2)-1)*Input2)

and the random parameter was set to an integer between 1 and 3.  Input 2 is a .1 (meters) constant to convert the joint spacing to 10 centimeter increments.

mod(SegmentYCounter,2) test if the row is an odd or even row.
(Input1*2)*Input2 created an even number between 2 & 6 and then multiplies it by input 2
((Input1*2)-1)*Input2 created an odd number between 1 & 5 and then multiplies it by input 2

#### iToo

• Hero Member
• Posts: 3651
##### Re: Quasi-Random patterns
« Reply #3 on: April 25, 2014, 09:39:10 PM »
Glad the problem is solved. I'm not sure if this case would be solved in other way, since i may need to test for a while with the scene.
Anyway, if you need help with this or other style, don't hesitate to post again.
Carlos Quintero
iToo Software

#### March

• Newbie
• Posts: 6
##### Re: Quasi-Random patterns
« Reply #4 on: April 25, 2014, 10:21:11 PM »
Thank you, I will.

For future versions, may I request a "Quasi-Random" parameter that allows for various implementations of a random number generator/algorithm?  Things like non-repeating random numbers (uses them all before starting over) or non-successive random numbers (same number never happens 2x in a row)?  I'm still new to the software but it appears we can not run loops or store our own variables so there is no way to code these conditions internally.   Perhaps even weighting numbers would be useful as well, assigning probabilities and such.

Also, a Sequence "parameters" in addition to operator that works like a numberic would be very useful to be able to feed an operator a sequence of numbers to cycle through and would make for more elegant solution to certain tasks as well.   These are all just suggestions that came about when I was thinking through ways of solving this particular problem.  Cool software though, going to be great when it reaches the maturity of Forest Pack.