-
Notifications
You must be signed in to change notification settings - Fork 0
/
coders-strike-back.js
41 lines (36 loc) · 1.48 KB
/
coders-strike-back.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* https://www.codingame.com/ide/puzzle/coders-strike-back
* Once per race you may substitute your desired thrust with the keyword BOOST to grant your pod a burst of speed.
**/
// game loop
while (true) {
var inputs = readline().split(' ');
var x = parseInt(inputs[0]);
var y = parseInt(inputs[1]);
var nextCheckpointX = parseInt(inputs[2]); // x position of the next check point
var nextCheckpointY = parseInt(inputs[3]); // y position of the next check point
var nextCheckpointDist = parseInt(inputs[4]); // distance to the next checkpoint
var nextCheckpointAngle = parseInt(inputs[5]); // angle between your pod orientation and the direction of the next checkpoint
var inputs = readline().split(' ');
var opponentX = parseInt(inputs[0]);
var opponentY = parseInt(inputs[1]);
var boostUsed = false;
// Write an action using print()
// To debug: printErr('Debug messages...');
// You have to output the target position
// followed by the power (0 <= thrust <= 100)
// i.e.: "x y thrust"
if(nextCheckpointDist < 600){
thrust = 50;
}else if(nextCheckpointAngle > 90 || nextCheckpointAngle < -90){
thrust = 50;
}else{
thrust = 100;
}
if(boostUsed === false && nextCheckpointDist > 10000 && nextCheckpointAngle === 0){
print(nextCheckpointX + ' ' + nextCheckpointY + ' BOOST');
boostUsed = true;
}else{
print(nextCheckpointX + ' ' + nextCheckpointY + ' '+thrust);
}
}