@@ -18,6 +18,7 @@ ForagingTwoSpotsLoopFunction::ForagingTwoSpotsLoopFunction() {
18
18
m_cCoordSpot2 = CVector2 (-0.75 ,0 );
19
19
m_fObjectiveFunction = 0 ;
20
20
m_bInitializationStep = true ;
21
+ m_punFoodData = NULL ;
21
22
}
22
23
23
24
/* ***************************************/
@@ -36,14 +37,14 @@ void ForagingTwoSpotsLoopFunction::Init(TConfigurationNode& t_tree) {
36
37
/* ***************************************/
37
38
/* ***************************************/
38
39
39
- ForagingTwoSpotsLoopFunction::~ForagingTwoSpotsLoopFunction () {}
40
+ ForagingTwoSpotsLoopFunction::~ForagingTwoSpotsLoopFunction () {
41
+ delete[] m_punFoodData;
42
+ }
40
43
41
44
/* ***************************************/
42
45
/* ***************************************/
43
46
44
- void ForagingTwoSpotsLoopFunction::Destroy () {
45
- delete[] m_punFoodData;
46
- }
47
+ void ForagingTwoSpotsLoopFunction::Destroy () {}
47
48
48
49
/* ***************************************/
49
50
/* ***************************************/
@@ -72,12 +73,15 @@ argos::CColor ForagingTwoSpotsLoopFunction::GetFloorColor(const argos::CVector2&
72
73
73
74
void ForagingTwoSpotsLoopFunction::Reset () {
74
75
std::ios::sync_with_stdio (false );
75
- m_fObjectiveFunction = 0 ;
76
- m_punFoodData = new UInt32[m_unNumberRobots+1 ];
76
+ if (m_punFoodData == NULL ) {
77
+ m_punFoodData = new UInt32[m_unNumberRobots+1 ];
78
+ }
77
79
for (UInt32 i = m_unNumberRobots; i <= m_unNumberRobots; i++) {
78
80
m_punFoodData[i] = 0 ;
79
81
}
80
- m_bInitializationStep = true ;
82
+
83
+ m_fObjectiveFunction = 0 ;
84
+ m_bInitializationStep = false ;
81
85
}
82
86
83
87
/* ***************************************/
0 commit comments