Refactor alot of stuff
This commit is contained in:
@@ -86,6 +86,7 @@ namespace KernelPanic.Editor
|
||||
public string routePolicy = "legacy";
|
||||
public bool startersOnly;
|
||||
public bool prefetch = true;
|
||||
public string combatPolicy = "language";
|
||||
public string outputDirectory = "Artifacts/Balance";
|
||||
|
||||
public static Options Parse(string[] args)
|
||||
@@ -109,6 +110,7 @@ namespace KernelPanic.Editor
|
||||
break;
|
||||
case "-balanceWaves": result.maxWaves = int.Parse(Value(args, ref i), CultureInfo.InvariantCulture); break;
|
||||
case "-balancePrefetch": result.prefetch = bool.Parse(Value(args, ref i)); break;
|
||||
case "-balanceCombatPolicy": result.combatPolicy = Value(args, ref i).ToLowerInvariant(); break;
|
||||
case "-balanceStartersOnly": result.startersOnly = bool.Parse(Value(args, ref i)); break;
|
||||
case "-balanceRoutePolicy": result.routePolicy = Value(args, ref i).ToLowerInvariant(); break;
|
||||
case "-balanceRoute":
|
||||
@@ -130,6 +132,7 @@ namespace KernelPanic.Editor
|
||||
if (!new[] { "legacy", "repair", "elite", "deck", "adaptive" }.Contains(result.routePolicy))
|
||||
throw new ArgumentException("balanceRoutePolicy must be legacy, repair, elite, deck, or adaptive.");
|
||||
result.outputDirectory = Path.GetFullPath(result.outputDirectory);
|
||||
if (result.combatPolicy != "greedy" && result.combatPolicy != "language") throw new ArgumentException("balanceCombatPolicy must be greedy or language.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -278,11 +281,11 @@ namespace KernelPanic.Editor
|
||||
[Serializable]
|
||||
public sealed class Report
|
||||
{
|
||||
public int schemaVersion = 5;
|
||||
public int schemaVersion = 6;
|
||||
public string generatedUtc = DateTime.UtcNow.ToString("o");
|
||||
public string unityVersion = Application.unityVersion;
|
||||
public string policy = "Greedy preview value per (cost+1), lowest-uptime target, hand-order ties; 64 plays/round cap. First four authored distro exclusives plus both language starter decks. Paired no-shop and upgrade-shop policies, package levels 0 and 5 by default. Upgrade-shop buys affordable offers in this order: healing at <=50% uptime, draw riders, magnitude, cost reduction, max uptime, RAM, Cycles, cards, then useful healing; offer-order ties; no rerolls/removals. Actual Play Mode combat; death visuals acknowledged on the next editor update. First seed repeats for every scenario.";
|
||||
public string limitations = "A bounded heuristic benchmark, not optimal play or a balance verdict. Conditional/draw/setup effects are undervalued during combat; fixed exclusive choice; upgrade-first shopping is not optimal deckbuilding; different loadouts consume RNG differently. Wave/round caps are censored survivors, not wins. Uptime damage excludes shield and overkill; partial final rounds count. Resource metrics sample explicitly ended Execute turns only: native clears and mid-turn defeats are excluded. Empty hand does not prove lack of draw is the cause of a defeat.";
|
||||
public string policy = "Combat policy selected by options.combatPolicy: greedy preview or language-aware setup/draw/persistent-work scoring; lowest-uptime target, hand-order ties; 64 plays/round cap. First four authored distro exclusives plus both language starter decks. Paired no-shop and upgrade-shop policies, package levels 0 and 5 by default. Upgrade-shop buys affordable offers in this order: healing at <=50% uptime, draw riders, magnitude, cost reduction, max uptime, RAM, Cycles, cards, then useful healing; offer-order ties; no rerolls/removals. Actual Play Mode combat; death visuals acknowledged on the next editor update. First seed repeats for every scenario.";
|
||||
public string limitations = "A bounded heuristic benchmark, not optimal play or a balance verdict. Language-aware scoring estimates setup value but does not search future turns; fixed exclusive choice; upgrade-first shopping is not optimal deckbuilding; different loadouts consume RNG differently. Wave/round caps are censored survivors, not wins. Uptime damage excludes shield and overkill; partial final rounds count. Resource metrics sample explicitly ended Execute turns only: native clears and mid-turn defeats are excluded. Empty hand does not prove lack of draw is the cause of a defeat.";
|
||||
public Options options;
|
||||
public List<Scenario> scenarios;
|
||||
public List<RunResult> runs = new();
|
||||
@@ -398,7 +401,7 @@ namespace KernelPanic.Editor
|
||||
{
|
||||
var text = new StringBuilder("# Seeded combat comparison\n\n");
|
||||
text.AppendLine(report.policy).AppendLine().AppendLine(report.limitations).AppendLine();
|
||||
text.AppendLine($"Encounter/map revision 2, ten-wave campaign, then endless. Route policy: {report.options.routePolicy}; legacy preference: {report.options.route}. Legacy skips events; other policies prefer reachable nodes using RoutePriority, and resolve events by improving the highest preview-value eligible card and removing the lowest preview-value card only above eight cards. Deck-order ties. Adaptive prioritizes repair at <=60% Uptime and ranks elites above Cache at >=80%; otherwise prefers deck improvements. Repair restores up to {RunJourney.RepairUptime} Uptime; elites award Bits and a draw rider on clear. Build rewards take Bits for all policies. Shopping happens before route choice/events, matching the UI. Prefetch: {report.options.prefetch}, only when no further play is possible; total {report.runs.Sum(run => run.prefetches)}. Endless starts only if the cap exceeds the campaign milestone. These results are not directly comparable to benchmarks without the route map.").AppendLine();
|
||||
text.AppendLine($"Encounter revision 4 / map revision 2, ten-wave campaign, then endless. Combat policy: {report.options.combatPolicy}. Route policy: {report.options.routePolicy}; legacy preference: {report.options.route}. Legacy skips events; other policies prefer reachable nodes using RoutePriority, and resolve events by improving the highest preview-value eligible card and removing the lowest preview-value card only above eight cards. Deck-order ties. Adaptive prioritizes repair at <=60% Uptime and ranks elites above Cache at >=80%; otherwise prefers deck improvements. Repair restores up to {RunJourney.RepairUptime} Uptime; elites award Bits and a draw rider on clear. Build rewards take Bits for all policies. Shopping happens before route choice/events, matching the UI. Prefetch: {report.options.prefetch}, only when no further play is possible; total {report.runs.Sum(run => run.prefetches)}. Endless starts only if the cap exceeds the campaign milestone. These results are not directly comparable to benchmarks without the route map.").AppendLine();
|
||||
text.AppendLine($"Seeds: {string.Join(", ", report.options.seeds)}. Limits: {report.options.maxWaves} waves / {report.options.maxRounds} total rounds. Unity {report.unityVersion}.").AppendLine();
|
||||
text.AppendLine($"Package levels: {string.Join(", ", report.options.packageLevels)}. Shop policies: {string.Join(", ", report.options.shoppingPolicies.Select(shop => shop ? "upgrade-shop" : "no-shop"))}.").AppendLine();
|
||||
text.AppendLine("| Loadout | Runs | Uptime damage / round | Mean rounds | Mean waves cleared | Wave cap reached | Round cap alive | Died | Repeat checked |");
|
||||
@@ -524,9 +527,7 @@ namespace KernelPanic.Editor
|
||||
if (card.Definition == null || card.Definition.IsToken || card.IsBroken || card.IsLocked
|
||||
|| _combat.GoPlayBlockReason(card) != null
|
||||
|| _combat.GetDisplayedPlayCost(card) > _combat.PlayerState.Cycles) continue;
|
||||
var preview = CardPreviewService.Build(_combat, card, target);
|
||||
double damage = (preview.MinimumDamage + (double)preview.MaximumDamage) / 2;
|
||||
double score = (damage + preview.Shield * 0.7 + preview.Heal * 1.5 + preview.Repairs * 3 + 1) / (preview.Cost + 1);
|
||||
double score = BalancePolicy.Score(_combat, card, target, _report.options.combatPolicy == "language");
|
||||
if (score <= best) continue;
|
||||
best = score;
|
||||
chosen = card;
|
||||
@@ -685,6 +686,7 @@ namespace KernelPanic.Editor
|
||||
if (++_seedIndex >= _report.options.seeds.Length) { _seedIndex = 0; _scenarioIndex++; }
|
||||
if (_scenarioIndex < _report.scenarios.Count) { Begin(); return; }
|
||||
Directory.CreateDirectory(_report.options.outputDirectory);
|
||||
// Export standalone reports without a baseline-comparison dependency.
|
||||
File.WriteAllText(Path.Combine(_report.options.outputDirectory, "balance-comparison.json"), JsonUtility.ToJson(_report, true), new UTF8Encoding(false));
|
||||
File.WriteAllText(Path.Combine(_report.options.outputDirectory, "balance-comparison.md"), ToMarkdown(_report), new UTF8Encoding(false));
|
||||
Debug.Log($"Balance comparison complete: {_report.runs.Count} measured runs, {_report.scenarios.Count} verified repeats. {_report.options.outputDirectory}");
|
||||
|
||||
Reference in New Issue
Block a user