Automatically re-weight scoring to add up to 1 internally.

This commit is contained in:
Asriel Camora
2024-07-28 19:12:32 -07:00
parent 05560c999d
commit 13cd698743
2 changed files with 11 additions and 28 deletions
-23
View File
@@ -669,9 +669,6 @@ public sealed class Settings : Window, IDisposable
using (var panel = ImRaii2.GroupPanel("Score Weights (Advanced)", -1, out _)) using (var panel = ImRaii2.GroupPanel("Score Weights (Advanced)", -1, out _))
{ {
ImGui.TextWrapped("All values should add up to 1.");
ImGuiHelpers.ScaledDummy(10);
DrawOption( DrawOption(
"Progress", "Progress",
"Amount of weight to give to the craft's progress.", "Amount of weight to give to the craft's progress.",
@@ -722,26 +719,6 @@ public sealed class Settings : Window, IDisposable
v => config = config with { ScoreSteps = v }, v => config = config with { ScoreSteps = v },
ref isDirty ref isDirty
); );
if (ImGui.Button("Normalize Weights", OptionButtonSize))
{
var total = config.ScoreProgress +
config.ScoreQuality +
config.ScoreDurability +
config.ScoreCP +
config.ScoreSteps;
config = config with
{
ScoreProgress = config.ScoreProgress / total,
ScoreQuality = config.ScoreQuality / total,
ScoreDurability = config.ScoreDurability / total,
ScoreCP = config.ScoreCP / total,
ScoreSteps = config.ScoreSteps / total
};
isDirty = true;
}
if (ImGui.IsItemHovered())
ImGuiUtils.Tooltip("Normalize all weights to sum up to 1");
} }
if (isDirty) if (isDirty)
+11 -5
View File
@@ -32,11 +32,17 @@ public readonly record struct MCTSConfig
MaxScoreWeightingConstant = config.MaxScoreWeightingConstant; MaxScoreWeightingConstant = config.MaxScoreWeightingConstant;
ExplorationConstant = config.ExplorationConstant; ExplorationConstant = config.ExplorationConstant;
ScoreProgress = config.ScoreProgress; var total = config.ScoreProgress +
ScoreQuality = config.ScoreQuality; config.ScoreQuality +
ScoreDurability = config.ScoreDurability; config.ScoreDurability +
ScoreCP = config.ScoreCP; config.ScoreCP +
ScoreSteps = config.ScoreSteps; config.ScoreSteps;
ScoreProgress = config.ScoreProgress / total;
ScoreQuality = config.ScoreQuality / total;
ScoreDurability = config.ScoreDurability / total;
ScoreCP = config.ScoreCP / total;
ScoreSteps = config.ScoreSteps / total;
ActionPool = config.ActionPool; ActionPool = config.ActionPool;
} }