Skip to content

Commit

Permalink
Merge pull request #9 from mrchantey/dev
Browse files Browse the repository at this point in the history
Patch
  • Loading branch information
mrchantey authored Jul 14, 2024
2 parents 011d0c9 + 425d376 commit be5a425
Show file tree
Hide file tree
Showing 80 changed files with 209 additions and 1,586 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
assets
/target/
docs/book
crates/beet_web/assets/scenes
out.txt
rustc-ice*
43 changes: 8 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 10 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ beet_ml = { workspace = true, optional = true }
beet_net = { workspace = true, optional = true }

[dev-dependencies]
beet_examples.workspace = true # TODO cyclic dependency
beet_examples.workspace = true
bevy = { workspace = true, default-features = true }
log.workspace = true
pretty_env_logger.workspace = true
Expand All @@ -59,7 +59,7 @@ tokio.workspace = true
### WORKSPACE ################################################################################################z###########################

[workspace.package]
version = "0.0.3-rc.2"
version = "0.0.3-rc.3"
edition = "2021"
description = "A very flexible AI behavior library for games and robotics."
documentation = "https://beetmash.com/docs/beet"
Expand Down Expand Up @@ -89,21 +89,20 @@ members = [
"crates/beet_ml",
"crates/beet_net",
"crates/beet_server",
"crates/beet_web",
# "crates/cli",
]
exclude = ["crates/beet_esp"]

[workspace.dependencies]
## internal
beet = { path = "./", version = "0.0.3-rc.2" }
beet_core = { path = "crates/beet_core", version = "0.0.3-rc.2", default-features = false }
beet_ecs = { path = "crates/beet_ecs", version = "0.0.3-rc.2" }
beet_ecs_macros = { path = "crates/beet_ecs/macros", version = "0.0.3-rc.2" }
beet_ml = { path = "crates/beet_ml", version = "0.0.3-rc.2" }
beet_net = { path = "crates/beet_net", version = "0.0.3-rc.2" }
beet_server = { path = "crates/beet_server", version = "0.0.3-rc.2" }
beet_examples = { path = "crates/beet_examples", version = "0.0.3-rc.2" }
beet = { path = "./", version = "0.0.3-rc.3" }
beet_core = { path = "crates/beet_core", version = "0.0.3-rc.3", default-features = false }
beet_ecs = { path = "crates/beet_ecs", version = "0.0.3-rc.3" }
beet_ecs_macros = { path = "crates/beet_ecs/macros", version = "0.0.3-rc.3" }
beet_ml = { path = "crates/beet_ml", version = "0.0.3-rc.3" }
beet_net = { path = "crates/beet_net", version = "0.0.3-rc.3" }
beet_server = { path = "crates/beet_server", version = "0.0.3-rc.3" }
beet_examples = { path = "crates/beet_examples", version = "0.0.3-rc.3" }

## local
# forky_core = { path = "../forky/crates/forky/forky_core" }
Expand Down
4 changes: 0 additions & 4 deletions contributing.md

This file was deleted.

16 changes: 0 additions & 16 deletions cors.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use bevy::prelude::*;

/// Plugins used for most beet apps.
#[derive(Default)]
pub struct DefaultBeetPlugins;
pub struct BeetPlugins;

