Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int N = in.nextInt(); // the number of points used to draw the surface of Mars.
- int prevLAND_X = -1;
- int prevLAND_Y = -1;
- int startX = -1;
- int endX = -1;
- int startY = -1;
- int endY = -1;
- for (int i = 0; i < N; i++) {
- int LAND_X = in.nextInt(); // X coordinate of a surface point. (0 to 6999)
- int LAND_Y = in.nextInt(); // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
- if(LAND_Y == prevLAND_Y && (LAND_X - prevLAND_X) >= 1000) { // 1000 gap
- startX = prevLAND_X;
- endX = LAND_X;
- startY = prevLAND_Y;
- endY = LAND_Y;
- }
- prevLAND_X = LAND_X;
- prevLAND_Y = LAND_Y;
- }
- int rot = 0;
- int pow = 3;
- // game loop
- while (true) {
- final int X = in.nextInt(); // x coordinate of mars lander
- final int Y = in.nextInt(); // y coordinate of mars lander
- final int HS = in.nextInt(); // the horizontal speed (in m/s), can be negative.
- final int VS = in.nextInt(); // the vertical speed (in m/s), can be negative.
- final int F = in.nextInt(); // the quantity of remaining fuel in liters.
- final int R = in.nextInt(); // the rotation angle in degrees (-90 to 90).
- final int P = in.nextInt(); // the thrust power (0 to 4).
- // define rotation and power
- if(X >= startX && X <= endX) {
- rot = 0;
- }
- // define power
- if(VS < -30 && P < 4) {
- System.err.println("Power increased.");
- pow = P + 1;
- }
- if(VS > -10 && P > 1) {
- System.err.println("Power decreased.");
- pow = P - 1;
- }
- System.out.println(rot + " " + pow); // R P. R is the desired rotation angle. P is the desired thrust power.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement