Skip to content

Commit

Permalink
update for big-brain 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 27, 2021
1 parent fd82305 commit fe91bb0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/dorf_hero/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ bevy_tilemap = "0.4.0"
rand = "0.8.3"
pathfinding = "2.1.2"
bevy = "0.5.0"
big-brain = { path = "../../", version = "0.3.4" }
big-brain = { path = "../../" }
4 changes: 2 additions & 2 deletions examples/dorf_hero/src/ai/scorers/enemy_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn enemy_distance(
if let Ok(hero_pos) = hero_q.single() {
let distance = util::euclidean_distance(enemy_pos, hero_pos);
if distance <= enemy_distance.within {
score.set(enemy_distance.evaluator.evaluate((distance - enemy_distance.within) * -1.));
score.set(enemy_distance.evaluator.evaluate((distance - enemy_distance.within).abs()));
} else {
score.set(0.0);
}
Expand All @@ -57,7 +57,7 @@ pub fn enemy_distance(
for enemy_pos in enemy_q.iter() {
let distance = util::euclidean_distance(enemy_pos, hero_pos);
if distance <= enemy_distance.within {
score.set(enemy_distance.evaluator.evaluate((distance - enemy_distance.within) * -1.));
score.set(enemy_distance.evaluator.evaluate((distance - enemy_distance.within).abs()));
} else {
score.set(0.0);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/dorf_hero/src/ai/scorers/fear_of_death.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn fear_of_death(hp_q: Query<&Hp>, mut scorer_q: Query<(&Actor, &mut Score,
for (Actor(actor), mut score, fear) in scorer_q.iter_mut() {
if let Ok(hp) = hp_q.get(*actor) {
let perc = hp.current as f32 / hp.max as f32;
score.set(fear.evaluator.evaluate(((perc * 100.) - 100.).abs()));
score.set(fear.evaluator.evaluate((perc - 1.).abs()));
}
}
}

0 comments on commit fe91bb0

Please sign in to comment.