Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
big-brain
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Louis
big-brain
Commits
ab13f9a4
Unverified
Commit
ab13f9a4
authored
4 years ago
by
Kat Marchán
Browse files
Options
Downloads
Patches
Plain Diff
define a prelude
Fixes:
https://github.com/zkat/big-brain/issues/10
parent
e25dac5a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
README.md
+2
-2
2 additions, 2 deletions
README.md
examples/thirst.rs
+2
-2
2 additions, 2 deletions
examples/thirst.rs
src/actions.rs
+1
-1
1 addition, 1 deletion
src/actions.rs
src/lib.rs
+21
-19
21 additions, 19 deletions
src/lib.rs
src/scorers.rs
+2
-2
2 additions, 2 deletions
src/scorers.rs
with
28 additions
and
26 deletions
README.md
+
2
−
2
View file @
ab13f9a4
...
...
@@ -21,7 +21,7 @@ First, you define actions and considerations, which are just plain old `Bevy`
```
rust
use
bevy
::
prelude
::
*
;
use
big_brain
::
*
;
use
big_brain
::
prelude
::
*
;
#[derive(Debug,
Clone)]
pub
struct
Thirsty
;
...
...
@@ -59,7 +59,7 @@ pub fn thirsty_scorer_system(
```
rust
use
bevy
::
prelude
::
*
;
use
big_brain
::
*
;
use
big_brain
::
prelude
::
*
;
#[derive(Debug,
Clone)]
pub
struct
Drink
;
...
...
This diff is collapsed.
Click to expand it.
examples/thirst.rs
+
2
−
2
View file @
ab13f9a4
use
bevy
::
prelude
::
*
;
use
big_brain
::
*
;
use
big_brain
::
prelude
::
*
;
// 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
...
...
@@ -156,7 +156,7 @@ pub fn init_entities(mut cmd: Commands) {
Thinker
::
build
()
.picker
(
FirstToScore
{
threshold
:
80.0
})
// Note that what we pass in are _builders_, not components!
.when
(
Thirsty
::
build
(),
Drink
::
build
())
.when
(
Thirsty
::
build
(),
Drink
::
build
())
,
);
}
...
...
This diff is collapsed.
Click to expand it.
src/actions.rs
+
1
−
1
View file @
ab13f9a4
...
...
@@ -2,7 +2,7 @@ use std::sync::Arc;
use
bevy
::
prelude
::
*
;
use
crate
::{
ActionEnt
,
Actor
};
use
crate
::
thinker
::
{
ActionEnt
,
Actor
};
#[derive(Debug,
Clone,
Eq,
PartialEq)]
pub
enum
ActionState
{
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
21
−
19
View file @
ab13f9a4
pub
use
bevy
;
pub
mod
evaluators
;
pub
mod
pickers
;
pub
use
actions
::
*
;
pub
use
choices
::
*
;
pub
use
scorers
::
*
;
pub
use
thinker
::
*
;
pub
use
pickers
::
*
;
pub
mod
actions
;
pub
mod
choices
;
pub
mod
scorers
;
pub
mod
thinker
;
pub
mod
evaluators
;
mod
pickers
;
pub
mod
prelude
{
use
super
::
*
;
mod
actions
;
mod
choices
;
mod
scorers
;
mod
thinker
;
pub
use
super
::
BigBrainPlugin
;
pub
use
actions
::{
ActionBuilder
,
ActionState
};
pub
use
pickers
::{
FirstToScore
,
Picker
};
pub
use
scorers
::{
AllOrNothing
,
FixedScore
,
Score
,
ScorerBuilder
,
SumOfScorers
};
pub
use
thinker
::{
Actor
,
Thinker
};
}
use
bevy
::
prelude
::
*
;
...
...
@@ -20,12 +22,12 @@ pub struct BigBrainPlugin;
impl
Plugin
for
BigBrainPlugin
{
fn
build
(
&
self
,
app
:
&
mut
AppBuilder
)
{
app
.add_system
(
thinker_system
.system
());
app
.add_system
(
thinker_component_attach_system
.system
());
app
.add_system
(
thinker_component_detach_system
.system
());
app
.add_system
(
steps_system
.system
());
app
.add_system
(
fixed_score_system
.system
());
app
.add_system
(
all_or_nothing_system
.system
());
app
.add_system
(
sum_of_scorers_system
.system
());
app
.add_system
(
thinker
::
thinker
_system
.system
());
app
.add_system
(
thinker
::
thinker
_component_attach_system
.system
());
app
.add_system
(
thinker
::
thinker
_component_detach_system
.system
());
app
.add_system
(
actions
::
steps_system
.system
());
app
.add_system
(
scorers
::
fixed_score_system
.system
());
app
.add_system
(
scorers
::
all_or_nothing_system
.system
());
app
.add_system
(
scorers
::
sum_of_scorers_system
.system
());
}
}
This diff is collapsed.
Click to expand it.
src/scorers.rs
+
2
−
2
View file @
ab13f9a4
...
...
@@ -2,7 +2,7 @@ use std::sync::Arc;
use
bevy
::
prelude
::
*
;
use
crate
::{
Actor
,
ScorerEnt
};
use
crate
::
thinker
::
{
Actor
,
ScorerEnt
};
#[derive(Debug,
Clone,
Default)]
pub
struct
Score
(
pub
(
crate
)
f32
);
...
...
@@ -116,7 +116,7 @@ impl ScorerBuilder for AllOrNothingBuilder {
cmd
.entity
(
scorer
)
.insert
(
Score
::
default
())
.push_children
(
&
scorers
[
..
])
.insert
(
super
::
AllOrNothing
{
.insert
(
AllOrNothing
{
threshold
:
self
.threshold
,
scorers
:
scorers
.into_iter
()
.map
(
ScorerEnt
)
.collect
(),
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment