-
Notifications
You must be signed in to change notification settings - Fork 9
/
marsLanderPart1.js
35 lines (26 loc) · 1.33 KB
/
marsLanderPart1.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
var surfaceN = parseInt(readline()); // the number of points used to draw the surface of Mars.
for (var i = 0; i < surfaceN; i++) {
var inputs = readline().split(' ');
var landX = parseInt(inputs[0]); // X coordinate of a surface point. (0 to 6999)
var landY = parseInt(inputs[1]); // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
}
// game loop
while (true) {
var inputs = readline().split(' ');
var X = parseInt(inputs[0]);
var Y = parseInt(inputs[1]);
var hSpeed = parseInt(inputs[2]); // the horizontal speed (in m/s), can be negative.
var vSpeed = parseInt(inputs[3]); // the vertical speed (in m/s), can be negative.
var fuel = parseInt(inputs[4]); // the quantity of remaining fuel in liters.
var rotate = parseInt(inputs[5]); // the rotation angle in degrees (-90 to 90).
var power = parseInt(inputs[6]); // the thrust power (0 to 4).
if (vSpeed <= -40) {
power = 4;
} else {
power = 0;
}
var decision = rotate + ' ' + power;
// Write an action using print()
// To debug: printErr('Debug messages...');
print(decision); // 2 integers: rotate power. rotate is the desired rotation angle (should be 0 for level 1), power is the desired thrust power (0 to 4).
}