Mad Pod Racing - Puzzle Discussion

Can I have some help, my pod isn’t going forward. Or it’s not going straight forward when I change “thrust” in the print with for example “100”

import sys
import math

        thrust = 100
        # Auto-generated code below aims at helping you parse
        # the standard input according to the problem statement.


        # game loop
        while True:
            # next_checkpoint_x: x position of the next check point
            # next_checkpoint_y: y position of the next check point
            # next_checkpoint_dist: distance to the next checkpoint
            # next_checkpoint_angle: angle between your pod orientation and the direction of the next checkpoint
            x, y, next_checkpoint_x, next_checkpoint_y, next_checkpoint_dist, next_checkpoint_angle = [int(i) for i in input().split()]
            opponent_x, opponent_y = [int(i) for i in input().split()]

            # Write an action using print
            # To debug: print("Debug messages...", file=sys.stderr)


            # You have to output the target position
            # followed by the power (0 <= thrust <= 100)
            # i.e.: "x y thrust"
            print(str(next_checkpoint_x) + " " + str(next_checkpoint_y) + " " + thrust)

            if next_checkpoint_angle > 90 or next_checkpoint_angle < -90 and next_checkpoint_dist >= 6000:
                thrust = 0
            else:
                thrust = 100
            print(x, y, thrust)

Hi @JBM, I tried adding a text to the output line, but I get an error for invalid input. Shouldn’t it work like this: Console.WriteLine(X + " " + Y + " " + thrust + " " + text);

Edit: Already found the error. It’s not possible to include an empty space without an text following. You must have atleast one char behind the " ".

Is there a way to check the current Lap you’re in and your opponent is in? Or is there a way to check if you are in the leading position?

1 Like

Since they are not given in the inputs, you have to track them in your program.
Current lap: A pod completes a lap when it passes checkpoint 0. Count how many times that happens.
Leading position: Compare number of checkpoints passed and use distance to next checkpoint as a tiebreaker.

2 Likes

My code was crashing in the gold leage. I found out it was because of a received value -1 from readline for opponent pod next checkpoint id!? Easy fix, but still strange…

I’m more than sure it’s because you read input wrong.Copy your code somewhere and reset code in the IDE to get correct input reading.

I think you aren’t giving the correct output to the program. First of all, you are giving the input TWICE (you have two print statetemetns. Second of all, your second output is wrong; it is not a string, and most importantly, you are giving the pod’s location as it’s goal instead of the next checkpoint! And rembember, having a thrust of 0 can cause your pod to be unable to turn inside the 90 degrees barrier you have set.

I was working in the IDE right before I leveled up and it overwrote my previous good submission with uncompilable code. Now my score is tanking because it doesn’t compile. I can’t figure out how to edit a previous level’s code after leveling up. Any one know how to fix a previous level’s submission?

Hello,
I would like to report 2 things about Coders Strike Back

  1. It should be written somewhere that the next check point id of a dead opponent is -1!
    https://www.codingame.com/replay/157943234
    Agade die, then I die at the next lap (due to idCheckPoint for Agade equals -1). Which leads to equality.
    This issue seems to happen only when I am player 2.

  2. I think that I found a bug in codingame
    Here is an example of match:
    https://www.codingame.com/replay/157929038
    I have printed the input data at each turn, here is turn 7:
    Sortie d’erreur : (Player 1)
    0 : angle = 227.0 - x = 8359.0 - y = 6927.0 - vx = -215.0 - vy = -52.0
    1 : angle = 215.0 - x = 8951.0 - y = 6246.0 - vx = -81.0 - vy = -206.0
    2 : angle = 239.0 - x = 7860.0 - y = 7580.0 - vx = -209.0 - vy = -20.0
    3 : angle = 203.0 - x = 9538.0 - y = 5655.0 - vx = -49.0 - vy = -205.0
    Lap = 7

Sortie d’erreur : (Player 2)
0 : angle = 239.0 - x = 7860.0 - y = 7580.0 - vx = -209.0 - vy = -20.0
1 : angle = 203.0 - x = 9538.0 - y = 5655.0 - vx = -49.0 - vy = -205.0
2 : angle = 228.0 - x = 8359.0 - y = 6927.0 - vx = -215.0 - vy = -52.0
3 : angle = 214.0 - x = 8951.0 - y = 6246.0 - vx = -81.0 - vy = -206.0
Lap = 7

The angles provided for player 1 are different then the one provided for player 2 (obviously for the same turn/same pod). The issue seems to appear after the first collision.
I have checked, and it’s the player 2 that have the wrong data.
I don’t know if its specific to the language, but I am using Java :wink:

Thanks in advance for your feedback. This game is still awesome :wink:

1 Like

I can reproduce the 2), so I added it to the bug board. It will be fix as soon as possible. Thanks for the report.

