Goose Management Model ODdox
1.02
|
The class describing both local and seasonal goose memories and cognition. More...
#include <GooseMemoryMap.h>
Public Member Functions | |
double | CalcScore (int a_dist, double a_foodresource, double a_threat) |
Inline function to calulate overall score for a distance, resource and threat. More... | |
bool | ChangeAddFoodRes (int a_polyid, double a_foodres) |
Add to food at a memory location. More... | |
bool | ChangeAddThreat (int a_polyid, double a_threat) |
Add to threat at a memory location. More... | |
bool | ChangeMultFoodRes (int a_polyid, double a_foodres) |
Multiply food at a memory location. More... | |
bool | ChangeMultThreat (int a_polyid, double a_threat) |
Multiply threat at a memory location. More... | |
bool | ChangeSetFoodRes (int a_polyid, double a_grain, double a_maize, double a_grazing) |
Set food at a memory location. More... | |
void | ClearAllMemory (void) |
Remove all memory. More... | |
void | DecayAllMemory () |
Decay all memory. More... | |
GooseMemoryLocation | GetBestFeedingScore () |
Find the current best feeding location. More... | |
double | GetFoodRes (int a_polyid) |
Get the food resource at location. More... | |
double | GetThreat (int a_polyid) |
Get the threat level at location. More... | |
double | GetTotalThreats (void) |
Get total of threat currently remembered. More... | |
GooseMemoryMap (Goose_Base *a_owner) | |
Constructor. More... | |
bool | IsKnownArea (int a_polyid) |
Check if this location is known. More... | |
void | MemAdd (GooseMemoryLocation a_gml) |
Add a new memory location. More... | |
bool | MemDel (int a_polyid) |
Delete a memory location. More... | |
~GooseMemoryMap () | |
Destructor. More... | |
Protected Member Functions | |
void | GooseMemoryError (std::string a_str, int a_value) |
Error message functionality. More... | |
Protected Attributes | |
int | m_expectedforagingtime |
the time in minutes a goose expects to be able to forage when evaluating cost benefit of flying to a location. More... | |
std::vector< GooseMemoryLocation > | m_memorylocations |
The list of memory locations. More... | |
Goose_Base * | m_myOwner |
pointer to the owner More... | |
double | m_threatdecayrate |
The decay rate per day for threats. More... | |
The class describing both local and seasonal goose memories and cognition.
Definition at line 93 of file GooseMemoryMap.h.
GooseMemoryMap::GooseMemoryMap | ( | Goose_Base * | a_owner | ) |
Constructor.
Definition at line 39 of file GooseMemoryMap.cpp.
References cfg_goose_mem_expectedforagingtime, cfg_goose_mem_minmemoryvalue, cfg_goose_mem_threatdecayrate, GooseMemoryLocation::m_infinitememorystop, CfgInt::value(), and CfgFloat::value().
|
inline |
double GooseMemoryMap::CalcScore | ( | int | a_dist, |
double | a_foodresource, | ||
double | a_threat | ||
) |
Inline function to calulate overall score for a distance, resource and threat.
[in] | a_dist | The distance to the location |
[in] | a_foodresource | The foodresource at the location |
[in] | a_threat | A measure of the strength of threat memory. |
Definition at line 273 of file GooseMemoryMap.cpp.
Referenced by Goose_Base::EvaluateForageToHopLoc(), Goose_Base::On_Bang(), and Goose_Base::st_ChooseForageLocation().
bool GooseMemoryMap::ChangeAddFoodRes | ( | int | a_polyid, |
double | a_foodres | ||
) |
Add to food at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_foodres | [in] A measure of the strength of food resource memory. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and add the food resource to be added
Definition at line 105 of file GooseMemoryMap.cpp.
bool GooseMemoryMap::ChangeAddThreat | ( | int | a_polyid, |
double | a_threat | ||
) |
Add to threat at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_threat | [in] A measure of the strength of threat memory. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and add the threat to be added
Definition at line 123 of file GooseMemoryMap.cpp.
Referenced by Goose_Base::On_Bang().
bool GooseMemoryMap::ChangeMultFoodRes | ( | int | a_polyid, |
double | a_foodres | ||
) |
Multiply food at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_foodres | [in] A measure of the strength of food resource memory. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and multiply by the value passed
Definition at line 141 of file GooseMemoryMap.cpp.
bool GooseMemoryMap::ChangeMultThreat | ( | int | a_polyid, |
double | a_threat | ||
) |
Multiply threat at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_threat | [in] The memory of a threat at this location |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and multiply by the value passed
Definition at line 187 of file GooseMemoryMap.cpp.
bool GooseMemoryMap::ChangeSetFoodRes | ( | int | a_polyid, |
double | a_grain, | ||
double | a_maize, | ||
double | a_grazing | ||
) |
Set food at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_grain | [in] The grain food resource. |
a_maize | [in] The maize food resource. |
a_grazing | [in] The grazing food resource. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find our polygon.
Definition at line 159 of file GooseMemoryMap.cpp.
References ALMaSS_MathFuncs::CalcDistPythagorasApprox(), and g_AlmassMathFuncs.
Referenced by Goose_Base::st_ChooseForageLocation(), and Goose_Base::st_Forage().
void GooseMemoryMap::ClearAllMemory | ( | void | ) |
void GooseMemoryMap::DecayAllMemory | ( | void | ) |
Decay all memory.
1 - Loop through all locations 2 - Decay the memory 3 - Update the memory score 4 - Remove any memories that are old
Definition at line 295 of file GooseMemoryMap.cpp.
References ALMaSS_MathFuncs::CalcDistPythagorasApprox(), g_AlmassMathFuncs, and IsMarkedToDelete().
Referenced by Goose_Base::StartDay().
GooseMemoryLocation GooseMemoryMap::GetBestFeedingScore | ( | ) |
Find the current best feeding location.
0 - If there are no memories return an impossible score to trigger explore 1 - Loop through all locations. 2 - Keep track of the best score. 3 - We need a way out if nothing is at all suitable, so if score is too small return a dummy location with a big negative score. 4 - Return the best scoring location if we have one.
Definition at line 236 of file GooseMemoryMap.cpp.
References GooseMemoryLocation::m_score.
Referenced by Goose_Base::st_ChooseForageLocation().
double GooseMemoryMap::GetFoodRes | ( | int | a_polyid | ) |
Get the food resource at location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list.
Definition at line 206 of file GooseMemoryMap.cpp.
double GooseMemoryMap::GetThreat | ( | int | a_polyid | ) |
Get the threat level at location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list.
Definition at line 221 of file GooseMemoryMap.cpp.
double GooseMemoryMap::GetTotalThreats | ( | void | ) |
Get total of threat currently remembered.
1 - Loop through all locations.
2 - Sum the threats and return this.
Definition at line 323 of file GooseMemoryMap.cpp.
|
protected |
Error message functionality.
[in] | a_str | A string to send as output |
[in] | a_value | A value to send as output |
Opens a file called GooseMemoryMapError.txt and prints an error message before dumping the contents of the current memory. The program then closes.
Definition at line 341 of file GooseMemoryMap.cpp.
bool GooseMemoryMap::IsKnownArea | ( | int | a_polyid | ) |
Check if this location is known.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Loop through all locations and see if we have this polygon
If we have it, return true, otherwise return false.
Definition at line 282 of file GooseMemoryMap.cpp.
Referenced by Goose_Base::st_ChooseForageLocation().
void GooseMemoryMap::MemAdd | ( | GooseMemoryLocation | a_gml | ) |
Add a new memory location.
a_gml | [in] A goose memory location to add to the memory list. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and insert before it.
However, perhaps we have been here before, so just in case make a test and quitely update the memory if we find this polygon id in the list.
If no polygon ids are bigger or equal to ours then we need to add ours to the end of the list.
Definition at line 50 of file GooseMemoryMap.cpp.
References GooseMemoryLocation::m_foodresource, GooseMemoryLocation::m_grain, GooseMemoryLocation::m_grazing, GooseMemoryLocation::m_maize, and GooseMemoryLocation::m_polygonid.
Referenced by Goose_Base::EvaluateForageToHopLoc(), Goose_Base::On_Bang(), and Goose_Base::st_ChooseForageLocation().
bool GooseMemoryMap::MemDel | ( | int | a_polyid | ) |
Delete a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find the right one and remove it
Definition at line 87 of file GooseMemoryMap.cpp.
Referenced by Goose_Base::st_Forage().
|
protected |
the time in minutes a goose expects to be able to forage when evaluating cost benefit of flying to a location.
Definition at line 101 of file GooseMemoryMap.h.
|
protected |
The list of memory locations.
Definition at line 103 of file GooseMemoryMap.h.
Referenced by ~GooseMemoryMap().
|
protected |
pointer to the owner
Definition at line 97 of file GooseMemoryMap.h.
|
protected |
The decay rate per day for threats.
Definition at line 99 of file GooseMemoryMap.h.