can any one please advise what is wrong with this code
i use xStep instead of steps and ystep instead of slidStep and i use S to change from north to south
The Code IS :
# 1- always increament X +=1
# 2- increament Y +=S
# 3- initial S=1
# 4- if to switch > change S to -S
# 5- if to Skip > increment Y +=S in addtion to the normal increament
# 6- if the Y more than slide (9) > set it to (1)
# 7- if the Y less than (1) > set it to (9)
# 8- increment Ttoal Steps
# Vars & Intials
SLIDE = 10
SWITCH = 7
SKIP = 11
xSTEP = 1
ySTEP = 1
S = 1
Y_PACE_LENGTH = 6
X_PACE_LENGTH = 4
while xSTEP <= 35:
self.moveXY(xSTEP * X_PACE_LENGTH, ySTEP * Y_PACE_LENGTH)
if xSTEP%SWITCH == 0:
S = -S
if xSTEP%SKIP == 0 :
ySTEP += S
#6 & 7
ySTEP += S
if ySTEP < 1:
ySTEP = SLIDE
if ySTEP > SLIDE :
ySTEP = 1
xSTEP += 1
Please use the triple bacticks (```) to wrap all your code (I think you are using blockquotes, don’t use them).
From what I can tell:
Increment xSTEP last, since the next ySTEP depends on the current xSTEP.
The below is not right
if xStep % SWITCH = 0 : # that's assignment, not equality
You should be using SLIDE below (though it doesn’t matter much, until you get a new seed):
if ySTEP < 1:
ySTEP = 9 # should be SLIDE
Finally one of the seeds I encountered required me when moving from sideStep = 1 to SLIDE move from 1 to SLIDE - 1. (Though I never encountered that one again, so…)
You can leave it. While we agreed to not post full solutions on request yours is not a full solution. Others have to understand trotod’s explanation and your code to derive a working solution so the desired learning effect is still applied.
I think I cheated…
All I did was step on 1 mine to active all of them and run away. Everyone died (but me) and I walked to the skeleton.
So now I’m wearing a nice viking helmet.
I got through this level with moveXY() in various places (will not post… obviously). Should there be a new set of boots that accept the slide commands w/o allowing moveXY()?
No new boots… It is hard to come up with a level that requires coding skills (this level is optional after all) and is not broken by some (labor-intensive) trick. You should need quite a lot of moveXY-commands there, and measure them exactly. Maybe it would help to disable the overlay that shows the coordinates under the cursor… I’ll propose that to Cat.
Finally one of the seeds I encountered required me when moving from sideStep = 1 to SLIDE move from 1 to SLIDE - 1. (Though I never encountered that one again, so…)
I just encountered this, is there a way to tell what seed I’m using to help report it? Cause I changed my code 3x thinking I had it wrong before realizing this was intended…
Getting the level seed is apparently not that easy, but I will leave it here for future reference.
You can instead simply tell us the three variables you received, we can regenerate the level from that.
Getting the seed
Quote from HipChat:
Nick Winter
19:22
you can generate the seed from the session ID and the submit count, which you can get with… currentView.session.id/code currentView.session.get('state')
and then look in the Existence System to see how the seed is generated
Enter the mentioned code-fragment in the JS-console, execute and … well, look in the existence system in the level-editor.
We do not give out correct code on these forums. CodeCombat’s purpose is to help people “learn how to code by playing a game.” You can not learn how to code if you don’t do coding.
Your code learned me something new, even though i already solved the puzzle in another way, you taught me about the North = not North function, that might be handy sometimes.
Anyway, your code works just fine, but you should delete two lines that do nothing except break otherwise good code.
The north booleans in the slide section of your code should not be there.