/** * <summary> * Posts the solution for evaluation. Returns a summary of the score and game state. * Tries to submit the solution three times * </summary> */ public static ScoreResponse ScoreSolution(string apiKey, ScoreSolutionRequest solution) { var request = new RestRequest("/solution", Method.POST); request.AddHeader("x-api-key", apiKey); request.AddJsonBody(solution); var tries = 1; while (tries <= 3) { var response = Client.Execute(request); Console.WriteLine($"Scoring Solution..."); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <ScoreResponse>(response.Content)); } PrintResponseError(response); Console.WriteLine($"Attempt {tries} failed, waiting 2 sec and attempting again."); Thread.Sleep(2000); tries++; } Console.WriteLine("Fatal Error: could submit solution"); Environment.Exit(1); return(null); }
public Solution() { request = new ScoreSolutionRequest(); request.Solutions = new List <ImageSolutionRequest>(); }