Skip to content
Snippets Groups Projects
Unverified Commit ab13f9a4 authored by Kat Marchán's avatar Kat Marchán
Browse files
parent e25dac5a
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ First, you define actions and considerations, which are just plain old `Bevy` ...@@ -21,7 +21,7 @@ First, you define actions and considerations, which are just plain old `Bevy`
```rust ```rust
use bevy::prelude::*; use bevy::prelude::*;
use big_brain::*; use big_brain::prelude::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Thirsty; pub struct Thirsty;
...@@ -59,7 +59,7 @@ pub fn thirsty_scorer_system( ...@@ -59,7 +59,7 @@ pub fn thirsty_scorer_system(
```rust ```rust
use bevy::prelude::*; use bevy::prelude::*;
use big_brain::*; use big_brain::prelude::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Drink; pub struct Drink;
......
use bevy::prelude::*; use bevy::prelude::*;
use big_brain::*; use big_brain::prelude::*;
// First, we define a "Thirst" component and associated system. This is NOT // First, we define a "Thirst" component and associated system. This is NOT
// THE AI. It's a plain old system that just makes an entity "thirstier" over // THE AI. It's a plain old system that just makes an entity "thirstier" over
...@@ -156,7 +156,7 @@ pub fn init_entities(mut cmd: Commands) { ...@@ -156,7 +156,7 @@ pub fn init_entities(mut cmd: Commands) {
Thinker::build() Thinker::build()
.picker(FirstToScore { threshold: 80.0 }) .picker(FirstToScore { threshold: 80.0 })
// Note that what we pass in are _builders_, not components! // Note that what we pass in are _builders_, not components!
.when(Thirsty::build(), Drink::build()) .when(Thirsty::build(), Drink::build()),
); );
} }
......
...@@ -2,7 +2,7 @@ use std::sync::Arc; ...@@ -2,7 +2,7 @@ use std::sync::Arc;
use bevy::prelude::*; use bevy::prelude::*;
use crate::{ActionEnt, Actor}; use crate::thinker::{ActionEnt, Actor};
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
pub enum ActionState { pub enum ActionState {
......
pub use bevy; pub mod evaluators;
pub mod pickers;
pub use actions::*; pub mod actions;
pub use choices::*; pub mod choices;
pub use scorers::*; pub mod scorers;
pub use thinker::*; pub mod thinker;
pub use pickers::*;
pub mod evaluators; pub mod prelude {
mod pickers; use super::*;
mod actions; pub use super::BigBrainPlugin;
mod choices; pub use actions::{ActionBuilder, ActionState};
mod scorers; pub use pickers::{FirstToScore, Picker};
mod thinker; pub use scorers::{AllOrNothing, FixedScore, Score, ScorerBuilder, SumOfScorers};
pub use thinker::{Actor, Thinker};
}
use bevy::prelude::*; use bevy::prelude::*;
...@@ -20,12 +22,12 @@ pub struct BigBrainPlugin; ...@@ -20,12 +22,12 @@ pub struct BigBrainPlugin;
impl Plugin for BigBrainPlugin { impl Plugin for BigBrainPlugin {
fn build(&self, app: &mut AppBuilder) { fn build(&self, app: &mut AppBuilder) {
app.add_system(thinker_system.system()); app.add_system(thinker::thinker_system.system());
app.add_system(thinker_component_attach_system.system()); app.add_system(thinker::thinker_component_attach_system.system());
app.add_system(thinker_component_detach_system.system()); app.add_system(thinker::thinker_component_detach_system.system());
app.add_system(steps_system.system()); app.add_system(actions::steps_system.system());
app.add_system(fixed_score_system.system()); app.add_system(scorers::fixed_score_system.system());
app.add_system(all_or_nothing_system.system()); app.add_system(scorers::all_or_nothing_system.system());
app.add_system(sum_of_scorers_system.system()); app.add_system(scorers::sum_of_scorers_system.system());
} }
} }
...@@ -2,7 +2,7 @@ use std::sync::Arc; ...@@ -2,7 +2,7 @@ use std::sync::Arc;
use bevy::prelude::*; use bevy::prelude::*;
use crate::{Actor, ScorerEnt}; use crate::thinker::{Actor, ScorerEnt};
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub struct Score(pub(crate) f32); pub struct Score(pub(crate) f32);
...@@ -116,7 +116,7 @@ impl ScorerBuilder for AllOrNothingBuilder { ...@@ -116,7 +116,7 @@ impl ScorerBuilder for AllOrNothingBuilder {
cmd.entity(scorer) cmd.entity(scorer)
.insert(Score::default()) .insert(Score::default())
.push_children(&scorers[..]) .push_children(&scorers[..])
.insert(super::AllOrNothing { .insert(AllOrNothing {
threshold: self.threshold, threshold: self.threshold,
scorers: scorers.into_iter().map(ScorerEnt).collect(), scorers: scorers.into_iter().map(ScorerEnt).collect(),
}); });
......
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