impl PluginGroup for DefaultBeetPlugins {
impl PluginGroup for BeetPlugins {
fn build(self) -> PluginGroupBuilder {
#[allow(unused_mut)]
let mut builder = PluginGroupBuilder::start::<Self>()
Expand Down
4 changes: 2 additions & 2 deletions crates/beet_core/src/app/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod beet_plugin;
pub mod beet_plugins;
#[allow(unused_imports)]
pub use self::beet_plugin::*;
pub use self::beet_plugins::*;
1 change: 0 additions & 1 deletion crates/beet_core/src/movement/movement_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ impl Plugin for MovementPlugin {
app.add_plugins(ActionPlugin::<(
Hover,
Translate,
SetAgentOnRun<Velocity>,
)>::default()).add_systems(
Update,
(
Expand Down
39 changes: 22 additions & 17 deletions crates/beet_core/src/robotics/depth_sensor_scorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use bevy::prelude::*;
#[derive(Debug, Clone, PartialEq, Component, Action, Reflect)]
#[reflect(Default, Component, ActionMeta)]
#[category(ActionCategory::Behavior)]
#[systems(depth_sensor_scorer.in_set(TickSet))]
#[observers(depth_sensor_scorer)]
pub struct DepthSensorScorer {
// #[inspector(step = 0.1)]
pub threshold_dist: f32,
pub far_score: Score,
pub close_score: Score,
pub far_score: ScoreValue,
pub close_score: ScoreValue,
}

impl Default for DepthSensorScorer {
fn default() -> Self {
Self {
threshold_dist: 0.5,
far_score: Score::Fail,
close_score: Score::Pass,
far_score: score::FAIL,
close_score: score::PASS,
}
}
}
Expand All @@ -34,19 +34,24 @@ impl DepthSensorScorer {
}

pub fn depth_sensor_scorer(
trigger: Trigger<RequestScore>,
mut commands: Commands,
sensors: Query<&DepthValue, Changed<DepthValue>>,
mut scorers: Query<(&TargetAgent, &DepthSensorScorer, &mut Score)>,
query: Query<(&TargetAgent, &DepthSensorScorer, &Parent)>,
) {
for (target, scorer, mut score) in scorers.iter_mut() {
if let Ok(depth) = sensors.get(**target) {
let next_score = if let Some(depth) = **depth
&& depth < scorer.threshold_dist
{
scorer.close_score
} else {
scorer.far_score
};
score.set_if_neq(next_score);
}
let (target, scorer, parent) = query
.get(trigger.entity())
.expect(expect_action::ACTION_QUERY_MISSING);
if let Ok(depth) = sensors.get(**target) {
let next_score = if let Some(depth) = **depth
&& depth < scorer.threshold_dist
{
scorer.close_score
} else {
scorer.far_score
};
commands
.entity(parent.get())
.trigger(OnChildScore::new(trigger.entity(), next_score));
}
}
7 changes: 3 additions & 4 deletions crates/beet_core/src/robotics/robotics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ pub struct RoboticsPlugin;
impl Plugin for RoboticsPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(ActionPlugin::<(
SetAgentOnRun<DualMotorValue>,
InsertOnTrigger<OnRun, DualMotorValue>,
DepthSensorScorer,
)>::default())
.register_type::<DepthValue>()
.register_type::<DualMotorValue>();
.register_type::<DepthValue>()
.register_type::<DualMotorValue>();

let world = app.world_mut();
world.init_bundle::<DepthValue>();
world.init_bundle::<DualMotorValue>();

}
}
File renamed without changes.
15 changes: 11 additions & 4 deletions crates/beet_ecs/src/actions/flow/score_provider.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
use crate::prelude::*;
use bevy::prelude::*;

pub type ScoreValue = f32;

pub mod score{
use super::flow::ScoreValue;
pub const FAIL: ScoreValue = 0.0;
pub const PASS: ScoreValue = 1.0;
pub const NEUTRAL: ScoreValue = 0.5;
}


/// A constant score provider.
#[derive(Default, Deref, DerefMut, Component, Action, Reflect)]
#[reflect(Default, Component)]
Expand All @@ -11,9 +18,9 @@ pub type ScoreValue = f32;
pub struct ScoreProvider(pub ScoreValue);

impl ScoreProvider {
pub const FAIL: ScoreProvider = ScoreProvider(0.0);
pub const PASS: ScoreProvider = ScoreProvider(1.0);
pub const NEUTRAL: ScoreProvider = ScoreProvider(0.5);
pub const FAIL: ScoreProvider = ScoreProvider(score::FAIL);
pub const PASS: ScoreProvider = ScoreProvider(score::PASS);
pub const NEUTRAL: ScoreProvider = ScoreProvider(score::NEUTRAL);

pub fn new(score: ScoreValue) -> Self { Self(score) }
}
Expand Down
15 changes: 15 additions & 0 deletions crates/beet_ecs/src/actions/misc/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pub mod empty_action;
#[allow(unused_imports)]
pub use self::empty_action::*;
pub mod log_on_run;
#[allow(unused_imports)]
pub use self::log_on_run::*;
pub mod repeat;
#[allow(unused_imports)]
pub use self::repeat::*;
pub mod run_timer;
#[allow(unused_imports)]
pub use self::run_timer::*;
pub mod trigger_in_duration;
#[allow(unused_imports)]
pub use self::trigger_in_duration::*;
File renamed without changes.
4 changes: 4 additions & 0 deletions crates/beet_ecs/src/actions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pub mod action_types;
#[allow(unused_imports)]
pub use self::action_types::*;
pub mod flow;
pub mod global;
pub mod misc;
pub mod on_trigger;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;
use bevy::prelude::*;
use std::marker::PhantomData;


pub type InsertOnTrigger<Event, Params, TriggerBundle = ()> =
InsertMappedOnTrigger<DefaultMapFunc<Event, Params, TriggerBundle>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ impl<E: Event, T: Bundle, TrigBundle: Bundle> OnTriggerHandler
_trigger: &Trigger<Self::Event, Self::TriggerBundle>,
(entity, comp): (Entity, &OnTrigger<Self>),
) {
// log::info!("RemoveOnTrigger: {:?}", std::any::type_name::<T>());
comp.target.remove::<T>(commands, entity);
}
}
Expand Down
Loading

0 comments on commit be5a425

Please sign in to comment.