if (nextCheckpointAngle > 90) or (nextCheckpointAngle < -90) ;{
thrust = 0;
} else; {
thrust = 100;
}
whenever you put ; it breaks the code flow. meaning what the compiler sees when it looks at above is just this:
if (nextCheckpointAngle > 90) or (nextCheckpointAngle < -90) ;
else;
remove the ; at the end of the expressions and the “if else” will work.
How can I get the relative angle between pod and checkpoint instead of absolute angle ? (Like in silver league)
I tried some things with acos, convert radiant/degree or even add/substract 180 nothing work…
Is there a formula with the absolute angle, the position (x, y) of the pod and the position (x2, y2) of the next checkpoint ?
Hello all! Currently in Wood I and able to use BOOST in my code, however, it uses it right at the beginning when the race starts. Some races it’s fine because I still win, but others on different map layouts it causes my pod to go at too wide of an angle initially and I lose. Is there a way to delay the BOOST or how should I go about improving my code to combat the problem? Thank you!
Hi guys I’m kinda new here, can I know how do I defeat boss 3 and boss 4? As I solved boss 3 with the code below but I don’t know how to defeat boss 4 maybe in boss 3 I wrote the wrong code (in the BOOST part) or something. Can kindly guide me on this? I spend so much time (2 days) on the boss 4 but still couldn’t solve it. I wrote my code in Kotlin in case you wonder what language is that.
import java.util.*
import java.io.*
import java.math.*
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
fun main(args : Array<String>) {
val input = Scanner(System.`in`)
var thrust = "0"
// var boost = null
// game loop
while (true) {
val x = input.nextInt()
val y = input.nextInt()
val nextCheckpointX = input.nextInt() // x position of the next check point
val nextCheckpointY = input.nextInt() // y position of the next check point
val nextCheckpointDist = input.nextInt() // distance to the next checkpoint
val nextCheckpointAngle = input.nextInt() // angle between your pod orientation and the direction of the next checkpoint
val opponentX = input.nextInt()
val opponentY = input.nextInt()
if (nextCheckpointDist > 8000) {
thrust = "BOOST"
} else if (nextCheckpointAngle > 90 || nextCheckpointAngle < -90) {
thrust = "50"
} else if (nextCheckpointAngle < 90 || nextCheckpointAngle > -90) {
thrust = "100"
}
// Write an action using println()
// To debug: System.err.println("Debug messages...");
println("$nextCheckpointX $nextCheckpointY $thrust $nextCheckpointAngle")
// You have to output the target position
// followed by the power (0 <= thrust <= 100)
// i.e.: "x y thrust"
}
}
What if nextCheckpointAngle equals 90 or -90 and nextCheckpointDist is less than or equal to 8000?
In addition please read the discussion above for ideas to improve your bot, e.g. how not to move too far before rotating your pod to a different angle.
You print three space-separated numbers: the first two being the coordinates of the target destination and the third one being the target thrust. This is explained in the Output section in the puzzle statement.
You have to wait until all the battles are finished before your rank is stabilised, then you will get promoted if your score is still above that of the boss. And I see that you are in bronze league already.
How can I get to silver league? I’m in bronze league.
Here’s my code:
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
count = False
# 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, flush=True)
if next_checkpoint_angle > 90 or next_checkpoint_angle < -90: thrust = 0
else: thrust = 100
# You have to output the target position
# followed by the power (0 <= thrust <= 100)
# i.e.: "x y thrust"
#print(next_checkpoint_x,next_checkpoint_y,"BOOST")
#print(next_checkpoint_x,next_checkpoint_y,thrust)
k = 20
if (next_checkpoint_dist > 5000) and (next_checkpoint_angle <= 30) and (count == False):
print(str(next_checkpoint_x-k) + " " + str(next_checkpoint_y-k) + " " + "BOOST")
count = True
else:
print(str(next_checkpoint_x-k) + " " + str(next_checkpoint_y-k) + " " + str(thrust))
Moderator note: Please do not paste complete code in the chat. Snippets are fine. If you are having an issue, just tell us what it is (maybe with an error message or a description of what you’re trying to do or the results that you were expecting) and we can try to help you.