Tweak hypothetical advantage algorithm
This commit is contained in:
parent
f905dfdbc3
commit
0477d76322
|
@ -361,9 +361,9 @@ pub fn hypothetical_advantage(
|
||||||
let mut paths: Vec<(Vec<PlayerId>, f64)> = vec![(vec![player1], 0.0)];
|
let mut paths: Vec<(Vec<PlayerId>, f64)> = vec![(vec![player1], 0.0)];
|
||||||
let mut visited: HashSet<PlayerId> = HashSet::new();
|
let mut visited: HashSet<PlayerId> = HashSet::new();
|
||||||
|
|
||||||
let mut final_adv: Option<f64> = None;
|
let mut final_path: Option<(f64, usize)> = None;
|
||||||
|
|
||||||
while final_adv.is_none() {
|
while final_path.is_none() {
|
||||||
if paths.is_empty() {
|
if paths.is_empty() {
|
||||||
return Ok(0.0);
|
return Ok(0.0);
|
||||||
}
|
}
|
||||||
|
@ -377,12 +377,12 @@ pub fn hypothetical_advantage(
|
||||||
if visited.contains(&id) {
|
if visited.contains(&id) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
if id == player2 {
|
||||||
|
final_path = Some((old_adv + adv, path.len() - 1));
|
||||||
|
}
|
||||||
visited.insert(id);
|
visited.insert(id);
|
||||||
let mut path_ = path.clone();
|
let mut path_ = path.clone();
|
||||||
path_.extend_one(id);
|
path_.extend_one(id);
|
||||||
if id == player2 {
|
|
||||||
final_adv = Some(old_adv + adv);
|
|
||||||
}
|
|
||||||
Some((path_, old_adv + adv))
|
Some((path_, old_adv + adv))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -394,7 +394,8 @@ pub fn hypothetical_advantage(
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(final_adv.unwrap())
|
let (final_adv, len) = final_path.unwrap();
|
||||||
|
Ok(final_adv * 0.5_f64.powi(len as i32))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initialize_edge(
|
pub fn initialize_edge(
|
||||||
|
@ -432,7 +433,7 @@ mod tests {
|
||||||
Ok(connection)
|
Ok(connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions to generate test data
|
// Functions to generate placeholder data
|
||||||
|
|
||||||
fn metadata() -> DatasetMetadata {
|
fn metadata() -> DatasetMetadata {
|
||||||
DatasetMetadata {
|
DatasetMetadata {
|
||||||
|
|
Loading…
Reference in a new issue