diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-09-08 13:17:27 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-09-08 13:17:27 +0200 |
commit | 7960997ed26e2631a5015104eb841864eb33bfef (patch) | |
tree | 8f6a71d4e0519bcf41a1d468a8d064fcf48f2216 /src/strategy | |
parent | 694c3421b23e74da244675cbf7b2c3cfbb2866ab (diff) |
Optimized away unnecessary sum
Diffstat (limited to 'src/strategy')
-rw-r--r-- | src/strategy/monte_carlo_tree.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/strategy/monte_carlo_tree.rs b/src/strategy/monte_carlo_tree.rs index 2d27b62..24b2088 100644 --- a/src/strategy/monte_carlo_tree.rs +++ b/src/strategy/monte_carlo_tree.rs @@ -70,8 +70,7 @@ impl NodeStats { fn node_with_highest_ucb<'a>(&'a mut self) -> &'a mut (Command, NodeStats) { debug_assert!(self.unexplored.is_empty()); debug_assert!(self.explored.len() > 0); - let total_attempts = self.explored.iter().map(|(_, n)| n.attempts).sum::<f32>(); - let sqrt_n = total_attempts.sqrt(); + let sqrt_n = self.attempts.sqrt(); let mut max_position = 0; let mut max_value = self.explored[0].1.ucb(sqrt_n); |