Coding Challenge: Remote Fields. Closed Feb. 21

Started by GameGibu, February 20, 2016, 12:40:07 AM

Previous topic - Next topic

GameGibu

Hello all,

I have a map almost ready to test; but I need a way of continuously setting a field remotely.

I cannot be a a terminal for a while, so I thought I would give you all  a challenge for your thinking bags:

Write me a crpl that can SetFieldCell on a distant 3x3 area given four parameters:
TargetX, TargetY, StrengthX, and StrengthY.

TargetX and TargetY are in map cell coordinates. StrengthX and StrengthY are in Integer Creeper as per the SetFieldCell function. These are all input variables, so in code the once block should look similar to this:
once
$TargetX:0
$TargetY:0
$StrengthX:1000000
$StrengthY:1000000

#other initialisation functions. (This should be an untouchable, un-nullifiable, not-required-to-win core. It will float in space, possibly outside the map border. )

endonce


I will credit whoever completes this challenge with the best code in my next map!

Ends 2016.02.21 23:59 Earth Standard Time.

Best of luck, ;D
-GameGibu
Bringing you Custom maps since 2971!
☆CRPL Master☆

Builder17

#1
Code attached.

$TargetX:0
$TargetY:0
$StrengthX:1000000
$StrengthY:1000000

once
SetUnitAttribute (Self CONST_TAKEMAPSPACE 0)
SetUnitAttribute (Self CONST_NULLIFIERDAMAGES 0)
SetUnitAttribute (Self CONST_COUNTSFORVICTORY 0)
SetUnitAttribute (Self CONST_CREATEPZ 0)
SetUnitAttribute (Self CONST_SUPPORTSDIGITALIS 0)
endonce

<-TargetX 2 add <-TargetX 1 sub
do
   <-TargetY 2 add <-TargetY 1 sub
   do
      I J <-StrengthY <-StrengthX 0 0 SetFieldCell
   loop
loop

GameGibu

I'll look at it after Reentry, when we touch down and I have access to a terminal.

Everyone else should keep writing though, I'd like to see how all your skills match up!  :D :D :D

-GameGibu
Bringing you Custom maps since 2971!
☆CRPL Master☆

GameGibu

Looking at the do loop, it should have worked, but in testing it I could not get the do loop to work, so I rewrote my own loop and it worked fine.  :-\

And the winner is: Builder17!
(of course, it was the only entry...)

You will receive recognition in my next map for your contribution!  :D

Thanks for participating!
-GameGibu
Bringing you Custom maps since 2971!
☆CRPL Master☆