Mad Pod Racing - Puzzle Discussion

Mad Pod Racing. Wood 2 league - Obsolete data

Hi! :slight_smile:

Mad Pod Racing. Wood 2 league - Obsolete data
map=4000 3000 12000 3000 8000 6000
Opponent Boss 2

I really enjoy Mad Pod Racing.
Here is something i don’t understand.
I’m using Java.

Turn 54/168
It Says Lap 1/3 in top left corner.
Checkpoint 0 is lit. On screen the pod body is outside checkpoint 0 area.

Turn 54 debug output:
Position 3993, 3743 ← Y 3743 says pod is outside checkpoint 0 area.
Speed -295, -325 ← Difference in x and y positions from last turn?
Target 4000, 3000 ← This is the x, y position of checkpoint 0.

Turn 54 standard error stream:
pod position 4341 4126 ← This is different from debug output. Old data?
target 4000 3000 ← Target checkpoint 0. Same as debug output.
nextCheckpointDist 1177 ← Correct. But calculated from old data?
nextCheckpointAngle 9 ← Visually this isn’t right. Should probably be 17?
gameLoop 54

Turn 55
Lap 2 starts. Lap 2/3 in top left corner.
Checkpoint 0 light is off and checkpoint 1 light is on.
On screen the pod body is inside checkpoint 0 area.
Target is still checkpoint 0. Both in debug output and in standard output stream.
This move will be towards the wrong target.

Turn 55 debug output:
Position 3699, 3333 ← X, Y says the pod is inside checkpoint 0 area.
Speed -250, -348 ← Should be x -294, y -410?
Target 4000, 3000 ← Obsolete data from turn 54.

Turn 55 Standard error stream:
pod position 3993 3743 ← Obsolete data from turn 54 debug output.
target 4000 3000 ← Obsolete data from turn 54.
nextCheckpointDist 743 ← Obsolete data from turn 54 debug output.
nextCheckpointAngle 17 ← Obsolete data. Should be 87.
gameLoop 55

Turn 56
Both debug output and standard error stream gets new target. 1 turn too late.

Turn 56 Debug output:
Position 3476, 2904 ← debug ouput posisions always seems right
Speed -189, -364 ← I don’t know whats wrong here.
Target 12000, 3000 ← Right values but 1 turn too late.

Turn 56 Standard error stream:
pod position 3699 3333 ← Obsolete. Always 1 turn late.
target 12000 3000 ← Right values but 1 turn late.
nextCheckpointDist 8308 ← Calculated from old data.
nextCheckpointAngle 87 ← Obsolete. Always 1 turn late.
gameLoop 56

Sorry about the indenting. Its this editor or the browser.
Best regards! :slight_smile:

Game code:
import java.util.*;

class Player {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int gameLoop = 1;

    // game loop
    while (true) {
        int x = in.nextInt();
        int y = in.nextInt();
        int nextCheckpointX = in.nextInt();
        int nextCheckpointY = in.nextInt();
        int nextCheckpointDist = in.nextInt();
        int nextCheckpointAngle = in.nextInt();
        int opponentX = in.nextInt();
        int opponentY = in.nextInt();

        System.err.println("pod position " + x + "  " + y);
        System.err.println("target       " + nextCheckpointX + "  " + nextCheckpointY);
        System.err.println("nextCheckpointDist  " + nextCheckpointDist);
        System.err.println("nextCheckpointAngle " + nextCheckpointAngle);
        System.err.println("gameLoop            " + gameLoop);

        gameLoop ++;

        System.out.println(nextCheckpointX + " " + nextCheckpointY + " 85");
    }
}

}

It’s easier if you can share the replay link and screenshots too. But I’ll give you an explanation using my own replay and see if you can find the same thing.

Your code shows that you are printing to System.err the values of the variables at the beginning of the turn. And you have to refer to the previous frame of the replay to find the same numbers as that shows the state of affairs at the end of the turn.

Screenshots below: the console is printing out the values of the variables at the beginning of turn 11, which are the same as those shown as the state of affairs at the end of turn 10.

Hope it helps!

Hi guys!

