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
5fd1cf09
Unverified
Commit
5fd1cf09
authored
4 years ago
by
Kat Marchán
Browse files
Options
Downloads
Patches
Plain Diff
privatize score values, and require they be betweeen 0.0 and 100.0
parent
e857fcf0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
examples/thirst.rs
+2
-5
2 additions, 5 deletions
examples/thirst.rs
src/scorers.rs
+10
-1
10 additions, 1 deletion
src/scorers.rs
with
13 additions
and
7 deletions
README.md
+
1
−
1
View file @
5fd1cf09
...
@@ -31,7 +31,7 @@ pub fn score_thirst_system(
...
@@ -31,7 +31,7 @@ pub fn score_thirst_system(
)
{
)
{
for
(
Parent
(
actor
),
mut
score
)
in
query
.iter_mut
()
{
for
(
Parent
(
actor
),
mut
score
)
in
query
.iter_mut
()
{
if
let
Ok
(
thirst
)
=
thirsts
.get
(
*
actor
)
{
if
let
Ok
(
thirst
)
=
thirsts
.get
(
*
actor
)
{
score
.
0
=
thirst
.thirst
;
score
.
set
(
thirst
.thirst
)
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
examples/thirst.rs
+
2
−
5
View file @
5fd1cf09
...
@@ -103,11 +103,8 @@ pub fn thirsty_scorer_system(
...
@@ -103,11 +103,8 @@ pub fn thirsty_scorer_system(
// generally "the higher the better", and "first across the finish
// generally "the higher the better", and "first across the finish
// line", but that's all configurable using Pickers!
// line", but that's all configurable using Pickers!
//
//
// In a real-world application, you might want to do a fancier
// The score here must be between 0.0 and 100.0.
// calculation here, possibly to clamp the value to a range, add a
score
.set
(
thirst
.thirst
);
// curve, etc. In our case, we'll just assume thirst goes from
// 0.0..100.0, to keep things simple.
score
.0
=
thirst
.thirst
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/scorers.rs
+
10
−
1
View file @
5fd1cf09
...
@@ -3,7 +3,16 @@ use bevy::prelude::*;
...
@@ -3,7 +3,16 @@ use bevy::prelude::*;
use
crate
::
ScorerEnt
;
use
crate
::
ScorerEnt
;
#[derive(Debug,
Clone,
Default)]
#[derive(Debug,
Clone,
Default)]
pub
struct
Score
(
pub
f32
);
pub
struct
Score
(
pub
(
crate
)
f32
);
impl
Score
{
pub
fn
set
(
&
mut
self
,
value
:
f32
)
{
if
!
(
0.0
..=
100.0
)
.contains
(
&
value
)
{
panic!
(
"Score value must be between 0.0 and 100.0"
);
}
self
.0
=
value
;
}
}
/**
/**
This trait defines new Scorers. In general, you should use the [derive macro](derive.Scorer.html) instead.
This trait defines new Scorers. In general, you should use the [derive macro](derive.Scorer.html) instead.
...
...
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