Skip to content

Commit

Permalink
Initialize all weights to 0 for the statistical strategy. Assert that…
Browse files Browse the repository at this point in the history
… all incoming weights are not negative.
  • Loading branch information
davidstone committed Oct 1, 2024
1 parent 5f0fbcc commit 07ed7a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/tm/strategy/statistical_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ struct SelectionWeights {
auto const other = read_bytes<Species>(stream);
auto const user = read_bytes<Species>(stream);
auto const switch_out_weight = read_bytes<double>(stream);
BOUNDED_ASSERT(switch_out_weight >= 0.0);
auto const switch_in_multiplier = read_bytes<double>(stream);
BOUNDED_ASSERT(switch_in_multiplier >= 0.0);
using MoveCount = bounded::integer<0, bounded::normalize<bounded::number_of<MoveName>>>;
auto const move_count = read_bytes<MoveCount>(stream);
auto moves = MoveData(containers::generate_n(move_count, [&] {
auto const name = read_bytes<MoveName>(stream);
auto const weight = read_bytes<double>(stream);
BOUNDED_ASSERT(weight >= 0.0);
return containers::map_value_type<MoveName, double>(name, weight);
}));
set(
Expand Down Expand Up @@ -124,7 +127,7 @@ struct SelectionWeights {
per_matchup.set(switch_out_weight, switch_in_multiplier, std::move(move_data));
}

UsageFor<Species, PerOther> m_data;
UsageFor<Species, PerOther> m_data{};
};

struct Statistical {
Expand Down

0 comments on commit 07ed7a0

Please sign in to comment.