A bit like @Slava_Ukraini the speed displayed is not the same as in the sys.err for me. Or i’m wrong ?

velocityX = nextX - currentX
velocityY = nextY - currentY

Nope ? :slight_smile:

Please check if my reply above your post helps. If not, please share the replay link and a screenshot of an example for our reference.

Thank you 5DN1L for you answer. :slight_smile:
I think I understand you.

This post will be only about Wood 2 league and the Debug speed output.
I see in you answer that you are in a higher league and I guess you get more input data.
Maybe even speed.
Also the league you are in, probably have this problem fixed.
I will post screenshots and try to post a replay. I’m not sure how it’s done. :slight_smile:

In Wood 2 league speed in debug output isn’t speed.
This is what i think it is.
Map is map=4000 3000 12000 3000 8000 6000
Replay: Coding Games and Programming Challenges to Code Better
//
//


Turn 1
1 output is done. Saying go to next checkpoint at thrust 88.

Turn 1 Debug output says:
Position: 4088, 2505
Speed: 74 , 4
Target: 12000, 3000

To get to the X position we calculate X speed and add that to the old X position:
Old X speed + thrust - resistance. 0 + 88 - 0 = 88.
Resistance is 0 because we start at X speed 0 and at X speed 0 the resistance is 0.
Old X position is 4000 and to that we add X speed 88. We get X 4088.
Our new X position at the end of turn 1 is 4088.
74 is part of the X speed calculation. But not for this turn.
//
//


Turn 2.
1 output is done. Saying go to next checkpoint at thrust 88.

Turn 2 Debug output says:
Position: 4250, 2514
Speed: 137 , 8
Target: 12000, 3000
xSpeed = oldXSpeed + thrust - resistance = 88 + 88 - 14 = 162
resistance is 14. That’s how 74 is involved. oldSpeed - 74 = 14.
Debug says X speed is 137. It’s not X speed. It’s part on next turns X speed calculation.
X Distance traveled from last turn: 4250 - 4088 = 162.
//
//


Turn 3
1 output is done. Saying go to next checkpoint at thrust 88.

Turn 3 Debug output says:
Position: 4475, 2528
Speed: 191 , 11
Target: 12000, 3000

xSpeed = oldSpeed + thrust - resistance = 162 + 88 - 25 = 225
Resistance is 25.
137 from turn 2 debug output is old speed - resistance = 162 - 25 = 137
X Distance traveled from last turn: 4475 - 4250 = 225.

Code:
I’m sorry about the indenting. I’ll try a different browser next time.
And the code isn’t important.
Only thing happening in code is:
System.out.println(nextCheckpointX + " " + nextCheckpointY + " 88");

Best regards! :slight_smile:

import java.util.*;

class Player {

public static void main(String args[]) {

    System.err.println("This is turn 0.");
    Scanner in = new Scanner(System.in);
    // After System.in turn is 1.

    System.err.println("This is turn 1. Before game loop start.");
    // int gameLoop is set to 1 to match number of turns.
    // Turns will be 0 to 168
    int gameLoop = 1;

    // game loop
    while (true) {

        int x = in.nextInt();
        int y = in.nextInt();
        int nextCheckpointX = in.nextInt();
        int nextCheckpointY = in.nextInt();
        int nextCheckpointDist = in.nextInt();
        int nextCheckpointAngle = in.nextInt();
        int opponentX = in.nextInt();
        int opponentY = in.nextInt();

     System.err.println();
        System.err.println("gameLoop            " + gameLoop);
        System.err.println("pod position        " + x + "  " + y);
        System.err.println("target              " + nextCheckpointX + "  " + nextCheckpointY);
        System.err.println("nextCheckpointDist  " + nextCheckpointDist);
        System.err.println("nextCheckpointAngle " + nextCheckpointAngle);
        System.err.println("opponent position   " + opponentX + "  " + + opponentY);

        gameLoop ++;

        System.out.println(nextCheckpointX + " " + nextCheckpointY + " 88");
    }
}

}

The game engine applies friction (this is the term used in the statement, equivalent to “resistance” in your message) after the pods have moved, i.e. at the end of every turn. So:

