help with creeper control

Started by teknotiss, August 14, 2013, 12:13:17 PM

Previous topic - Next topic

teknotiss

hey code monkey/deities! i want to have a CRPL script that stops creeper from rising above a terrain height, so i had a bit of a look through the CRPL docs and help stuff, but i found C++ REALLY annoying, and doing it all backwards is a bit of a leap.
so could someone walk me through such a script? i feel it shouldn't be too hard, but i don't know how to start.
this would seem like the logical place
#Set the creeper to height 5 on the current position
CurrentCoords 5 SetCreeper
but how do i make that on all co-ordinates?
or should i be doing an "if (creeperheight) x" sort of script?
or perhaps a "while (creeprheight) x" etc etc.
since it will be effecting the whole map i feel it should be the most efficient code possible, whatever that maybe  ::)
so to prevent me melting my brain i ask for the assistance of a CRPL wunderkind!
cheers in advance  ;)
"Is God willing to prevent evil, but not able? Then he is not omnipotent.... Is he able, but not willing? Then he is malevolent.... Is he both able and willing? Then whence cometh evil?.... Is he neither able nor willing? Then why call him God?" --- Epicurus

thepenguin

#1
tek, meet me in chat to talk more.

you want to use "do" loops.


MapHeight 0 do
MapWidth 0 do
  I J 5 SetCreeper
loop
loop
We have become the creeper...

Michionlion

Yes, you will also need to use 'if' statements to check if the creeper needs to be set back to the limit, or is already below it.
Something like this:

I J GetCreeper <-limit gt if
I J <-limit SetCreeper
endif
"Remember kids, the only difference between science and messing around is writing it down."
                                                                                                                         - Adam Savage

My website
My CW1, and CW2 maps!

teknotiss

cheers for the help dudes, but it seems CRPL isn't able to do what i want without WAY too much fuss. to id and then create scripts for each safe area/stepping stone would take longer than i care to spend.
so there goes a great map idea, but hey ho way it goes.

just a Q for virgil (if you have time dude, not massively important) how big could a map be for a script to limit the creeper height in every cell to, say, terrain height 9 in game play?

or could i break the cell check into multi frame events?
ie
check cells x1,4,7,10... in frame 1
check cells x2,5,8,11... in frame 2
check cells x3,6,9,12... in frame 3
or something similar? perhaps limiting whole rows of cells would be less script heavy.
problem is i just dunno about any of this.....
"Is God willing to prevent evil, but not able? Then he is not omnipotent.... Is he able, but not willing? Then he is malevolent.... Is he both able and willing? Then whence cometh evil?.... Is he neither able nor willing? Then why call him God?" --- Epicurus

Grauniad

There may be different ways to think about it.

You may be able to simply check a cell width around each stepping stone, You may be able to set the emitters to limit their emission to 9- or 8.9 deep. Any number of options.

Co-incidentally, I just asked (in another thread) since I think that the creeper sim only updates 2 times a second - but I may be confusing it with an older game.
A goodnight to all and to all a good night - Goodnight Moon

teknotiss

i think i may have bitten off a rather large chunk to get started on  ::)
i have zero rpl experience, and i hated coding when i did it 15 years (or more!) ago, so it's really only something i want to do if it's not too hard or time consuming.
but, unfortunately, i don't have the first idea of how to go about either of the two options you suggested.  :(
"Is God willing to prevent evil, but not able? Then he is not omnipotent.... Is he able, but not willing? Then he is malevolent.... Is he both able and willing? Then whence cometh evil?.... Is he neither able nor willing? Then why call him God?" --- Epicurus

Grauniad

An emitter on Terrain level 1 that emits to depth of 5 will never have creeper rise above level 6. In fact, it will absorb creeper over that limit. At least it did last time I checked. You may want to check with Virgil if he changed the code.

So if you set strong emitters on low levels, you can still avoid flooding the stepping stones.
A goodnight to all and to all a good night - Goodnight Moon

knucracker

Yeah, the best way in general is to just set the emitter values to the max height that you want Creeper.  So set your emitters to 9 and put them on level 1 terrain.  Or different combinations of terrain height and emitter strength.  If you want more Creeper, then have the emitters emit more frequently or just put more of them.

That's the easiest way to get a map with areas that never flood.  Now of course shields or other things could push Creeper up on them, but in general the Creeper on the map won't get ever deeper so you can have islands that don't flood.

Alternately, you can just put a band of VOID around an island and it will never flood, except in cases of extremely high Creeper.

Another alternative is to put a core on an island and to turn on the tower field for the core and set it to push outwards.  With a high field strength, no Creeper will make it onto the little island.  It will be like there is a shield there.

Or you could load up a list with coordinate pairs in CRPL and set just those cells to X Creeper if the creeper there is greater than X.  This would work for a manageable number of cells.  If your islands are square, then use a loop, or a couple nested loops.

If you want to limit the entire map, every frame, then the CRPL for doing that could run into a lot of instructions per frame.  The current limit for a core is 500,000 commands per frame.  That is more of a safety limit than something you should push.  Naturally the more you do per frame the worse things get.  You could of course break things up across frames as you indicated, that would allow some creeper to spike higher for some number of frames, though.

If you really, really want some global always enforced Creeper limit the best way to do it would be to just wait for the next build.  I just added support for SetCreeperMax and SetAntiCreeperMax CRPL calls :)  I already scan over all creeper as part of the simulation and I already look for a min value (the evaporation limit).  So it is relatively trivial to add support for a max value.  See, if you have actually read this far into the message, I saved the best for last.

For those following along, the default value is 0, which means to not apply a max.  So integer overflow is still the default and creeper fusion is still possible.  But, if you want to disallow fusion (in some cases... there may be others) you can now just set a max on Creeper to prevent it.  Note that Creeper that exceeds the max is simply clipped to the max, so it is like an upper value evaporation.  AntiCreeper has a separate max, so you can limit Creeper without limiting AC.  The max for AC is expressed as a positive integer, even though AC is stored as a negative number internally.

teknotiss

Quote from: virgilw on August 14, 2013, 03:04:32 PM
....  See, if you have actually read this far into the message, I saved the best for last.

For those following along, the default value is 0, which means to not apply a max.  So integer overflow is still the default and creeper fusion is still possible.  But, if you want to disallow fusion (in some cases... there may be others) you can now just set a max on Creeper to prevent it.  Note that Creeper that exceeds the max is simply clipped to the max, so it is like an upper value evaporation.  AntiCreeper has a separate max, so you can limit Creeper without limiting AC.  The max for AC is expressed as a positive integer, even though AC is stored as a negative number internally.

waiting! that sounds like the solution for me! ;)
of course trying something simple first would be an idea i guess! i'll have a bash at some more basic things while i wait for the next build.
the spilt frame clipping would work for the map idea i had since the islands were plenty large enough for a relay and some overspill (if it was clipped in the next few frames), but a global max is a better idea.
i don't understand the emitter limits though.
might try the limiting of emitters idea though (could be something to add to the unit option in the editor!), can i make one CRPL core and scipt to effect all emitters? or one each?
"Is God willing to prevent evil, but not able? Then he is not omnipotent.... Is he able, but not willing? Then he is malevolent.... Is he both able and willing? Then whence cometh evil?.... Is he neither able nor willing? Then why call him God?" --- Epicurus