# Coders Strike Back - Puzzle Discussion

I do 3, 6 or 9 moves per pod, -18/0/18 with 0/200/SHIELD. Shield moves are only added if the 0 speed moves involve collisions and thrust moves aren’t included if the shield timeout is active.

For a single pair that means you need (assuming avg of 6 choices per turn) 36/1296/46656/1679616 simulated turns for depth 1/2/3/4 (each involves a move for both players as it is simultaneous) so depth 3 is doable without any pruning. The usual minimax improvements (Alphabeta, move ordering) then reduce the required simulation count and I pretty much always get depth 4 for both pods, often getting 5 for one pair and occasionally 5 for both.

4 Likes

i cant get past the first thing

Is there any tutorial similar to this problem? I don’t understand anything. Thanks.

I need help @everyone
This is my code

``````if (nextCheckpointAngle > 90 || nextCheckpointAngle < -90)
{
speed = 0;
}
else
{
speed = 100;
}
cout << nextCheckpointX << " " << nextCheckpointY << speed << endl;
``````

but it gives me this error
invalid input. Expected ‘x y power’ but found ‘10472 6999100’

‘10472 6999100’

x = 10472
y = 6999100
power is undefined

As it said invalid input. Expected ‘x y power’

1 Like

I dont understand how/what this is and works:

``````if (u instanceof Checkpoint) {
// Collision with a checkpoint
this.bounceWithCheckpoint((Checkpoint) u);
}
``````

wrote in JavaScript:

``````if(nextCheckpointAngle>90||nextCheckpointAngle<-90){
var thrust='0';

}else{
var  thrust='BOOST';
}
print(nextCheckpointX ,nextCheckpointY ,thrust);
}
``````

how can i improve my code to level up

You wouldn’t want to include boost within that loop as you should be taking in the distance to the next checkpoint as well as angle when considering boosting, you may want to consider something like

if (hasBoost && nextCheckpointDist > 3000 && nextCheckpointAngle == 0) {
thrust = “BOOST”;
hasBoost = false;
}

In terms of actually racing, you want to be able to adjust the destination of your pod based on your speed, allowing it to target a closer section of the actual point radius based on speed(the radius of the point is 600)
(nextCheckpointX-VelocityX) for example

1 Like

i need help because i don’t get it so please someone help me

if nextCheckpointAngle > 90 or nextCheckpointAngle < -90 then
thrust = 0
else
thrust = 100
end if
print x y thrust

GalaxyOwl4

i need help @everyone

you forgot to add " " between nextCheckpointY and speed.
The line should look like this:

``````cout << nextCheckpointX << " " << nextCheckpointY << " " << speed << endl;
``````

since it’s not x yspeed it’s x y speed.

How i am supposed to do anything when i new and i want to LEARN one language, not to show my skills?! And then i see sigh “Can you fix the code?” NO, i can’t , what is this "Educational site " when after one hour i don’t want to touch codes again in my life? Huh?

Just out of curiosity, is there some way to know what to current velocity of my pod is.
I’m in the Wood 1 League btw, in case that matters.

yes, you can estimate it from current and previous position

Hi, I am new to codingame but I cannot get passed the tutorial of this. It keeps saying error because I don’t have the right coordinates. I am using python. The following is my code.
import sys
import math

``````# This code automatically collects game data in an infinite loop.
# It uses the standard input to place data into the game variables such as x and y.
# YOU DO NOT NEED TO MODIFY THE INITIALIZATION OF THE GAME VARIABLES.

# game loop
while True:
# x: x position of your pod
# y: y position of your pod
# next_checkpoint_x: x position of the next check point
# next_checkpoint_y: y position of the next check point
x, y, next_checkpoint_x, next_checkpoint_y = [int(i) for i in input().split()]

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

# Edit this line to output the target position
# and thrust (0 <= thrust <= 100)
# i.e.: "x y thrust"
print(str(next_checkpoint_y) + " " + str(next_checkpoint_y) + " 50")``````
1 Like

How do i get boost while using Python? I have tried a lot of ways but it never works. Including the solutions given from above.
This is my code for when printing:

``````import sys
import math

while True:
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()]

if next_checkpoint_angle>90 or next_checkpoint_angle<-90 or
next_checkpoint_dist<1500:
thrust = 0
else:
thrust = 100

if next_checkpoint_dist > 5000:
print(str(next_checkpoint_x-20) + " " + str(next_checkpoint_y-20) + " " + "BOOST"))
else:
print(str(next_checkpoint_x-20) + " " + str(next_checkpoint_y-20) + " " + str(thrust))``````

To extend on what inorry said, you can work it out calulating
Curent X - Last turn X = curent velocity,
Curent X + curent velocity = next X

if next_checkpoint_dist > 5000:
print(str(next_checkpoint_x-20) + " " + str(next_checkpoint_y-20) + " " + “BOOST”))
else:
print(str(next_checkpoint_x-20) + " " + str(next_checkpoint_y-20) + " " + str(thrust))

The Statement for boost looks fine, since to use Boost, it’s just the string display of BOOST
have you tried a smaller next checkpoint distance?, so that you can test to see if it works in the IDE

I was able to figure it out. I made a different condition so that if it was greater than a certain dist, it would set the var thrust to the string BOOST.

``````boostplayed = 0
while True

if boostplayed == 0 and next_checkpoint_dist >= 6000 and next_checkpoint_angle<10 and next_checkpoint_angle>-10:
boostplayed = 1
thrust = "BOOST"

print(str(next_checkpoint_x-20) + " " + str(next_checkpoint_y-20) + " " + str(thrust))``````

I’m just trying to understand how to progress from Wood 1 to whatever comes after (Wood 2???).
I managed to BOOST, like it says to in the description but the game never goes to the next part. Am I to assume then that I need to go above and beyond what is asked for in the puzzle and add a clause for there to be a certain distance from a checkpoint before the BOOST is used? Or is it bugged and its not progressing? I have to reach a certain rank when submitting my code and it does like 150 races?

Javascript

`````` if(nextCheckpointAngle > 90 || nextCheckpointAngle < -90){
thrust = 0;
}else{
thrust = "BOOST";
}
print(nextCheckpointX + ' ' + nextCheckpointY + ' ' + "BOOST");
``````

}

Given you code, you print BOOST every turn.
Okay you’re in javascript, but your thrust is a int and then it’s a string. Make sure you understand what thrust is and what you should output.

You will be promoted to Bronze if your bot gets a better score than the boss after your submit.
You already passed wood2 if you’re in wood1