Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 30ce5db

Browse files
committed
let's try this
1 parent fe91bb0 commit 30ce5db

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

examples/dorf_hero/src/ai/scorers/enemy_distance.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl ScorerBuilder for EnemyDistanceBuilder {
2020
fn build(&self, cmd: &mut Commands, scorer: Entity, _actor: Entity) {
2121
cmd.entity(scorer).insert(EnemyDistance {
2222
within: self.within,
23-
evaluator: LinearEvaluator::new_ranged(0.0, self.within),
23+
evaluator: LinearEvaluator::new_ranged(self.within, 0.0),
2424
});
2525
}
2626
}
@@ -47,7 +47,7 @@ pub fn enemy_distance(
4747
if let Ok(hero_pos) = hero_q.single() {
4848
let distance = util::euclidean_distance(enemy_pos, hero_pos);
4949
if distance <= enemy_distance.within {
50-
score.set(enemy_distance.evaluator.evaluate((distance - enemy_distance.within).abs()));
50+
score.set(enemy_distance.evaluator.evaluate(distance / enemy_distance.within));
5151
} else {
5252
score.set(0.0);
5353
}
@@ -57,7 +57,7 @@ pub fn enemy_distance(
5757
for enemy_pos in enemy_q.iter() {
5858
let distance = util::euclidean_distance(enemy_pos, hero_pos);
5959
if distance <= enemy_distance.within {
60-
score.set(enemy_distance.evaluator.evaluate((distance - enemy_distance.within).abs()));
60+
score.set(enemy_distance.evaluator.evaluate(distance / enemy_distance.within));
6161
} else {
6262
score.set(0.0);
6363
}

examples/dorf_hero/src/ai/scorers/fear_of_death.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct FearOfDeathBuilder;
2121
impl ScorerBuilder for FearOfDeathBuilder {
2222
fn build(&self, cmd: &mut Commands, scorer: Entity, _actor: Entity) {
2323
cmd.entity(scorer).insert(FearOfDeath {
24-
evaluator: PowerEvaluator::new(2.),
24+
evaluator: PowerEvaluator::new_ranged(2., 1.0, 0.0),
2525
});
2626
}
2727
}
@@ -30,7 +30,7 @@ pub fn fear_of_death(hp_q: Query<&Hp>, mut scorer_q: Query<(&Actor, &mut Score,
3030
for (Actor(actor), mut score, fear) in scorer_q.iter_mut() {
3131
if let Ok(hp) = hp_q.get(*actor) {
3232
let perc = hp.current as f32 / hp.max as f32;
33-
score.set(fear.evaluator.evaluate((perc - 1.).abs()));
33+
score.set(fear.evaluator.evaluate(perc));
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)