Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CPP Ecosystem Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
RIVOAL Samuel
CPP Ecosystem Project
Commits
4c7a655e
Commit
4c7a655e
authored
4 years ago
by
fuzzy_bunny
Browse files
Options
Downloads
Patches
Plain Diff
Corrected captors and accessories choice code + enhanced step nb print msg
parent
d4eae304
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Aquarium.cpp
+4
-2
4 additions, 2 deletions
src/Aquarium.cpp
src/Environment.cpp
+1
-1
1 addition, 1 deletion
src/Environment.cpp
src/PetFactory.cpp
+5
-9
5 additions, 9 deletions
src/PetFactory.cpp
with
10 additions
and
12 deletions
src/Aquarium.cpp
+
4
−
2
View file @
4c7a655e
...
...
@@ -22,10 +22,12 @@ Aquarium::Aquarium( int width, int height, int _delay, int startingNbOfAnimals,
string
kamikazeName
=
(
KamikazeBehaviour
::
getBehaviourInstance
())
->
getBehaviourName
();
// TODO : fixer la liste des availableCaptorsAndAccessories
Statistics
*
statistics
=
new
Statistics
({
"b_multiple"
,
gregariousName
,
fearfulName
,
kamikazeName
,
Fin
::
getName
(),
Eyes
::
getName
()});
//Statistics* statistics = new Statistics({"b_multiple", gregariousName, fearfulName, kamikazeName, Fin::getName(), Eyes::getName()});
Statistics
*
statistics
=
new
Statistics
({
"b_multiple"
,
gregariousName
,
fearfulName
,
kamikazeName
,
"a_None"
});
// TODO : fixer la liste des availableCaptorsAndAccessories
AnimalFactory
*
factory
=
new
PetFactory
(
width
,
height
,
animalsDistribution
,
{
Fin
::
getName
(),
Eyes
::
getName
()},
*
statistics
);
//AnimalFactory* factory = new PetFactory(width, height, animalsDistribution, {Fin::getName(), Eyes::getName()}, *statistics);
AnimalFactory
*
factory
=
new
PetFactory
(
width
,
height
,
animalsDistribution
,
{
"a_None"
}
,
*
statistics
);
water
=
new
Environment
(
width
,
height
,
startingNbOfAnimals
,
*
factory
,
*
statistics
);
...
...
This diff is collapsed.
Click to expand it.
src/Environment.cpp
+
1
−
1
View file @
4c7a655e
...
...
@@ -41,7 +41,7 @@ int Environment::getHeight() const {
void
Environment
::
step
()
{
++
nb_steps
;
// increment the number of steps
cout
<<
"["
<<
nb_steps
<<
"]"
<<
endl
;
cout
<<
"[
step #
"
<<
nb_steps
<<
"]"
<<
endl
;
statistics
.
saveData
();
// save statistics of the previous step before doing the new one
cimg_forXY
(
*
this
,
x
,
y
)
...
...
This diff is collapsed.
Click to expand it.
src/PetFactory.cpp
+
5
−
9
View file @
4c7a655e
...
...
@@ -5,7 +5,7 @@
#include
"Eyes.h"
#include
<iterator>
#include
<
random
>
#include
<
stdlib.h
>
using
namespace
std
;
...
...
@@ -22,10 +22,8 @@ string choose_unchosen_element(const unordered_set<string> remaining_elements) {
string
chosen_one
;
// randomly choosing an index in remaining_elements
default_random_engine
random_generator
;
uniform_int_distribution
<
int
>
distribution
(
0
,
remaining_elements
.
size
()
-
1
);
int
index
=
distribution
(
random_generator
);
int
index
=
rand
()
%
remaining_elements
.
size
();
auto
it
=
remaining_elements
.
begin
();
for
(
int
_i
=
0
;
_i
<
index
;
_i
++
){
it
++
;
...
...
@@ -42,9 +40,7 @@ unordered_set<string> choose_elements(const unordered_set<string> available_elem
// randomly choosing a number of elements to choose
// this number is bound by the number of elements in available_elements
default_random_engine
random_generator
;
uniform_int_distribution
<
int
>
distribution
(
0
,
available_elements
.
size
());
int
nb_to_choose
=
distribution
(
random_generator
);
int
nb_to_choose
=
rand
()
%
available_elements
.
size
();
for
(
int
i
=
0
;
i
<
nb_to_choose
;
i
++
){
string
chosen_elem
;
...
...
@@ -76,7 +72,7 @@ Animal* PetFactory::createMember(string behaviour) {
pet
->
setBehaviourAsMultiple
();
}
else
{
if
(
behaviour
!=
"
n
one"
){
if
(
behaviour
!=
"
a_N
one"
){
pet
->
setBehaviour
(
behaviour
);
}
}
...
...
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