1 Like

Thanks SaiksyApo :slight_smile:
You haven’t been able to reproduce the 1) ?
It only happens when player 1 timeout (not when player 2 timeout).

I am sorry in advance, but I think that I just find another bug… XD
I think there is something wrong in CG computations. (If I am right, I am really surprised to be the first one to highlight this)

3) Math error
I have tried to have something easy to reproduce the issue:
Options:
seed=807222711
pod_per_player=2
pod_timeout=100
map=3608 5206 13596 7597 12464 1358 10518 5956

Output loop 1
Player 1
86385 60997 100
91225 53679 100
Player 2
0 0 0
0 0 0

Ouput loop 2
Player 1
65373 83577 100
71779 78875 100
Player 2
0 0 0
0 0 0

ERROR FOUND!
Data provided by CG
Pod id = 1 - position (3723.0 5853.0) - speed (121.0 95.0) - angle = 47.0
Computed data
Pod id = 1 - position (3722.0 5853.0) - speed (120.0 96.0) - angle = 47.0

I have manually performed the math, and the error seems to be in your side.
x = 3580, y = 5740, vx = 74, vy = 40
Output : x = 71779 y = 78875 Trust = 100
New vx = 74 + 100 * cos(47.0002057) = 142.199573
New vy = 40 + 100 * cos(47.0002057) = 113.135615
New x = 3580 + 142.199573 = 3722.19957
New y = 5740 + 113.135615 = 5853.13561

End loop leads to:
x = Round(3722.19957) = 3722
y = Round(5853.13561) = 5853
vx = Trunc(142.199573 x 0.85) = 120
vy = Trunc(113.135615 x 0.85) = 96

If you want I can help for the debug :wink:

EDIT: Thanks PB, the issue is due to the angles! Angles are never rounded, the ones provided as input by CG are provided rounded (finally its like mars lander), to have the correct behaviour you have to keep the computed one :wink:

1 Like

The 1) is the default behavior in every puzzle. We may drop a line about it, but it’s not a bug.

I disagree on 1) being the default behaviour. CSB is a 1v1 game, if the opponent is “dead”, then you have won.

The default behaviour you describe makes sense for 1v1v1 and 1v1v1v1 games.

1 Like

It’s a race, if the opponent is not able to pass a “dead” guy, it doesn’t deserve to win either.

2 Likes

On turn one, you face in the direction 28.67°.
On turn two, you try to face in the direction 47,00°.
This is a 18.33° rotation, which is not allowed by the game engine.
If you correct the rotation to 46.67°, you get the correct output given by the game engine.

The source of the discrepancy comes from the fact that the game engine stores the angle with a floating point value that is never rounded, but only provides you with the rounded version.

Also, a small typo at the end of you message. It’s “round”, not “floor”.

Thanks a lot PB, you are right about angle! I must not round them. I have edited my previous post ;).

For problem 1), it is weird to have a different behaviour according to our player id.
I understand why the implementation give this behaviour: it is implemented like players are providing their outputs one after the other (which is true for many games, but not CSB).

I can’t seem to get my little pod to move, I have output such as:

Pod 1 of player pandasforbreakfast moves towards (4502, 6010) at power 100

but the pod doesn’t move, and of course the boss wins, and I have no feedback why my pod did not even move - just the comments say it did.

(4502 6010 are the coordiantes of flag 1)

So I’m not sure how I can get started, let alone refine things??

Can someone please explain to me how to defeat boss 2 because we are absolutely lost, if you could include code examples and stuff like that so we can understand,

what have you tried so far?

Can any one help me how to use BOOST?
I am using python