Skip to content

Commit

Permalink
Merge branch 'main' into telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
snow-jallen authored Feb 26, 2023
2 parents 3235bf2 + 14b9947 commit f734197
Show file tree
Hide file tree
Showing 22 changed files with 1,583 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ Object: Get your rover to the destination before everyone else!
- Winners are determined by the amount of time elapsed from when the game state becomes 'Playing' to when your rover makes it to the target.
- Tip: Make sure you use the high-resolution information you get back from Perseverance and Ingenuity about their surrounding cells to help improve your planning of how you will get to the target.

## Proposed Changes for the March 2022 Competition

- Change spawning locations
- circle spawn (equidistant from target)
- fair spawn (possibly different distances but equal best-path to target)
- weighted spawn
- Edge wrapping
- Unpassable barriers / cliffs (require pathfinding)
- Weather/storms changes difficulty values (so your previous map becomes invalidated, requiring constant scanning and re-evaluation)
- closing ring, as time passes boot players outside of a certain radius
- Multiple waypoints
- Unbounded battery (you can charge beyond your initial battery level)
- Change scoring: most efficient wins (battery used / time taken), within 60 seconds of first to target
- Return battery level on join

## API Documentation

There is an [API Playground](https://snow-rover.azurewebsites.net/swagger/index.html) where you can see exactly what endpoints exist on the server, what arguments need to be passed in, and what type of data you get back. Feel free to use that to help you get familiar with how to interact with the server. While you *can* play the game using nothing more than the API Playground, or a commandline with `curl` in bash or `Invoke-RestMethod` in PowerShell (or even from a few different browser tabs), you will have the best success by writing a program to automate your server interactions.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/5256_8_Terra_Sirenum-full2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
500 changes: 500 additions & 0 deletions resources/PerseveranceDriveToCitadelle.csv

Large diffs are not rendered by default.

Binary file added resources/PerseveranceDriveToCitadelle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/PerseveranceDriveToCitadelle.json

Large diffs are not rendered by default.

Binary file added resources/PerseveranceDriveToCitadelle_500.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
500 changes: 500 additions & 0 deletions resources/Terra_Sirenum_500.csv

Large diffs are not rendered by default.

Binary file added resources/Terra_Sirenum_500.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/Terra_Sirenum_500.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Mars.MissionControl/Difficulty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public record Difficulty
{
public Difficulty(int value)
{
if (value < 0 || value > 2048)
if (value < 0 || value > 20480)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
Expand Down
7 changes: 6 additions & 1 deletion src/Mars.Web/Components/NewGame.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div class="row mb-2">
<InputRadioGroup Name="mapNumber" @bind-Value=mapNumber>
@foreach (var map in multiGameHoster.ParsedMaps)
@foreach (var map in multiGameHoster.ParsedMaps.Take(MaxMaps))
{
<div class="form-check mx-3">
<InputRadio Value="@map.MapNumber" class="form-check-input" id=@($"map{map.MapNumber}") />
Expand Down Expand Up @@ -51,6 +51,8 @@
[CascadingParameter(Name = "GameManager")]
public GameManager? gameManager { get; set; }

int MaxMaps = 3;

private GameStartOptions startOptions => gameManager!.GameStartOptions;

bool startGameButtonHidden = true;
Expand All @@ -59,6 +61,9 @@
protected override void OnParametersSet()
{
mapNumber = multiGameHoster.ParsedMaps.First().MapNumber;

if (!int.TryParse(config["MaxMaps"], out MaxMaps))
MaxMaps = 3;
}

private string? password;
Expand Down
53 changes: 53 additions & 0 deletions src/Mars.Web/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace Mars.Web.Controllers;

[ApiController]
[Route("[controller]")]
public class AdminController : ControllerBase
{
private readonly IConfiguration config;
private readonly ILogger<AdminController> logger;
private readonly MultiGameHoster gameHoster;

public AdminController(IConfiguration config, ILogger<AdminController> logger, MultiGameHoster gameHoster)
{
this.config = config;
this.logger = logger;
this.gameHoster = gameHoster;
}

[HttpPost("[action]")]
[ProducesResponseType(typeof(string), 200)]
[ProducesResponseType(typeof(ProblemDetails), 400)]
public IActionResult StartGame(StartGameRequest request)
{
if (request.Password != config["GAME_PASSWORD"])
return Problem("Invalid password", statusCode: 400, title: "Cannot start game with invalid password.");

if (gameHoster.Games.TryGetValue(request.GameID, out var gameManager))
{
try
{
var gamePlayOptions = new GamePlayOptions
{
RechargePointsPerSecond = request.RechargePointsPerSecond,
};
logger.LogInformation("Starting game play via admin api");
gameManager.Game.PlayGame(gamePlayOptions);
return Ok("Game started OK");
}
catch (Exception ex)
{
return Problem(ex.Message, statusCode: 400, title: "Error starting game");
}
}

return Problem("Invalid GameID", statusCode: 400, title: "Invalid Game ID");
}
}

public class StartGameRequest
{
public int RechargePointsPerSecond { get; set; }
public string? Password { get; set; }
public string GameID { get; set; }
}
3 changes: 2 additions & 1 deletion src/Mars.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
"GAME_PASSWORD": "password",
"CleanupFrequencyMinutes": "60",
"ApiLimitPerSecond": "10",
"SeqServer": "http://localhost:5341"
"SeqServer": "http://localhost:5341",
"MaxMaps": "5"
}
1 change: 1 addition & 0 deletions src/Mars.Web/data/lowres_terrain_04.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Mars.Web/data/lowres_terrain_05.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Mars.Web/data/terrain_04.json

Large diffs are not rendered by default.

Loading

0 comments on commit f734197

Please sign in to comment.