Skip to content

Commit

Permalink
Automatically re-weight scoring to add up to 1 internally.
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Jul 29, 2024
1 parent 05560c9 commit 13cd698
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
23 changes: 0 additions & 23 deletions Craftimizer/Windows/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,6 @@ ref isDirty

using (var panel = ImRaii2.GroupPanel("Score Weights (Advanced)", -1, out _))
{
ImGui.TextWrapped("All values should add up to 1.");
ImGuiHelpers.ScaledDummy(10);

DrawOption(
"Progress",
"Amount of weight to give to the craft's progress.",
Expand Down Expand Up @@ -722,26 +719,6 @@ ref isDirty
v => config = config with { ScoreSteps = v },
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)
Expand Down
16 changes: 11 additions & 5 deletions Solver/MCTSConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ public MCTSConfig(in SolverConfig config)
MaxScoreWeightingConstant = config.MaxScoreWeightingConstant;
ExplorationConstant = config.ExplorationConstant;

ScoreProgress = config.ScoreProgress;
ScoreQuality = config.ScoreQuality;
ScoreDurability = config.ScoreDurability;
ScoreCP = config.ScoreCP;
ScoreSteps = config.ScoreSteps;
var total = config.ScoreProgress +
config.ScoreQuality +
config.ScoreDurability +
config.ScoreCP +
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;
}
Expand Down

0 comments on commit 13cd698

Please sign in to comment.