Update adjudication logging

This commit is contained in:
Tim Van Baak 2024-08-15 22:20:03 -07:00
parent 889e9d173b
commit 9a64609605
3 changed files with 21 additions and 13 deletions

View File

@ -620,7 +620,10 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
if (!potentialDislodger) if (!potentialDislodger)
{ {
progress |= LoggedUpdate(decision, false, depth, "No invader can move"); string reason = decision.Incoming.Count == 0
? "No unit is attacking"
: "All attacks failed";
progress |= LoggedUpdate(decision, false, depth, reason);
} }
return progress; return progress;
@ -752,7 +755,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
if (givesSupport.Outcome == true) min += 1; if (givesSupport.Outcome == true) min += 1;
if (givesSupport.Outcome != false) max += 1; if (givesSupport.Outcome != false) max += 1;
} }
progress |= LoggedUpdate(decision, min, max, depth, "Updated based on unit's supports"); progress |= LoggedUpdate(decision, min, max, depth, $"Updated based on {decision.Supports.Count} hold supports");
return progress; return progress;
} }
} }
@ -817,7 +820,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
if (givesSupport.Outcome == true) min += 1; if (givesSupport.Outcome == true) min += 1;
if (givesSupport.Outcome != false) max += 1; if (givesSupport.Outcome != false) max += 1;
} }
progress |= LoggedUpdate(decision, min, max, depth, "Updated with supports from other powers"); progress |= LoggedUpdate(decision, min, max, depth, $"Updated with {decision.Supports.Count} (?) move supports from third parties");
return progress; return progress;
} }
} }
@ -839,7 +842,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
} }
// Force min to zero in case of an attempt to disloge a unit of the same power. // Force min to zero in case of an attempt to disloge a unit of the same power.
if (decision.Order.Unit.Power == destPower) min = 0; if (decision.Order.Unit.Power == destPower) min = 0;
progress |= LoggedUpdate(decision, min, max, depth, "Updated with supports"); progress |= LoggedUpdate(decision, min, max, depth, $"Updated with {decision.Supports.Count} (?) move supports");
return progress; return progress;
} }
else else
@ -855,7 +858,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
if (givesSupport.Outcome == true) min += 1; if (givesSupport.Outcome == true) min += 1;
if (givesSupport.Outcome != false) max += 1; if (givesSupport.Outcome != false) max += 1;
} }
progress |= LoggedUpdate(decision, min, max, depth, "Updated with supports from all powers"); progress |= LoggedUpdate(decision, min, max, depth, $"Updated with {decision.Supports.Count} move supports from all powers");
return progress; return progress;
} }
} }
@ -880,7 +883,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
if (givesSupport.Outcome == true) min += 1; if (givesSupport.Outcome == true) min += 1;
if (givesSupport.Outcome != false) max += 1; if (givesSupport.Outcome != false) max += 1;
} }
progress |= LoggedUpdate(decision, min, max, depth, "Updated based on unit's supports"); progress |= LoggedUpdate(decision, min, max, depth, $"Updated based on {decision.Supports.Count} supports");
return progress; return progress;
} }
@ -934,7 +937,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
min = 0; min = 0;
} }
progress |= LoggedUpdate(decision, min, max, depth, "Updated based on unit's supports"); progress |= LoggedUpdate(decision, min, max, depth, $"Updated based on {decision.Supports.Count} supports");
return progress; return progress;
} }
@ -992,7 +995,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
decision, decision,
attack.MinValue > defense.MaxValue && beatsAllCompetingMoves, attack.MinValue > defense.MaxValue && beatsAllCompetingMoves,
depth, depth,
"Updated based on competing moves"); $"Updated based on {decision.Competing.Count} competing moves");
return progress; return progress;
} }
} }

View File

