Skip to content
Snippets Groups Projects

all quiet good

Merged KINGNE NGOUMETEU Jehoiakim requested to merge Jehoiakim into master
11 files
+ 76
32
Compare changes
  • Side-by-side
  • Inline

Files

+ 36
23
@@ -13,6 +13,7 @@ const double Animal::AFF_SIZE = 8.;
const double Animal::MAX_SPEED = 10.;
const double Animal::LIMIT_VIEW = 30.;
int Animal::STEPS_TO_CHANGE_BEHAVIOUR = 10;
int Animal::next = 0;
@@ -34,27 +35,26 @@ Animal::Animal() {
// Testtttttttttttttttttttttttttttttttttttttttttttt
// initialize Animal behaviour
int which_behaviour;
which_behaviour = rand() % 4 + 1;
isMultiple = 0;
if ( which_behaviour == 1 ){
if ( next%4 == 0 ){
behaviour = new GregariousBehaviour();
}
if ( which_behaviour == 2 ){
if ( next%4 == 1 ){
behaviour = new FearfulBehaviour();
}
if ( which_behaviour == 3 ){
if ( next%4 == 2 ){
behaviour = new KamikazeBehaviour();
}
if ( next%4 == 3 ){
behaviour = new KamikazeBehaviour();
isMultiple = 1;
}
if ( which_behaviour == 4 ){
behaviour = new FearfulBehaviour();
isMultiple = 1;}
// Testtttttttttttttttttttttttttttttttttttttttttttt
color = new T[ 3 ];
@@ -81,27 +81,25 @@ Animal::Animal( const Animal & a ){
// Testtttttttttttttttttttttttttttttttttttttttttttt
// initialize Animal behaviour
int which_behaviour;
which_behaviour = rand() % 4 + 1;
isMultiple = 0;
if ( which_behaviour == 1 ){
if ( next%4 == 0 ){
behaviour = new GregariousBehaviour();
}
if ( which_behaviour == 2 ){
if ( next%4 == 1 ){
behaviour = new FearfulBehaviour();
}
if ( which_behaviour == 3 ){
if ( next%4 == 2 ){
behaviour = new KamikazeBehaviour();
}
if ( next%4 == 3 ){
behaviour = new KamikazeBehaviour();
isMultiple = 1;
}
if ( which_behaviour == 4 ){
behaviour = new FearfulBehaviour();
isMultiple = 1;}
// Testtttttttttttttttttttttttttttttttttttttttttttt
color = new T[ 3 ];
@@ -245,12 +243,27 @@ void Animal::setOrientationSpeed(double new_orientation,double new_speed){
this->speed = new_speed;
}
void Animal::changeBehaviour(){
if (isMultiple) {
--STEPS_TO_CHANGE_BEHAVIOUR;
if (isMultiple && STEPS_TO_CHANGE_BEHAVIOUR == 0) {
STEPS_TO_CHANGE_BEHAVIOUR = 10;
cout << "Reach Here ? Change Behaviour" << endl;
delete behaviour;
behaviour = new KamikazeBehaviour();}
}
int which_behaviour;
which_behaviour = rand() % 3 + 1;
if ( which_behaviour == 1 ){
behaviour = new GregariousBehaviour();
}
if ( which_behaviour == 2 ){
behaviour = new FearfulBehaviour();
}
if ( which_behaviour == 3 ){
behaviour = new KamikazeBehaviour();
}
}
}
double Animal::getMaxSpeed(){
return MAX_SPEED;
}
Loading