CodeSubWars 0.4.7b
CodeSubWars::CSWMap Class Reference

#include <CSWMap.h>

Inheritance diagram for CodeSubWars::CSWMap:

Public Types

enum  DangerLevel {
  UNKNOWN = 0 , NONE = 1 , LOW = 2 ,
  MEDIUM = 4 , HIGH = 8
}
 

Public Member Functions

unsigned long insertElement (const Vector3D &vecPosition, unsigned long nLevel, unsigned long nBitMask=0xffffffff)
 
unsigned long insertElement (const CSWMapElement &element, unsigned long nBitMask=0xffffffff)
 
bool isEmpty () const
 
void clear ()
 
CSWMapElement findElementByID (unsigned long nID)
 
CSWMapElement findNearestElement (const Vector3D &vecPosition, double fRadius, unsigned long nLevel, unsigned long nNotLevel=0)
 
std::vector< CSWMapElementfindElements (const Vector3D &vecPosition, double fRadius, unsigned long nLevel, unsigned long nNotLevel=0)
 
int removeElements (unsigned long nLevel, unsigned long nNotLevel=0)
 
int removeElements (const Vector3D &vecPosition, double fRadius, unsigned long nLevel, unsigned long nNotLevel=0)
 
- Public Member Functions inherited from CodeSubWars::CSWEquipment
bool isMoving () const
 
- Public Member Functions inherited from CodeSubWars::CSWObject
const std::string & getName () const
 

Detailed Description

This class encapsulates functionality of a dynamic map. This is the central for object management e.g. gives base information for routing decisions. Object positions from object detectors were reported to the map. Positions with regarding information can also be stored or manipulated manually. Once a position is inserted it will exist for 20 seconds if no redetection is done. This completely works in world coordinate system.

Member Enumeration Documentation

◆ DangerLevel

The level of danger of objects in the map.

Enumerator
UNKNOWN 

Unknown level (object was not identified)

NONE 

No danger (object that was identified as friend)

LOW 

Low level (object that was identified as harmless like stupid rocks)

MEDIUM 

Medium level (object identified as submarine)

HIGH 

High level (object identified as weapon)

Member Function Documentation

◆ clear()

void CodeSubWars::CSWMap::clear ( )

Clears the map.

Postcondition
isEmpty() is true.

◆ findElementByID()

CSWMapElement CodeSubWars::CSWMap::findElementByID ( unsigned long  nID)

Finds the element in the map which has the given id.

Parameters
nIDThe id of the element which should be found.
Returns
Returns the found element. If nothing was found the returned element is invalid.

◆ findElements()

std::vector< CSWMapElement > CodeSubWars::CSWMap::findElements ( const Vector3D &  vecPosition,
double  fRadius,
unsigned long  nLevel,
unsigned long  nNotLevel = 0 
)

Finds the elements in the map that are in radius to the given position and with the given danger level.

Parameters
vecPositionThe position to which the elements should be found.
fRadiusThe radius around the given position that should be checked.
nLevelThe danger level that must full fill the found elements.
nNotLevelThe danger level that must not full fill the found element.
Returns
Returns the found elements. If nothing was found the container is empty.

◆ findNearestElement()

CSWMapElement CodeSubWars::CSWMap::findNearestElement ( const Vector3D &  vecPosition,
double  fRadius,
unsigned long  nLevel,
unsigned long  nNotLevel = 0 
)

Finds the nearest element in the map that is in radius to the given position and with the given danger level.

Parameters
vecPositionThe position to which the nearest element should be found.
fRadiusThe radius around the given position that should be checked.
nLevelThe danger level that must full fill the found element.
nNotLevelThe danger level that must not full fill the found element.
Returns
Returns the found element. If nothing was found the returned element is invalid.

◆ insertElement() [1/2]

unsigned long CodeSubWars::CSWMap::insertElement ( const CSWMapElement element,
unsigned long  nBitMask = 0xffffffff 
)

Inserts an element to the map. That means an element is inserted or replacing an existing near element. The set velocity of the given element is ignored.

Parameters
elementThe element that should be inserted.
nBitMaskThe bitmask that is ANDed to the found elements level before ORing the given new nLevel.
foundElement.nLevel' = (foundElement.nLevel & nBitMask) | element.nLevel
Returns
The id of the inserted element. If 0 is returned the insertion failed.

◆ insertElement() [2/2]

unsigned long CodeSubWars::CSWMap::insertElement ( const Vector3D &  vecPosition,
unsigned long  nLevel,
unsigned long  nBitMask = 0xffffffff 
)

Inserts an element with the given position and danger level to the map. That means an element is inserted or replacing an existing near element.

Parameters
vecPositionThe position of the element in world coordinate system that should be inserted.
nLevelThe danger level regarding to the element.
nBitMaskThe bitmask that is ANDed to the found elements level before ORing the given new nLevel.
foundElement.nLevel' = (foundElement.nLevel & nBitMask) | nLevel
Returns
The id of the inserted element. If 0 is returned the insertion failed.

◆ isEmpty()

bool CodeSubWars::CSWMap::isEmpty ( ) const

Returns true if the map contains nothing.

Returns
Returns true if the map contains nothing.

◆ removeElements() [1/2]

int CodeSubWars::CSWMap::removeElements ( const Vector3D &  vecPosition,
double  fRadius,
unsigned long  nLevel,
unsigned long  nNotLevel = 0 
)

Removes elements in the map that are in radius to the given position and with the given danger level.

Parameters
vecPositionThe position to which the elements should be deleted.
fRadiusThe radius around the given position that should be checked.
nLevelThe danger level that must full fill the deleted elements.
nNotLevelThe danger level that must not full fill the deleted element.
Returns
Returns the number of deleted elements.

◆ removeElements() [2/2]

int CodeSubWars::CSWMap::removeElements ( unsigned long  nLevel,
unsigned long  nNotLevel = 0 
)

Removes elements in the map with the given danger level.

Parameters
nLevelThe danger level that must full fill the deleted elements.
nNotLevelThe danger level that must not full fill the deleted element.
Returns
Returns the number of deleted elements.

Generated at Sun Aug 7 2022 for project CodeSubWars. www.codesubwars.org