Turn 1:
X speed during current turn = Old X speed + thrust = 0 + 88 = 88
X-coordinate = Old X-coordinate + speed = 4000 + 88 = 4088
X speed at the end of turn = “Old” X speed x 0.85 = 88 x 0.85 = 74
4088 and 74 are shown in turn 1 of the replay.

Turn 2:
X speed during current turn = Old X speed + thrust = 74 + 88 = 162
X-coordinate = Old X-coordinate + speed = 4088 + 162 = 4250
X speed at the end of turn = “Old” X speed x 0.85 = 162 x 0.85 = 137
4250 and 137 are shown in turn 2 in the replay.

Turn 3:
X speed during current turn = Old X speed + thrust = 137 + 88 = 225
X-coordinate = Old X-coordinate + speed = 4250 + 225 = 4475
X speed at the end of turn = “Old” X speed x 0.85 = 225 x 0.85 = 191
4475 and 191 are shown in turn 3 in the replay.

Hope this explanation helps you understand how the game engine works in this game.

If you still have questions on distance and angle as mentioned in your original post, please kindly explain your calculation using this replay too, and I will try to help you understand :slight_smile:

btw, code in this forum should be formatted using the </> button in the formatting toolbar :wink:

Hi! :slight_smile:

It’s hard not to start talking about turns when speed is discussed.
But it make things more complicated.
I will return to my original post I hope.
For now this is only about debug output X axis speed in wood 2 league. :slight_smile:

I am also using 15% for friction. That is why I changed thrust from 85 to 88 so it wouldn’t make things more confusing. And I didn’t want to “spoil” it for anyone.
And thrust 88 had the same situation to be discussed for the continuation of the original post.

When debug output calls it speed when it’s not, isn’t that just a mistake?
It’s printed in debug at a point when friction is added to it.
It’s a preparation of speed before the next speed calculation.
So when next speed calculation is to be done, friction is already added and the game just adds thrust to it.

We can’t move 88 at the speed of 74.
74 might be interesting for someone but speed must have been what was intended to print?

Best regards! :slight_smile:

Consider friction a natural consequence of movements… Friction builds up while moving, so it happens during the current turn, not the next turn. And no matter you like it or not, this is the logic used by the game engine :person_shrugging:

Anyway, let’s not discuss whether it is right or wrong for the game engine to be coded that way. Let’s focus on playing the game based on the given rules.

How do I get the coordinates for the next checkpoint in gold league? I don’t see a variable for that.

You have to reset the code to get a new template for getting the inputs for this league.

That is what I did.

And if you have done so, you will have the coordinates of all the checkpoints at the beginning. You have to store them for later use, because in this league, you are given the next checkpoint ID instead of the next checkpoint coordinates.

Ok, Thank you.

EZ WIN IF YOU SET THRUST TO 150! Its overpowered.

I am 1st in my ranking in Wood 3 league, why i am not promoting to wood 2???

There is a bug in promotion. You may try submitting your code again, and if that still fails to promote you, please contact Thibaud of CodinGame to fix the issue for you.

I couldn’t know how to beat the boss 2 in mad pod racing problem although i have followed the pseudo code as is, here is my code

...
if (nextCheckpointAngle > 90 || nextCheckpointAngle < -90)
                {System.out.println(nextCheckpointX + " " + nextCheckpointY + "0");}
            else 
                {System.out.println(nextCheckpointX + " " + nextCheckpointY + "100");}
            // You have to output the target position
            // followed by the power (0 <= thrust <= 100)
            // i.e.: "x y thrust"
            System.out.println(nextCheckpointX + " " + nextCheckpointY + " 80");
...end of class

can anyone help? Thanks in advance

Where does the third System.out.println belong to?

if (nextCheckpointAngle > 90 || nextCheckpointAngle < -90){
                System.out.println(nextCheckpointX + " " + nextCheckpointY + "0");
            }
            else {
                System.out.println(nextCheckpointX + " " + nextCheckpointY + "100");
            }

I have removed it. now the video doesn’t even start it gives the result right away.

You have missed the spaces before “0” and “100”. You should include add a space there, similar to how you include a space between nextCheckpointX and nextCheckpointY.