-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<RootNamespace>Mars_Lander</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
|
||
/** | ||
* Save the Planet. | ||
* Use less Fossil Fuel. | ||
*/ | ||
class Player | ||
{ | ||
public record FlatSurface(Vector2 Left, Vector2 Right, Vector2 Center, float Length) | ||
{ | ||
public override string ToString() | ||
{ | ||
return $"{{ Left = {Left}, Right = {Right}, Center = {Center}, Length = {Length} }}"; | ||
} | ||
} | ||
|
||
private static void Main(string[] args) | ||
{ | ||
string[] inputs; | ||
var N = int.Parse(Console.ReadLine()); // the number of points used to draw the surface of Mars. | ||
|
||
var marsLandPoints = new List<Vector2>(); | ||
for (var i = 0; i < N; i++) | ||
{ | ||
inputs = Console.ReadLine().Split(' '); | ||
var landX = int.Parse(inputs[0]); | ||
var landY = int.Parse(inputs[1]); | ||
marsLandPoints.Add(new Vector2(landX, landY)); | ||
} | ||
|
||
var flatSurface2 = marsLandPoints.Skip(1) | ||
.Select((x, i) => new FlatSurface(marsLandPoints[i], x, (marsLandPoints[i] + x) / 2, x.X - marsLandPoints[i].X)); | ||
var flatSurface = flatSurface2 | ||
.FirstOrDefault(x => x.Left.Y == x.Right.Y); | ||
|
||
|
||
// game loop | ||
while (true) | ||
{ | ||
inputs = Console.ReadLine().Split(' '); | ||
var position = new Vector2(int.Parse(inputs[0]), int.Parse(inputs[1])); | ||
var speed = new Vector2(int.Parse(inputs[2]), int.Parse(inputs[3])); | ||
|
||
var F = int.Parse(inputs[4]); // the quantity of remaining fuel in liters. | ||
var R = int.Parse(inputs[5]); // the rotation angle in degrees (-90 to 90). | ||
var P = int.Parse(inputs[6]); // the thrust power (0 to 4). | ||
|
||
// Write an action using Console.WriteLine() | ||
// To debug: Console.Error.WriteLine("Debug messages..."); | ||
SetPositionAboveLand(flatSurface, position, speed); | ||
} | ||
} | ||
|
||
private static void SetPositionAboveLand(FlatSurface flatSurface, Vector2 position, Vector2 speed) | ||
{ | ||
var directionToSurface = -1; | ||
|
||
|
||
var direction = (flatSurface.Center - position).X; | ||
var rotation = -20 * (direction / 4000) - (speed.X / 50); | ||
Console.Error.WriteLine($"Direction%: {direction / 4000}. speed%{speed.X / 50}"); | ||
|
||
// if (direction < -flatSurface.Length / 2) | ||
// { | ||
// rotation *= 1; | ||
// } | ||
// else if (direction > flatSurface.Length / 2) | ||
// { | ||
// rotation *= -1; | ||
// } | ||
|
||
int trust = 0; | ||
if (position.Y < 2500) | ||
{ | ||
trust = 4; | ||
} | ||
else | ||
{ | ||
trust = 3; | ||
} | ||
|
||
// R P. R is the desired rotation angle. P is the desired thrust power. | ||
Console.WriteLine($"{(int)rotation} {trust}"); | ||
} | ||
} |