@ -116,7 +116,6 @@ public class Timelines(int next, Dictionary<string, Season?> pasts)
/// </summary> /// </summary>
public Season GetTimelineRoot(Season season) public Season GetTimelineRoot(Season season)
{ {
Console.WriteLine($"GetTimelineRoot({season.Key})");
return Pasts[season.Key] is Season past && season.Timeline == past.Timeline return Pasts[season.Key] is Season past && season.Timeline == past.Timeline
? GetTimelineRoot(past) ? GetTimelineRoot(past)
: season; : season;

View File

@ -94,8 +94,11 @@ public class SerializationTest
Assert.That(setup.World.OrderHistory[s0.Key].DoesMoveOutcomes.Count, Is.GreaterThan(0), "Missing moves"); Assert.That(setup.World.OrderHistory[s0.Key].DoesMoveOutcomes.Count, Is.GreaterThan(0), "Missing moves");
Assert.That(setup.World.OrderHistory[s0.Key].IsDislodgedOutcomes.Count, Is.GreaterThan(0), "Missing dislodges"); Assert.That(setup.World.OrderHistory[s0.Key].IsDislodgedOutcomes.Count, Is.GreaterThan(0), "Missing dislodges");
// Assert.Ignore("Serialization doesn't fully work yet");
// Serialize and deserialize the world // Serialize and deserialize the world
string serialized = JsonSerializer.Serialize(setup.World, Options); string serialized = JsonSerializer.Serialize(setup.World, Options);
Console.WriteLine(serialized);
World reserialized = JsonSerializer.Deserialize<World>(serialized, Options) World reserialized = JsonSerializer.Deserialize<World>(serialized, Options)
?? throw new AssertionException("Failed to reserialize world"); ?? throw new AssertionException("Failed to reserialize world");
@ -103,10 +106,9 @@ public class SerializationTest
Assert.That(reserialized.OrderHistory[s0.Key].Orders.Count, Is.GreaterThan(0), "Missing orders"); Assert.That(reserialized.OrderHistory[s0.Key].Orders.Count, Is.GreaterThan(0), "Missing orders");
Assert.That(reserialized.OrderHistory[s0.Key].DoesMoveOutcomes.Count, Is.GreaterThan(0), "Missing moves"); Assert.That(reserialized.OrderHistory[s0.Key].DoesMoveOutcomes.Count, Is.GreaterThan(0), "Missing moves");
Assert.That(reserialized.OrderHistory[s0.Key].IsDislodgedOutcomes.Count, Is.GreaterThan(0), "Missing dislodges"); Assert.That(reserialized.OrderHistory[s0.Key].IsDislodgedOutcomes.Count, Is.GreaterThan(0), "Missing dislodges");
Assert.That(reserialized.Timelines.Pasts, Is.Not.Empty, "Missing timeline history");
}); });
Assert.Ignore("Serialization doesn't fully work yet");
// Resume the test case // Resume the test case
setup = new(reserialized, MovementPhaseAdjudicator.Instance); setup = new(reserialized, MovementPhaseAdjudicator.Instance);
setup[("a", 1)] setup[("a", 1)]
@ -118,8 +120,12 @@ public class SerializationTest
setup.ValidateOrders(); setup.ValidateOrders();
Assert.That(mun1, Is.Valid); Assert.That(mun1, Is.Valid);
var adjudications = setup.AdjudicateOrders(); var adjudications = setup.AdjudicateOrders();
foreach (var adj in adjudications)
{
Console.WriteLine($"{adj}");
}
Assert.That(mun1, Is.NotCut); Assert.That(mun1, Is.NotCut);
Console.WriteLine(string.Join(", ", adjudications.Select(a => a.ToString())));
DoesMove mun0move = adjudications.OfType<DoesMove>().Single(move => move.Order.Unit.Key == mun0.Order.Unit.Key); DoesMove mun0move = adjudications.OfType<DoesMove>().Single(move => move.Order.Unit.Key == mun0.Order.Unit.Key);
Assert.That(mun0move.Outcome, Is.True); Assert.That(mun0move.Outcome, Is.True);
IsDislodged tyr0dislodge = adjudications.OfType<IsDislodged>().Single(dis => dis.Order.Unit.Key == tyr0.Order.Unit.Key); IsDislodged tyr0dislodge = adjudications.OfType<IsDislodged>().Single(dis => dis.Order.Unit.Key == tyr0.Order.Unit.Key);