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