stripes???

Started by thepenguin, December 26, 2012, 11:56:27 AM

Previous topic - Next topic

thepenguin

somehow this script gave me these stripes (see attatched maps and screenshots)
ShowTraceLog
0 ->Theta
5 ->Alpha
MapHeight 1 sub 0 do
MapWidth 1 sub 0 do
<-Theta 1 add ->Theta
<-Alpha I J GetTerrain sub ->Beta
<-Beta 0 gt if
I J <-Beta SetCreeper
else
I J 0 SetCreeper
endif
loop
<-Theta 500 gt if
1 delay
0 ->Theta
endif
loop
"Finished" Trace
We have become the creeper...

lurkily

#1
What are you trying to do?  You seem to be looking for terrain heights less than '5', and setting creeper on that terrain to "5 - TerrainHeight".

Perhaps you meant to use  "<-Alpha I J GetCreeper sub ->Beta" instead of "<-Alpha I J GetTerrain sub ->Beta"?  That would dig a hole into any creeper that exceeded a depth of 5 . . .

Either way, I'm not sure what you're trying to accomplish, or why you're getting lines.  I can't test, being at work, though, and that might shed more light.  Comments in your script describing what your script is intended to do at each point will very much help us know what your script is intended to do, and will help other people easily determine when the code is not written according to your intent.


This is what I'm reading in your script:

Quote from: Lurkily's CommentaryFor every map cell
increment Number of cells processed (Theta) starting from 0.
Sub that cell's terrain level from alpha and store in 'beta'.
If "5 - this cell's terrain"(Beta) is GT 0, set creeper equal to "5 - this cell's terrain"(Beta)
Else set creeper to 0 - dig a hole to bare rock.
Pause every 500 cells(Theta = 500) to rest for 1 frame.

J

The stripes come from the creeper height on the cells so I think it has to do with rounding. If you try numbers like 4.9 or 3.6 you won't see any stripes.

For if you don't know what the script does, it sets the creeper to a certain height in every cell, in such way the creeper height + terrain height is the same everywhere. It does one row per frame, and when reaching the bottom of the map, it shows 'finished' in the trace log and starts again from the top of the map.

lurkily

Quote from: J on December 26, 2012, 12:55:58 PM
The stripes come from the creeper height on the cells so I think it has to do with rounding. If you try numbers like 4.9 or 3.6 you won't see any stripes.

For if you don't know what the script does, it sets the creeper to a certain height in every cell, in such way the creeper height + terrain height is the same everywhere. It does one row per frame, and when reaching the bottom of the map, it shows 'finished' in the trace log and starts again from the top of the map.
So basically, you want there to be one universal level that all creeper cannot rise above, regardless of terrain?  Are you trying to create a ceiling, or would you rather average all creeper so that you aren't REMOVING creeper, just spreading it evenly?

Because Alpha is always 5, The line <-Alpha I J GetTerrain sub ->BetaShould make <-Beta 0 gt ifAlways reduce creeper by 5 at terrain height =< 5, and to 0 everywhere else.

I can only think this through as a thought experiment where I am right now, and am somewhat distracted . . . so if I make some mistakes, please forgive me.

J

It sets the creeper to a certain level (defined in Alpha) no matter of the terrain.
Try it in CW3 and see.

Found something that explaines the stripes: When setting the creeper, the creeper can move away before the bordering cells are filled, so there's a slight loss of creeper. Once the creeper finally reached exactly the height, it shows it is one level higher. If you use<-Theta MapWitdh gt ifyou'll get less stripes, use<-Theta MapWitdh 2 mul gt ifand you will get stripes.This one seems to work best to avoid stripes:<-Theta MapWitdh 2 div gt if

lurkily

#5
Okay . . . looking at it in the right light, I can see it doing that . . . I'm gonna stop commenting at work, I think.  Without being able to run it and insert traces where I need more understanding, it's just a recipe for disaster.  

My one suggestion will be to use a decimal as your threshold.  You only get gradients when you rise above 5 - so instead, use 4.5 as a threshold, and even if you do get 'stripes' of creeper height, they will not be visible as gradients.

Sorry for this whole thread . . . I love exploring and tinkering with examples that I don't fully understand, but without CW3 at hand it's probably counterproductive for me to comment.