Kirk's Quest - The Descent - puzzle discussion (old)

Feel free to send your feedback or ask some help here!

WARNING: The rules of this game have been changed on the 3rd of March 2016.

5 Likes

Wrote some code that runs correctly as a test singly and in batch, but when submitting it shows entirely diffrerent behavior and insists I do not meet the objective for the single shot per mountain test.

you have to shot the tallest mountain each time to make it work.

  • You need to be careful about the X coordinate to not be wrong.

At last, as a general advice, tests performed at submit time are different (slightly) than tests at coding time.

I don’t think this input for this game is correct? Or possibly the way you output the strings in the game view on the left?

import sys, math

    # game loop
    while 1:
    
    SX, SY = [int(i) for i in input().split()]
    print(SX, SY, file=sys.stderr)
    for i in range(8):
        MH = int(input())
        print(MH, file=sys.stderr)
    
    print("HOLD")

I see:

"Let's destroy those mountains to secure our landing..."
stderr: 0 10  (+ mountain ranges)

Your spaceship is over mountain 0, your altitude is 10
stderr: 1 10  (+ mountain ranges)

Your spaceship is over mountain 1, your altitude is 10
stderr: 2 10  (+ mountain ranges)

Your spaceship is over mountain 2, your altitude is 10
stderr: 3 10  (+ mountain ranges)

...

Your spaceship is over mountain 6, your altitude is 10
7 10

Your spaceship is over mountain 7, your altitude is 10
7 9

Your spaceship is over mountain 7, your altitude is 9
6 9

...

Your spaceship is over mountain 4, your altitude is 9
3 9

You crashed your spaceship on mountain 3

This isn’t that much of a problem, but the text does state:

You can only fire once per pass on the mountain located directly below the starship. Firing on a mountain base will only destroy part of it and it will sink a random number of kilometers.

(emph in original)

1 Like

Ok this is frustrating me to no end.
I’m on test case two.
this is an example of what’s in my code:

print >> sys.stderr, X == Y
if X == Y:
   print Statement

and on the output console I see:
False
Statement

(WHAT!?)

any help, explaination, or ideas would be welcome?

I dunno why you have this error but your condition is odd, isn’t it?

How is it “odd”? I’m afraid your comment is a little vague. Purposely so I assume but it hasn’t helped me. So I’ll try to explain my situation differently. I hope that if I describe my method for a solution here it won’t give any one information they don’t want, and if so they should stop reading here. What I’m trying to do is find the biggest mountian and when the ship is over it telling it to fire and hold otherwise. In my code I check to see if the ship is currently over the largest mountain and then tell it to fire. However for some reason after the first shot, which is always correct on every test case, the ship then proceeds to mis-fire. Some times it holds when the conditions for firing are met sometimes it fires when the conditions for firing are not met and sometimes it fires more than once in the same 8 game turns.

1 Like

Sorry, i didn’t mean to confuse you.

I remember that this puzzle is a little tricky, not to choose which mountain to shoot, but to update the position of the ship correctly, search in that direction :wink:

I’ve gotten it to work. I found the assumption that wasn’t true. In my code there was this situation.

if (condition):
      print fire
print hold

the problem was that sometimes even though the condition was true my ship was still holding
I fixed it like this:

if (condition):
    print fire
else:
    print hold

the assumption that was incorrect was that for the purpose of these games I was using the print() as a return() and that after the the program encountered it’s first print() it stopped running it. However that wasn’t the case so after the first time ‘fire’ and ‘hold’ were printed my ship became more and more out of sync with the game state. Thus throwing off future shots and causing me to fail.

3 Likes

Great answer, thans this helped me too, I guess the problem in my and your code was that we was printing 2 echo statements for single position this why next points was moved by each of those double echo.

Can anyone tell me how to get the mountain height of the place where the ship currently is? I’m a total programming noob, so I’d love some advice/feedback!

Oh, I should mention, I’m doing this in Javascript.

if (condition):
    print fire
print hold

(I can’t quote code, that’s annoying ^^) so thanks, i forgot to put that kind of common mistake in the FAQ section. It’ll be there soon
EDIT: I didn’t forget, but i wasn’t explicit, so now it’s fixed :slight_smile:

Frequently asked questions

If you get the 8 moutain height + X position of the ship, then the mountain under the ship is at mountain_height[X]. Now it is your duty to find a way to stock mountain height, but it shouldn’t be a problem.

Read the problem again and I’m sure you’ll find the answer :wink:

So are you saying that MH returns an array? That was not clear to me. Perhaps this is a hint to whoever can edit the puzzle! Anyway, thanks!

Nope, but you could stock each MH in an array, yes :wink:

2 Likes

Basic challenge, finished it with Java. Good practice, hardest part for me is always understanding the initial problem.

1 Like

this was annoying. made same error. great catch

I got half of the half of the problems done with :
if mh != 0 :
print fire
else
print hold

Can’t understand how to make the other half work.

I did the first two “games” easily without a problem. However, I do not understand this one and have become rather frustrated. I don’t understand this concept of a “game turn” and what exactly that means. Do I try to set up actions for the ship within the for loop? Or is every “game turn” one iteration of the while loop? I also dislike that I can’t see what my values for SX and SY are as I update them, so there’s no way to tell if that is what is causing the issues. It would make things a lot simpler if there were some way to more directly interact with the results of my code.

5 Likes

A turn is a full iteration of the while loop. Every turn you will get a reading of the map first, You need to shoot rhe tallest one every turn, if that helps.
Use System.err.println{"SX: " + SX);

to see your values in real time.

MH’s value changes because of the while loop. MH will change ten times as it reads each mountain height of the map each turn.
Try using the System.err.println to see how your code is changing.