Mad Pod Racing - Puzzle Discussion

You use it to print(next_checkpoint_x - velocity_x, next_checkpoint_y - velocity_y, thrust).

But your velocity calculation is wrong. It should go like this:

last_x = 0
last_y = 0
while (True)
    x, y, ... = input().split()
    velocity_x = x - last_x
    velocity_y = y - last_y
    last_x = x
    last_y = y
    ...

Right! Now i understand why we need velocity in the first place. Itā€™s to find the next checkpoint more clearly.
Thank you very much jackek1, Uljahn, 5DN1L. I appreciate support from all of you peers :smile:

2 Likes

I rebuilt GitHub - dreignier/cg-brutaltester: A local arena for codingame multiplayer puzzles (Java) in c++20:

However everything BUT GO binaries work, and the referee for this game is in GO! Would someone here like to take a crack at rebuilding the referee in c++?

The physics is inaccurately explained. The description says that thrust is the acceleration of the pod. In fact, there is clearly some friction implemented. So even with zero thrust and nonzero speed, the pod decelerates.
Moreover, the pod takes time to turn, it can not immediately accelerate in an arbitrary direction. This broke my idea to implement a version of space travel under constant acceleration (max burn the first half, turn around and max burn decelarating)

Iā€™ve seen a my bot orbit the goal and get stuck quite a lot. How do you recognize and get out of an orbit of doom?

There is more description in the section named ā€œExpert Rulesā€. Iā€™m not sure whether all the rules are shown in the lower leagues, though.

On each turn the pods movements are computed this way:

  1. Rotation: the pod rotates to face the target point, with a maximum of 18 degrees (except for the 1rst round).
  2. Acceleration: the podā€™s facing vector is multiplied by the given thrust value. The result is added to the current speed vector.
  3. Movement: The speed vector is added to the position of the pod. If a collision would occur at this point, the pods rebound off each other.
  4. Friction: the current speed vector of each pod is multiplied by 0.85
  5. The speedā€™s values are truncated and the positionā€™s values are rounded to the nearest integer.
6 Likes

Could you share the link to a replay so that we can take a look?

Me? I havenā€™t had it happen for a while. Iā€™m building all kinds of new code smells into my approach so maybe Iā€™ll go back to basics again and see it again.

I donā€™t understand, I did 20.20 and iā€™m not in Bronze ?

You have to beat the boss of Wood 1 to be promoted to Bronze. I think the boss has a score greater than 23. Please check the leaderboard for the exact number.

Common problems and their solutions

Orbiting the checkpoint:
Youā€™re limited to turning 18 degrees per turn. If your current speed will cause you to move more than 18 degrees across the checkpoint in a single turn, you cannot turn fast enough to get to the checkpoint. This can happen at high speed when close to the CP. The solution is to either slow down or get further away. One simple way is to change your max thrust based on your angle to target.

Stopping at the edge of the checkpoint:
When your bot stops right at the edge of the checkpoint and will go no further, itā€™s because your evaluation function is valuing distance from the next CP higher than passing the current checkpoint. i.e. ā€œIf I hit this checkpoint, the distance to the next checkpoint will go from 1 to 3000. Being far from the next checkpoint is bad. Therefore the best thing I can do is make my distance to the next checkpoint as close to zero as I can without passing it.ā€ To fix, add a factor that counts how many checkpoints you have passed and use it to offset that distance change.

How to have the best thrust with genetic algorithm ?

I canā€™t figure out how to change my angle. Iā€™m on python 3 btw.

The required output consists (mainly) of your target coordinates and the desired thrust. So you change your angle indirectly via that.

Im a bit late, but you print the word ā€˜BOOSTā€™ in the section where you specify thrust. Remember you can only use it once, so you might want to check and make sure you havenā€™t used it before you assign ā€˜BOOSTā€™ to thrust

Thatā€™s more than a bit late :sweat_smile:

I am in the first stage and didnā€™t understand the output of this game. I think it needs more instruction. Need to drop.

Iā€™m stuck at the part where collisions are introduced. Iā€™m not sure what Iā€™m supposed to do. I tried doing a Dot Product to intentionally boost the enemy away from the checkpoint, tried my luck with the normal boost code from the previous episode before the collisions were introduced, and etc. Is there something Iā€™m supposed to do with the circular force-field being 400 units radius?

hi!!

this is my code i am doing the language go it looks correct and i tried everything but nothing is working there has to be something Rong but if anyone can help me please do :slight_smile:
// nextcheakpoint x,y or cheakpointx, cheakpointy

    // and thrust (0 <= thrust <= 100)

    // i.e.: "x y thrust"

    fmt.Printf("%d %d 50\n", x,y)

                       

// nextcheakpoint x,y or cheakpointx, cheakpointy
    // and thrust (0 <= thrust <= 100)
    // i.e.: "x y thrust"
    fmt.Printf("%d %d 50\n", x,y)
                        

}

}

}

}

Your code looks incomplete. You are advised to follow through the tutorial first if you have not done so yet.