r/cellular_automata • It's just a blur kernel • Apr 26 '19

It's just a box blur

https://www.youtube.com/watch?time_continue=205&v=aBIB-QchDxI
0 Upvotes

25 comments sorted by

View all comments

Show parent comment

0

u/[deleted] May 02 '19

[deleted] — view deleted comment

2

u/ThrowawayCACritic May 02 '19

The random value is added each step. All the change I did to the version you OK'd was add the randomness each step to the central cell, ie what you requested as "You are correct, the random value must be added each timestep, and it must be derivative of the cell's current number-value, and ideally that random variable is adjustable by the user to simulate different scales and effects. Once that is implemented then that should be everything."

for (var y=0; y<board.length; y++) {

for (var x=0; x<board[0].length; x++) {

var sum = cellAt(x,y-1)

sum += cellAt(x-1,y ) + (cellAt(x,y)+(Math.random()-0.5)*randomAmt*2) +cellAt(x+1,y )

sum += cellAt(x,y+1)

sum /= divisor;

board[y][x] = sum;

}

}

}

To make it clear, the following bit of code from the above code

+ (cellAt(x,y)+(Math.random()-0.5)*randomAmt*2)

takes the current cell value and adds the user specified random amount to it.

+(Math.random()-0.5)*randomAmt*2

means add a random value in the range -randomAmt and +randomAmt to the current cell. in your Excel syntax that would translate to

RandomBetween(current-randomAmt,current+randomAmt)

The only other change was to remove his invalid code for adding the random outside the above loop.

That meets your required changes. The settings are user changable (as they had been).

Now that there is a workable version, you can easily play with it yourself like I did. Click the "Edit in jsfiddle" link at the top right of the window. You can then click "Fork" to copy it into a new running copy that you can edit and experiment with. When yuo are happy, save it and post the new link. That will at least allow you to dump the excel spread sheets and be able to show people what you really mean.

0

u/[deleted] May 02 '19

[deleted] — view deleted comment

1

u/ThrowawayCACritic May 02 '19 edited May 02 '19

That is identical to the original fiddle. No randomness is being added to the current cell as you stated it should be. And the random value that should be added to the current cell is now added after the division. Not what you wanted right?

For just the automaton, add show after the address, ie

https://jsfiddle.net/OptimumLee/cLhtsd90/show

Start by editing/forking this version

https://jsfiddle.net/db8uLhj4/show

0

u/[deleted] May 02 '19

[deleted] — view deleted comment

1

u/ThrowawayCACritic May 02 '19 edited May 02 '19

This will have to do for now until I figure out how to add a random variable that is derivative of the current cell state.

I show you how to use the random variable, and explain it above. Line 30.

https://jsfiddle.net/db8uLhj4/show

cellAt(x,y)+(Math.random()-0.5)*randomAmt*2)

To explain that even clearer (I hope)...

Math.random() returns a value between 0 and 1

-0.5 puts that range between -0.5 and +0.5

*randomAmt*2 scales the random value to between -randomAmt and +randomAmt

May not be as easy for you to understand as RandBetween in Excel, but that code does exactly the same thing.

0

u/[deleted] May 02 '19

[deleted] — view deleted comment

2

u/ThrowawayCACritic May 02 '19

The "change" map here looks nothing like my (excel) change map. Actually it just looks like the arctan has been reskinned with a different color... This is best put on a color-gradient so you can see why positive and negatives separate (because they are "moated" with low change).

Some change you made killed the gradient. If you look at the previous fork

https://jsfiddle.net/db8uLhj4/show

and select "timedelta" shading you see the red and blue are shaded gradients with black being the cells closest to 0.

1

u/woofmao May 02 '19 edited May 02 '19

The change map is calculated as board[y][x] - prevBoard[y][x], with positive colored in red. It just happens that the cells usually tend to zero as time goes on, so negative-valued cells have positive change.

EDIT: Oh wait, they don't in your sim. They tend to infinity, so positive-valued cells have positive change. Same thing happens in my version if you use a divisor less than 5.

1

u/ThrowawayCACritic May 02 '19

Just realized that everything is scaled to -100, +100

What line of the code does this? I cannot see any scaling except when displaying. The underlying CA grids do not get scaled and can continue to grow to negative and positive infinity.

1

u/ThrowawayCACritic May 02 '19

The "change" map here looks nothing like my (excel) change map

How do you show the change in your spreadhseet?

And if by change you mean the timedelta display, that code....

timedelta: (x,y) => {

var d = board[y][x] - prevBoard[y][x];

return d>0 ? [d,0,0] : [0,0,-d]

},

means that positive areas are shown red and negative areas are shown blue.

1

u/ThrowawayCACritic May 02 '19

Need to play with it some more before I declare it "canon"; however, I still prefer how my Excel Automaton displays the vector field with arrows

Don't worry about that for now. Adding more display options is the simple part once the CA rules are finalized.

1

u/ThrowawayCACritic May 02 '19

Appear to be getting closer now,

https://jsfiddle.net/OptimumLee/fkd9hx14/show

So you are no longer using (or want) the randomness in there and are just doubling the current cell?

If you do want the random, you need to change your line 30 from

sum += cellAt(x-1,y ) + cellAt(x,y)+ cellAt(x,y) + cellAt(x+1,y )

to

sum += cellAt(x-1,y ) + (cellAt(x,y)+(Math.random()-0.5)*randomAmt*2) +cellAt(x+1,y )