Skip to content
Snippets Groups Projects
Unverified Commit 07b60ed8 authored by Kat Marchán's avatar Kat Marchán
Browse files

docs: updated docs and examples

parent 0c8763a2
No related branches found
No related tags found
No related merge requests found
......@@ -35,9 +35,9 @@ define the actual behavior.
#### Scorers
`Scorer`s are entities that look at the world and evaluate into `Score` values. You can think of them as the "eyes" of the AI system. They're a highly-parallel way of being able to look at the `World` and use it to make some decisions later.
`Scorer`s are entities that look at the world and evaluate into [`Score`](scorers::Score) values. You can think of them as the "eyes" of the AI system. They're a highly-parallel way of being able to look at the `World` and use it to make some decisions later.
They are created by types that implement `ScorerBuilder`.
They are created by types that implement [`ScorerBuilder`](scorers::ScorerBuilder).
```rust
use bevy::prelude::*;
......@@ -75,7 +75,7 @@ pub fn thirsty_scorer_system(
#### Actions
`Action`s are the actual things your entities will _do_. They are connected to `ActionState`s, and are created by types implementing `ActionBuilder`.
`Action`s are the actual things your entities will _do_. They are connected to [`ActionState`](actions::ActionState)s, and are created by types implementing [`ActionBuilder`](actions::ActionBuilder).
```rust
use bevy::prelude::*;
......@@ -122,13 +122,13 @@ fn drink_action_system(
#### Thinkers
Finally, you can use it when define the `Thinker`, which you can attach as a
Finally, you can use it when define the [`Thinker`](thinker::Thinker), which you can attach as a
regular Component:
```rust
cmd.spawn().insert(Thirst::new(70.0, 2.0)).insert(
Thinker::build()
.picker(FirstToScore { threshold: 80.0 })
.picker(FirstToScore { threshold: 0.8 })
.when(Thirsty::build(), Drink::build()),
);
```
......
......@@ -20,10 +20,11 @@ impl Thirst {
pub fn thirst_system(time: Res<Time>, mut thirsts: Query<&mut Thirst>) {
for mut thirst in thirsts.iter_mut() {
thirst.thirst += thirst.per_second * (time.delta().as_micros() as f32 / 1000000.0);
thirst.thirst += thirst.per_second * (time.delta().as_micros() as f32 / 1_000_000.0);
if thirst.thirst >= 100.0 {
thirst.thirst = 100.0;
}
println!("Thirst: {}", thirst.thirst);
}
}
......@@ -120,16 +121,12 @@ fn idle_system(mut query: Query<&mut ActionState, With<Idle>>) {
for mut state in query.iter_mut() {
match *state {
ActionState::Requested => {
println!("Idling...");
*state = ActionState::Executing;
}
ActionState::Cancelled => {
println!("Idling cancelled");
*state = ActionState::Success;
}
ActionState::Executing => {
println!("Idled");
}
ActionState::Executing => {}
_ => {}
}
}
......@@ -174,9 +171,8 @@ pub fn thirsty_scorer_system(
// generally "the higher the better", and "first across the finish
// line", but that's all configurable using Pickers!
//
// The score here must be between 0.0 and 100.0.
score.set(thirst.thirst);
println!("Thirst: {}", thirst.thirst);
// The score here must be between 0.0 and 1.0.
score.set(thirst.thirst / 100.);
}
}
}
......@@ -190,7 +186,7 @@ pub fn init_entities(mut cmd: Commands) {
// Thinker::build().component() will return a regular component you
// can attach normally!
Thinker::build()
.picker(FirstToScore { threshold: 80.0 })
.picker(FirstToScore { threshold: 0.8 })
// Note that what we pass in are _builders_, not components!
.when(Thirsty::build(), Drink::build())
.otherwise(Idle::build()),
......
/*!
Utilities for turning values of 0.0..=100.0 into different curves.
Utilities for turning values within a certain range into different curves.
*/
/**
......
......@@ -127,7 +127,7 @@ regular Component:
```no_run
cmd.spawn().insert(Thirst::new(70.0, 2.0)).insert(
Thinker::build()
.picker(FirstToScore { threshold: 80.0 })
.picker(FirstToScore { threshold: 0.8 })
.when(Thirsty::build(), Drink::build()),
);
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment