private void ReceiveRevealRequest(byte[] body, ulong senderId) { Log.Trace("Receiving Reveal Request", "ReceiveRevealRequest"); RevealRequest request = RevealRequest.FromBytes(body); bool success = Session.Manager.QueueReveal(request.EntityId); RevealResponse response = new RevealResponse() { EntityId = request.EntityId, Success = success }; Log.Trace("Sending response success ? " + response.Success, "ReceiveRevealRequest"); response.SendToPlayer(senderId); }
private void ReceiveRevealResponse(byte[] body) { Log.Trace("Receiving Reveal Response", "ReceiveRevealResponse"); RevealResponse response = RevealResponse.FromBytes(body); String result = response.Success ? "Successfully queued for reveal" : "Failed to reveal"; result += " grid " + response.EntityId; Notification notice = new ChatNotification() { Text = result, Sender = "GP" }; notice.Raise(); }
// Most of the code is very similar to TrainModel and TestModel in the Q_Agent, which is why I would like to combine all 3 into a single method with parametrized behavior public void TestRandom() { int winCount = 0; Dictionary <int, int> stepStatistics = new Dictionary <int, int>(); List <double> clearedRates = new List <double>(); for (int i = 0; i < NumRuns; i++) { bool endState = false; int stepCount = 0; while (!endState) { (int, int)selectedState; RevealResponse response = RevealResponse.Nothing; var revealedTiles = new List <(int, int)>(); // Five attempts to find a new random state that has not already been revealed int attempt = 0; do { selectedState = SelectRandomState(); attempt++; if (attempt > 200) { endState = true; break; } }while (revealedTiles.Contains(selectedState)); if (gameBoard.ValidateCoordinates(selectedState)) { response = gameBoard.RevealTile(selectedState); revealedTiles.Add(selectedState); } gameBoard.PrintBoard(); if (response == RevealResponse.Bomb) { endState = true; } if (gameBoard.CheckWinState()) { endState = true; winCount++; } stepCount++; } clearedRates.Add(gameBoard.GetPercentageCleared()); if (stepStatistics.ContainsKey(stepCount)) { stepStatistics[stepCount]++; } else { stepStatistics.Add(stepCount, 1); } gameBoard = ResetFunc.Invoke(); } Console.WriteLine(string.Format("Win Count: {0} out of {1} ({2}%)", winCount, NumRuns, (winCount * 100 / NumRuns))); Console.WriteLine("Testing is complete. Step stats: "); Console.WriteLine(JsonConvert.SerializeObject(stepStatistics)); Console.WriteLine("Average percentage cleared: " + clearedRates.Average()); Console.ReadLine(); }