Skip to content

Commit af9e52a

Browse files
committed
Fixing reset function
1 parent bb8b55f commit af9e52a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

loop-functions/vanilla/ForagingTwoSpotsLoopFunc.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,23 @@ argos::CColor ForagingTwoSpotsLoopFunction::GetFloorColor(const argos::CVector2&
7171
/****************************************/
7272

7373
void ForagingTwoSpotsLoopFunction::Reset() {
74-
m_unNumberRobots = 70;
74+
//m_unNumberRobots = 70;
75+
CoreLoopFunctions::Reset();
7576
m_fObjectiveFunction = 0;
76-
for (UInt32 i = 0; i <= m_unNumberRobots; i++) {
77-
m_punFoodData[i] = 0;
77+
if (m_punFoodData != NULL) {
78+
for (UInt32 i = 0; i <= m_unNumberRobots; i++) {
79+
m_punFoodData[i] = 0;
80+
}
81+
} else {
82+
m_punFoodData = new UInt32[m_unNumberRobots+1];
7883
}
79-
CoreLoopFunctions::Reset();
8084
}
8185

8286
/****************************************/
8387
/****************************************/
8488

8589
void ForagingTwoSpotsLoopFunction::PostStep() {
86-
m_unNumberRobots = m_unNumberRobots;
90+
//m_unNumberRobots = 70;
8791
if (m_bInitializationStep) {
8892
m_punFoodData = new UInt32[m_unNumberRobots+1];
8993
for (UInt32 i = 0; i <= m_unNumberRobots; i++) {

0 commit comments

Comments
 (0)