Improve performance
This commit is contained in:
@@ -269,27 +269,18 @@ impl History {
|
||||
|
||||
agent::clean(self.agents.values_mut(), true);
|
||||
|
||||
let mut unique = Vec::with_capacity(100);
|
||||
let mut this_agent = Vec::with_capacity(1024);
|
||||
|
||||
let this_agent = composition
|
||||
.iter()
|
||||
.flatten()
|
||||
.flatten()
|
||||
.filter(|idx| {
|
||||
if !unique.contains(idx) {
|
||||
unique.push(*idx);
|
||||
|
||||
return true;
|
||||
for agent in composition.iter().flatten().flatten() {
|
||||
if this_agent.contains(agent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
false
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
this_agent.push(*agent);
|
||||
|
||||
for agent in &this_agent {
|
||||
if !self.agents.contains_key(agent) {
|
||||
self.agents.insert(
|
||||
**agent,
|
||||
*agent,
|
||||
Agent {
|
||||
player: priors.remove(agent).unwrap_or_else(|| {
|
||||
Player::new(
|
||||
|
||||
@@ -15,14 +15,17 @@ impl TeamMessage {
|
||||
}
|
||||
*/
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn posterior_win(&self) -> Gaussian {
|
||||
self.prior * self.likelihood_lose * self.likelihood_draw
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn posterior_lose(&self) -> Gaussian {
|
||||
self.prior * self.likelihood_win * self.likelihood_draw
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn likelihood(&self) -> Gaussian {
|
||||
self.likelihood_win * self.likelihood_lose * self.likelihood_draw
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user