-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPrey.cpp
More file actions
1631 lines (1370 loc) · 67.3 KB
/
Prey.cpp
File metadata and controls
1631 lines (1370 loc) · 67.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Prey.cpp
* - The prey objects
*/
#include "Prey.h"
#include <iostream>
#include "Ecosystem.h"
#include "FCMPrey.h"
#include <math.h>
#include <algorithm> //Reproduction based on gender /MRE/
using namespace std; //Reproduction based on gender /MRE/
Prey::Prey() {
}
Prey::~Prey() {
}
// for 1st generation individuals
Prey::Prey(short type, long id, int species, long parent1ID, long parent2ID, int speciesParent1ID, int speciesParent2ID, Position pos, float energy, float energy_max, float speed, short speed_max, short age, short age_max, short vision, short repAge, float distanceEvol, float stateBirth, FCMPrey *model, short genderVal, float defence, float coopDefence, short persuasionVal) : Sim(type, id, species, parent1ID, parent2ID, speciesParent1ID, speciesParent2ID, energy_max, speed_max, age_max, vision, repAge, distanceEvol, stateBirth, nbGenes, genderVal, defence, coopDefence, persuasionVal) //Add Gender /MRE/
{
setPosition(pos);
// calcWeight();
setAge(age);
setSpeed(speed);
this->setGender(genderVal);//Add Gender /MRE/ Female=1, Male=0
setUpdated(0);
setLastAction(0);
setLiving(true);
this->StrengthStrongestCell = 0;
this->StrengthWeakestCell = 1000000;
this->StrengthStrongestIndivClose = 0;
this->model = *model;
this->model.set_prey(this);
setEnergy(energy);
}
// for new born individuals // M.M
Prey::Prey(short type, long id, int species, long parent1ID, long parent2ID, int speciesParent1ID, int speciesParent2ID, Position pos, float speed, short age, float distanceEvol, FCMPrey *model, short genderVal) :Sim(type, id, species, parent1ID, parent2ID, speciesParent1ID, speciesParent2ID, distanceEvol, nbGenes, genderVal) //Add Gender /MRE/
{
setPosition(pos);
//setEnergy(energy); // M.M => because it should be calculated after specifying SOB
setAge(age);
setSpeed(speed);
setUpdated(0);
setLastAction(0);
setLiving(true);
this->StrengthStrongestCell = 0;
this->StrengthWeakestCell = 10000;
this->StrengthStrongestIndivClose = 0;
this->model = *model;
this->model.set_prey(this);
this->setGender(genderVal);//Add Gender /MRE/ Female=1, Male=0
}
FCMPrey * Prey::getFCM() {
return &model;
}
float Prey::get_mutate_amount(Ecosystem * eco){
Random *r = eco->getRandom();
double prob, test;
prob = r->next(32000) / 32000.0;
if (prob <= 0.05)
{
prob = r->next(32000) / 32000.0;
if (prob <= 0.5)
test = 0.3;
else
test = -0.3;
}
else if (prob <= 0.3)
{
prob = r->next(32000) / 32000.0;
if (prob <= 0.5)
test = 0.2;
else
test = -0.2;
}
else
{
prob = r->next(32000) / 32000.0;
if (prob <= 0.5)
test = 0.1;
else
test = -0.1;
}
return (float)test * 2; // M.M based on the changes in mutation probability (divided by 10)
}
void Prey::reprod(Prey * friends, vector<Prey> * newPrey, Ecosystem * eco) {
Random *r = eco->getRandom();
short nSens = FCMPrey::nbSens;
short nConcepts = FCMPrey::nbConcepts;
short nMoteursDep = FCMPrey::nbMoteursDep;
short nMoteursFix = FCMPrey::nbMoteursFix;
short bebe_gender = eco->rand.next(0, 1); //Add Gender /MRE/ Female=1, Male=0
FCMPrey bebe_fcm = FCMPrey(NULL);
float distanceEvol = 0;
Prey *selected_parent;
float partner_select;
// M.M commented because SOB is part of genome
// After creating the child's genome we have sob and we can calculate energy
// ------ Creation of FCM
float pRemove = (float)0.0005;
float prob;
for (int i = 0; i < nSens + nConcepts + nMoteursDep + nMoteursFix; ++i) { //-- Generate the new Proie's concepts and chart
partner_select = float(r->next(10000) / 10000.0);
if (i < nSens){//MRE RandomGoodGene //get sense features from mother or father (the one with same gender)
if (this->getGender() == bebe_gender)//female
{
selected_parent = this;
}
else
{
selected_parent = friends;
}
}
else{
if (partner_select < 0.5)
selected_parent = this;
else
selected_parent = friends;
}
for (int j = 0; j < nConcepts + nMoteursDep + nMoteursFix; ++j) {
float do_mutate = float(r->next(32000) / 32000.0);
if (selected_parent->model.get_chart(i, j) != 0){ //A.G
float mutate_amount = 0.0;
if (this->getAge() > (this->getAgeMax(false) - this->getRepAge())) //A.G
{
if (do_mutate <= pRemove)
{
bebe_fcm.set_chart(i, j, 0);
}
else mutate_amount = (do_mutate <= eco->getProbaMut_HighAge() + pRemove) ? get_mutate_amount(eco) : 0; //A.G
}
else
{
if (do_mutate <= pRemove)
{
bebe_fcm.set_chart(i, j, 0);
}
else mutate_amount = (do_mutate <= eco->getProbaMut() + pRemove) ? get_mutate_amount(eco) : 0;
}
bebe_fcm.set_chart(i, j, selected_parent->model.get_chart(i, j) + (float)mutate_amount);
}
else {
float mutate_amountLow = 0.0;
if (this->getAge() > (this->getAgeMax(false) - this->getRepAge())) //A.G
{
mutate_amountLow = (do_mutate <= eco->getProbaMutLow_HighAge()) ? get_mutate_amount(eco) : 0; //A.G
}
else
{
mutate_amountLow = (do_mutate <= eco->getProbaMutLow()) ? get_mutate_amount(eco) : 0;
}
bebe_fcm.set_chart(i, j, (float)mutate_amountLow);
}
}
}
distanceEvol = bebe_fcm.calculDistanceEvol(eco->fcm_prey); // Evolution Distance of new individual
for (int i = 0; i < nSens + nConcepts + nMoteursDep + nMoteursFix; ++i) {
// bebe_fcm.set_activation(i, model.get_activations()->at(i));
bebe_fcm.set_activation(i, 0); //-- Meisam: concepts should be zero?
}
//-- Create the new Prey
short bebe_type = 0; //-- Prey
long bebe_id = eco->maxPreyID;
int bebe_species = 0;
long bebe_parent1ID = getID();
long bebe_parent2ID = friends->getID();
int bebe_speciesParent1ID = getSpecies();
int bebe_speciesParent2ID = friends->getSpecies();
Position bebe_position = *(getPosition());
float bebe_speed = 0;
short bebe_age = 0;
float bebe_distanceEvol = distanceEvol;
// create new individual
Prey * bebe = new Prey(bebe_type, bebe_id, bebe_species, bebe_parent1ID, bebe_parent2ID, bebe_speciesParent1ID, bebe_speciesParent2ID, bebe_position, bebe_speed, bebe_age, bebe_distanceEvol, &bebe_fcm, bebe_gender);//Add Gender /MRE/
//-- species adjustment: For every new Prey, compare distanceEvol with parent species - add to closest species
float distFromP1 = 0.0;
float distFromP2 = 0.0;
// physical gene crossover and mutation / M.M
if (this->getGender() == 1)//female. first parameter should be mother //MRE RandomGoodGene
bebe->phGenome.crossover(this->phGenome.getGenome(), friends->phGenome.getGenome(), bebe_gender, this->phGenome.persuasion);
else
bebe->phGenome.crossover(this->phGenome.getGenome(), friends->phGenome.getGenome(), bebe_gender, friends->phGenome.persuasion);
bebe->phGenome.mutate(eco->getProbaMut(), eco);
//GENETYPE genome_evolDistance=bebe->phGenome.calcDistance(eco->ini_PreyGenome.getGenome()); // M.M calculate evolution distance
float genome_evolDistance;
if (bebe->getGender() == 1){//MRE RandomGoodGene
genome_evolDistance = bebe->phGenome.calcDistance(&eco->ini_FemalePreyGenome); // M.M calculate evolution distance
}
else{
genome_evolDistance = bebe->phGenome.calcDistance(&eco->ini_MalePreyGenome); // M.M calculate evolution distance
}
bebe->set_DistEvolution(genome_evolDistance + distanceEvol); // M.M update distance evolution
int percent = r->next(-25, 25);
eco->statWorld.incAvgEnergyTransferredMalePrey((friends->getStateBirth() * friends->getEnergyMax()) / 100);
eco->statWorld.incAvgEnergyTransferredFemalePrey((this->getStateBirth() * this->getEnergyMax()) / 100);
bebe->setEnergy(calculationEnergyNewBorn(friends->getStateBirth(), friends->getEnergyMax(), this->getStateBirth(), this->getEnergyMax())); // M.M
// bebe->calcWeight();
float energy = bebe->getEnergy(); // M.M
float geneticDistFromP1, geneticDistFromP2; //M.M
distFromP1 = bebe->getFCM()->calculDistanceEvol(eco, getFCM());
//geneticDistFromP1= bebe->phGenome.calcDistance(this->phGenome.getGenome()); // M.M
geneticDistFromP1 = bebe->phGenome.calcDistance(&this->phGenome); // M.M
distFromP1 += geneticDistFromP1;
distFromP2 = bebe->getFCM()->calculDistanceEvol(eco, friends->getFCM());
//geneticDistFromP2= bebe->phGenome.calcDistance(friends->phGenome.getGenome()); // M.M
geneticDistFromP2 = bebe->phGenome.calcDistance(&friends->phGenome); // M.M
distFromP2 += geneticDistFromP2; // M.M
if (distFromP1 < distFromP2) {
bebe->setSpecies(getSpecies());
bebe->speciesPtr = this->speciesPtr;
}
else {
bebe->setSpecies(friends->getSpecies());
bebe->speciesPtr = friends->speciesPtr;
}
bebe->set_action_offset(-1);
newPrey->push_back(*bebe); //-- Add the bebe to newPrey
eco->maxPreyID++;
eco->incNbPrey();
//-- Adjust the the parent's energy and other properties
incNbReprod();
friends->incNbReprod();
friends->setUpdated(1);
friends->setLastAction(FCMPrey::ReproduceAction); //-- Action of reproduction
friends->model.ConceptIndex = FCMPrey::SearchPartner; //-- shows Concept that should changes its' value after acting
friends->model.ConceptMultiplier = 0; //-- Based on the model.ConceptIndex, the value of this concpet should multipy to model.ConceptMultiplier
friends->cntReprodFailedTries = 0;
friends->reproduceFailed1 = 0; //-- 1: Energy of prey is not enough, 10: partner has not found, 11: both of them
friends->reproduceFailed2 = 0; //-- "energy of partner is not sufficient"
friends->reproduceFailed3 = 0; //-- "Partner has acted befor"
friends->reproduceFailed4 = 0; //-- "Partner has chosen another action"
friends->reproduceFailed5 = 0; //-- "Distance is far"
//friends->reproduceFailed6 = 0; //-- "Same gender" //Since Females are initiating reproduction, it happens when mate is male //MRE
friends->set_DistMating(get_DistMating()); //-- Initial value for Distance Parents
friends->setSpeed(0);
eco->ParentPrey[getID()].energy = getEnergy(); //-- Meisam: Information for Parents
eco->ParentPrey[friends->getID()].energy = friends->getEnergy(); //-- Meisam: Information for Parents
// in first pregnancy mother spend more energy than child earn (5%)
if (getNbReprod() == 1){
this->setEnergy(calculationEnergyNewParent(this->getEnergy(), energy, this->getStateBirth(), friends->getStateBirth()) - FirstPregnancyEneryWaste*getEnergy()); //-- Losing Energy for reproducing
}
else{
this->setEnergy(calculationEnergyNewParent(this->getEnergy(), energy, this->getStateBirth(), friends->getStateBirth())); //-- Losing Energy for reproducing
}
friends->setEnergy(calculationEnergyNewParent(friends->getEnergy(), energy, friends->getStateBirth(), this->getStateBirth()));
float newEnergy = friends->calculationEnergyAction(friends->getEnergy(), friends->model.getNbArc(), friends->getSpeed(), friends->getStrength(), 0, eco); //-- Losing Energy for acting
friends->setEnergy(newEnergy);
//-- clear the memory of Partner
friends->friendsClose.clear();
friends->friendsCloseDistance.clear();
friends->opponentsClose.clear();
friends->opponentsCloseDistance.clear();
friends->foodClose.clear();
friends->foodCloseDistance.clear();
delete bebe; //-- De-allocate
}
/*
* Method updateNew
* @Parameters
* - num, the current prey's position in rabbits data structure
* - *eco, pointer to the ecosystem object
* @Purpose
* - computes a list of the closet food, friends, and predators
* used to determine which action to take
* - prey looks in a spiral direction outward from its current position
* @Note
* - symantics (1, 2, 3, 4) == (North, East, South, West)
* - lookPermut[1..8] = {(1,2,3,4), (2,3,4,1), (3,4,1,2), (4,1,2,3),
* (1,4,3,2), (4,3,2,1), (3,2,1,4), (2,1,4,3)}
*/
void Prey::updateNew(Ecosystem * eco) {
//-- Clear the current list of friends and distance to friends
friendsClose.clear();
friendsCloseDistance.clear();
//-- Clear the current list of predators and distance to predators
opponentsClose.clear();
opponentsCloseDistance.clear();
//-- Clear the current food and distance to food
foodClose.clear();
foodCloseDistance.clear();
// A.G
// clear variables
setStrengthStrongestIndivCloseIndex(-1);
setStrengthStrongestIndivClose(0);
Position pos_temp;
pos_temp.x = -1;
pos_temp.y = -1;
setStrengthStrongestCellPos(pos_temp);
setStrengthStrongestCell(0);
setStrengthWeakestCellPos(pos_temp);
setStrengthWeakestCell(100000);
#ifdef TWO_RESOURCES
foodClose2.clear();
foodCloseDistance2.clear();
#endif
//-- Select a random direction for looking to start looking
int direction = eco->rand.next(1, 8);
//-- First distance to look (0= present cell) but these functins can't calculate "distance = 0"
int distance = 1;
//-- Number of Local Friends, Enemies & Foods
const int nbList = 5;
//-- Counters
int nbFriends = 0;
int nbOpponents = 0;
int nbFoods = 0;
#ifdef TWO_RESOURCES
int nbFoods2 = 0;
#endif
#ifdef TWO_RESOURCES
getListFriends(nbList, &distance, direction, &nbFriends, &nbOpponents, &nbFoods, &nbFoods2, eco);
#else
getListFriends(nbList, &distance, direction, &nbFriends, &nbOpponents, &nbFoods, eco);
#endif
cout << flush;
//-- Action: 0-escape, 1-rsearchFood, 2-socialize, 3-explore, 4-stay, 5-eat, 6-reproduce
short na = model.percept_prey(eco);
set_action_offset(na);
}
/*
* Uses distance and direction to look around itself in the world
* Finds the closest friends and adds them to the vector friendsClose
*/
#ifdef TWO_RESOURCES
void Prey::getListFriends(int nbList, int * distance, int direction, int * nbFriends, int * nbOpponents, int * nbFoods, int * nbFoods2, Ecosystem * eco) {
while ((*distance < getVision()) && (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)) {
switch (direction) {
case 1: {
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
case 2: {
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
case 3: {
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
case 4: {
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
case 5: {
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
case 6: {
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
case 7: {
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
case 8: {
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList || *nbFoods2 < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco);
break;
}
default:
break;
} //-- Endof switch
(*distance)++;
} //-- End of while
}
#else
void Prey::getListFriends(int nbList, int * distance, int direction, int * nbFriends, int * nbOpponents, int * nbFoods, Ecosystem * eco) {
while ((*distance < getVision()) && (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)) {
switch (direction) {
case 1: {
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
case 2: {
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
case 3: {
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
case 4: {
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
case 5: {
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
case 6: {
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
case 7: {
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
case 8: {
partialCompute2(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute1(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute4(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
if (*nbFriends < nbList || *nbOpponents < nbList || *nbFoods < nbList)
partialCompute3(nbList, distance, nbFriends, nbOpponents, nbFoods, eco);
break;
}
default:
break;
} //-- Endof switch
(*distance)++;
} //-- End of while
}
#endif
/*
* Finds the friends in the north direction
*/
#ifdef TWO_RESOURCES
void Prey::partialCompute1(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, int * nbFoods2, Ecosystem * eco) {
#else
void Prey::partialCompute1(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, Ecosystem * eco) {
#endif
Position pTemp;
//-- Look in one row
int i = 0;
for (int x = -(*distance - 1); x <= *distance; x++) {
i++;
if (i == 26)
i = 2;
//-- ChangePosition :
//-- pTemp.x = position->x + x;
//-- pTemp.y = position->y - *distance;
pTemp = Movement(x, -*distance, eco->getWidth(), eco->getHeight());
//-- Look at this location for finding local frieds, opponents and foods
#ifdef TWO_RESOURCES
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco, &pTemp);
#else
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, eco, &pTemp);
#endif
}
}
/*
* Finds the friends in the east direction
*/
#ifdef TWO_RESOURCES
void Prey::partialCompute2(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, int * nbFoods2, Ecosystem * eco) {
#else
void Prey::partialCompute2(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, Ecosystem * eco) {
#endif
Position pTemp;
//-- Look in one column
for (int y = -(*distance - 1); y <= *distance; y++) {
//-- ChangePosition :
//-- pTemp.x = position->x + *distance;
//-- pTemp.y = position->y + y;
pTemp = Movement(*distance, y, eco->getWidth(), eco->getHeight());
//-- Look at this location for finding local frieds, opponents and foods
#ifdef TWO_RESOURCES
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco, &pTemp);
#else
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, eco, &pTemp);
#endif
}
}
/*
* Finds the friends in the south direction
*/
#ifdef TWO_RESOURCES
void Prey::partialCompute3(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, int * nbFoods2, Ecosystem * eco) {
#else
void Prey::partialCompute3(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, Ecosystem * eco) {
#endif
Position pTemp;
//-- Look in one row
for (int x = (*distance - 1); x >= (-*distance); x--) {
//-- ChangePosition :
//-- pTemp.x = position->x + x;
//-- pTemp.y = position->y + *distance;;
pTemp = Movement(x, *distance, eco->getWidth(), eco->getHeight());
//-- Look at this location for finding local frieds, opponents and foods
#ifdef TWO_RESOURCES
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco, &pTemp);
#else
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, eco, &pTemp);
#endif
}
}
/*
* Finds the friends in the west direction
*/
#ifdef TWO_RESOURCES
void Prey::partialCompute4(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, int * nbFoods2, Ecosystem * eco) {
#else
void Prey::partialCompute4(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, Ecosystem * eco) {
#endif
Position pTemp;
//-- Look in one column
for (int y = (*distance - 1); y >= (-*distance); y--) {
//-- ChangePosition :
//-- pTemp.x = position->x - *distance;
//-- pTemp.y = position->y + y;
pTemp = Movement(-*distance, y, eco->getWidth(), eco->getHeight());
//-- Look at this location for finding local frieds, opponents and foods
#ifdef TWO_RESOURCES
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, nbFoods2, eco, &pTemp);
#else
lookat(nbList, distance, nbFriends, nbOpponents, nbFoods, eco, &pTemp);
#endif
}
}
#ifdef TWO_RESOURCES
void Prey::lookat(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, int * nbFoods2, Ecosystem * eco, Position * pTemp) {
#else
void Prey::lookat(int nbList, int * distance, int * nbFriends, int * nbOpponents, int * nbFoods, Ecosystem * eco, Position * pTemp) {
#endif
int FriendType = 0; //-- Prey
int OpponentType = 1; //-- Predator
float FoodAvailability = eco->getLevelGrass(*pTemp);
#ifdef TWO_RESOURCES
float FoodAvailability2 = eco->getLevelGrass2(*pTemp);
#endif
if (*nbFriends < nbList) {
//-- Get list of Friends in the Cell pTemp
vector<int> nearbyFriends = *(eco->getListCreature(*pTemp, FriendType));
//-- Continue until (1) found nbList friends, or (2) ran out of nearby friends -> add to list of friends
while (*nbFriends < nbList && int(nearbyFriends.size()) > 0) {
//-- Choose random friend to add to list
int fID = eco->rand.next(0, int(nearbyFriends.size()) - 1);
//-- Add distance value of friend in to the Global list friendsCloseDistance
friendsCloseDistance.insert(friendsCloseDistance.begin(), *distance);
//-- Add position of friend based on the distance in to Global list friendsClose
friendsClose.insert(friendsClose.begin(), nearbyFriends.at(fID));
//-- Remove the friend from the list of available friends
nearbyFriends.erase(nearbyFriends.begin() + fID);
*nbFriends += 1;
}
}
if (*nbOpponents < nbList) {
//-- Get list of Opponents in the Cell pTemp
vector<int> nearbyOpponents = *(eco->getListCreature(*pTemp, OpponentType));
//-- Continue until (1) found nbList Opponents, or (2) ran out of nearby Opponents -> add to list of Opponents
while (*nbOpponents < nbList && int(nearbyOpponents.size()) > 0) {
int fID = eco->rand.next(0, int(nearbyOpponents.size()) - 1);
//-- Add distance value of Opponent into the Global list OpponentsCloseDistance
opponentsCloseDistance.insert(opponentsCloseDistance.begin(), *distance);
//-- Add position of Opponent into the Global list OpponentsClose
opponentsClose.insert(opponentsClose.begin(), nearbyOpponents.at(fID));
//-- Remove the Opponent from the list of available Opponents
nearbyOpponents.erase(nearbyOpponents.begin() + fID);
*nbOpponents += 1;
}
}
if (*nbFoods < nbList && FoodAvailability >= 1) {
//-- Add distance value of food into the Global list foodCloseDistance
foodCloseDistance.insert(foodCloseDistance.begin(), *distance);
//-- Add position of food into the Global list foodClose
foodClose.insert(foodClose.begin(), *pTemp);
*nbFoods += 1;
}
// ============= A.G //Move2WeakestPreyCell //MRE RandomGoodGene
if (*nbFriends > 0)
{
//-- Get list of Friends in the Cell pTemp
vector<int> nearbyFriends = *(eco->getListCreature(*pTemp, FriendType));
float sum1 = 0;
float sum2 = 0;//added for StrengthStrongestPreyCellDistance(High/Low)
for (int cnt = 0; cnt < (int)nearbyFriends.size(); cnt++)
{
if ((eco->rabbits[nearbyFriends[cnt]].getGender()) == this->getGender()){
sum1 = sum1 + eco->rabbits[nearbyFriends[cnt]].getStrength();
}
else{
sum2 = sum2 + eco->rabbits[nearbyFriends[cnt]].getStrength();
}
if (eco->rabbits[nearbyFriends[cnt]].getStrength() > getStrengthStrongestIndivClose() && eco->rabbits[nearbyFriends[cnt]].getGender() != this->getGender()) //Move2StrongestPrey
{
setStrengthStrongestIndivCloseIndex(nearbyFriends[cnt]);
setStrengthStrongestIndivClose(eco->rabbits[nearbyFriends[cnt]].getStrength());
}
}
if (sum2 > getStrengthStrongestCell())
{
setStrengthStrongestCellPos(*pTemp);//StrengthStrongestPreyCellDistance(High/Low)
setStrengthStrongestCell(sum2);
}
if (sum1 < getStrengthWeakestCell())
{
setStrengthWeakestCellPos(*pTemp); //Move2WeakestPreyCell
setStrengthWeakestCell(sum1);
}
}
// =========
#ifdef TWO_RESOURCES
if (*nbFoods2 < nbList && FoodAvailability2 >= 1) {
//-- Add distance value of food into the Global list foodCloseDistance
foodCloseDistance2.insert(foodCloseDistance2.begin(), *distance);
//-- Add position of food into the Global list foodClose
foodClose2.insert(foodClose2.begin(), *pTemp);
*nbFoods2 += 1;
}
#endif
}
void Prey::act_driver(vector<Prey> * newPrey, Ecosystem * eco, short MatingMode) {
Position newPos;
setUpdated(1);
eco->ParentPrey[getID()].energy = getEnergy(); //-- Meisam: Information for Parents
newPos = act(newPrey, eco, MatingMode);
setPosition(newPos);
if (this->getGender() == 0){
float newEnergy = calculationEnergyAction(getEnergy(), model.getNbArc(), getSpeed(), getStrength(), 0, eco); //-- Losing Energy for acting //RS males don't carry persuasion penalty
setEnergy(newEnergy);
}
else{
float newEnergy = calculationEnergyAction(getEnergy(), model.getNbArc(), getSpeed(), getStrength(), getPersuasion(), eco); //-- Losing Energy for acting //RS females do carry persuasion penalty
setEnergy(newEnergy);
}
//-- clear the memory
friendsClose.clear();
friendsCloseDistance.clear();
opponentsClose.clear();
opponentsCloseDistance.clear();
foodClose.clear();
foodCloseDistance.clear();
// A.G
setStrengthStrongestIndivCloseIndex(-1);
setStrengthStrongestIndivClose(0);
Position pos_temp;
pos_temp.x = -1;
pos_temp.y = -1;
setStrengthStrongestCellPos(pos_temp);
setStrengthStrongestCell(0);
setStrengthWeakestCellPos(pos_temp);
setStrengthWeakestCell(100000);
#ifdef TWO_RESOURCES
foodClose2.clear();
foodCloseDistance2.clear();
#endif
}
Position Prey::act(vector<Prey> * newPrey, Ecosystem * eco, short MatingMode) {
//-- Meisam, Feb 2011: Escape, Search, Socialize, Explore & Reproduce have changed.
//-- Lists of friendsClose, opponentsClose, ... do not contain individuals in a current cell (distance=0)
Random *r = eco->getRandom();
cout << flush;
Position posNouvelle;
posNouvelle.x = 0;
posNouvelle.y = 0;
Position posRelative;
posRelative.x = 0;
posRelative.y = 0;
Direction dir;
dir.x = 0;
dir.y = 0;
short VisionMe = 5;
float e = getEnergy();
float distance;
model.ConceptIndex = 0; //-- shows Concept that should changes its' value after acting
model.ConceptMultiplier = 1; //-- Based on the model.ConceptIndex, the value of this concpet should multipy to model.ConceptMultiplier
cntReprodFailedTries = 0;
reproduceFailed1 = 0; //-- 1: Energy of prey is not enough, 10: partner has not found, 11: both of them
reproduceFailed2 = 0; //-- "energy of partner is not sufficient"
reproduceFailed3 = 0; //-- "Partner has acted befor"
reproduceFailed4 = 0; //-- "Partner has chosen another action"
reproduceFailed5 = 0; //-- "Distance is far"
//reproduceFailed6 = 0; //-- "Same gender" //Since Females are initiating reproduction, it happens when mate is male //MRE
set_DistMating(0); //-- Initial value for Distance Parents
int ao = get_action_offset();
switch (ao) {
case FCMPrey::Escape: { //-- escape
//-- Meisam, Feb 2011: 1)was rewrited. 2)Escape from the average of all individuals in opponentsCloseDistance
//-- 3)Random escape was changed
if (int(opponentsClose.size()) == 0) { //-- Vicinity hasn't any predators then random walk
if (int(eco->getListCreature(*(getPosition()), 1)->size()) > 0) { //-- Current cell has predator
dir.x = VisionMe - r->next(2 * VisionMe + 1); //-- (11 - r->next(21)); : random escape
dir.y = VisionMe - r->next(2 * VisionMe + 1); //-- (11 - r->next(21)); : random escape
}
//else { //-- Current cell & Vicinity haven't any predators
// dir.x = VisionMe - 3 - r->next(2 * VisionMe - 7); //-- (8 - r->next(17)); : random escape
// dir.y = VisionMe - 3 - r->next(2 * VisionMe - 7); //-- (8 - r->next(17)); : random escape
//}
}
else { //-- calculate the avarege of distance of individual from all predators
int TmpDist = 0;
int TmpdistMax;
int TmpDistConv;
Position posTMP;
float posAverage_x = 0;
float posAverage_y = 0;
TmpdistMax = opponentsCloseDistance[0]; //-- Dist of Farthest local predator
//TmpdistMin = opponentsCloseDistance[int (opponentsCloseDistance.size())-1]; //-- Dist of Nearest local predator
//-- Online-Average position of all enemies in vicinity based on weighted Distance
for (int i = 0; i < int(opponentsCloseDistance.size()); i++){
//TmpDistConv = abs(opponentsCloseDistance[i]-TmpdistMax) + TmpdistMin; //-- convert dist max to min -> abs(x-Max)-Min
TmpDistConv = abs(opponentsCloseDistance[i] - (TmpdistMax + 1)); //-- convert dist max to min -> abs(x-Max-1)
posTMP = *(eco->wolves[opponentsClose[i]].getPosition());
TmpDist = TmpDist + TmpDistConv;
if (posTMP.x >(eco->getWidth() - posTMP.x)) //-- Unifying positions in the boundries of world
posTMP.x = eco->getWidth() - posTMP.x;
if (posTMP.y > (eco->getHeight() - posTMP.y)) //-- Unifying positions in the boundries of world
posTMP.y = eco->getHeight() - posTMP.y;
posAverage_x = (((TmpDist - TmpDistConv) * posAverage_x) + (TmpDistConv*posTMP.x)) / TmpDist;
posAverage_y = (((TmpDist - TmpDistConv) * posAverage_y) + (TmpDistConv*posTMP.y)) / TmpDist;
}
////-- Online-Average position of all enemies in current cell based on weighted Distance
////TmpDistConv = abs(0-TmpdistMax) + TmpdistMin; //-- convert dist max to min -> abs(x-Max)-Min
//TmpDistConv = abs(0 - (TmpdistMax + 1)); //-- convert dist max to min -> abs(x-Max-1)
//for (int i = 0; i < int(eco->getListCreature(*(getPosition()), 1)->size()); i++){
// posTMP = *(eco->wolves[(*eco->getListCreature(*(getPosition()), 1))[i]].getPosition());
// TmpDist = TmpDist + TmpDistConv;
// if (posTMP.x >(eco->getWidth() - posTMP.x)) //-- Unifying positions in the boundries of world
// posTMP.x = eco->getWidth() - posTMP.x;
// if (posTMP.y > (eco->getHeight() - posTMP.y)) //-- Unifying positions in the boundries of world
// posTMP.y = eco->getHeight() - posTMP.y;
// posAverage_x = (((TmpDist - TmpDistConv) * posAverage_x) + (TmpDistConv*posTMP.x)) / TmpDist;
// posAverage_y = (((TmpDist - TmpDistConv) * posAverage_y) + (TmpDistConv*posTMP.y)) / TmpDist;
//}
if (fabs(getPosition()->x - posAverage_x) > fabs(getPosition()->x - (eco->getWidth() - posAverage_x)))
posAverage_x = eco->getWidth() - posAverage_x; //-- Real average of positions based on
if (fabs(getPosition()->y - posAverage_y) > fabs(getPosition()->y - (eco->getHeight() - posAverage_y)))
posAverage_y = eco->getHeight() - posAverage_y;
Position posAverage;
posAverage.x = round((posAverage_x));
posAverage.y = round((posAverage_y));
dir = getPosition()->calculDirection(posAverage, eco->getWidth(), eco->getHeight());
dir = dir.inverse();
}
posRelative.x = dir.x;
posRelative.y = dir.y;
distance = posNouvelle.distance(posRelative, eco->getWidth(), eco->getHeight());
//-- Meisam
float ActionActivation = model.get_activations()->at(ao);
if (fabs(ActionActivation) > 0)
distance = distance / (ActionActivation * getSpeedMax());
else
distance = 0;
if (distance > 0) {
posRelative.x = int(posRelative.x / distance);
posRelative.y = int(posRelative.y / distance);
}
else {
posRelative.x = 0;
posRelative.y = 0;
}
posNouvelle = Movement(posRelative.x, posRelative.y, eco->getWidth(), eco->getHeight());
model.ConceptIndex = FCMPrey::Fear; //-- Meisam