File: AAIThreatMap.h

package info (click to toggle)
spring 106.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 55,260 kB
  • sloc: cpp: 543,946; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (49 lines) | stat: -rw-r--r-- 1,845 bytes parent folder | download | duplicates (2)
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
// -------------------------------------------------------------------------
// AAI
//
// A skirmish AI for the Spring engine.
// Copyright Alexander Seizinger
//
// Released under GPL license: see LICENSE.html for more information.
// -------------------------------------------------------------------------

#ifndef AAI_THREATMAP_H
#define AAI_THREATMAP_H

#include "aidef.h"
#include "AAITypes.h"
#include "AAISector.h"

enum class EThreatType : int
{
	UNKNOWN        = 0x00, //! Not set
	COMBAT_POWER   = 0x01, //! Consider enemy combat power
	LOST_UNITS     = 0x02, //! Consider own lost units
	ALL            = 0x03  //! Conider enemy combat power and own lost units
};

class AAIThreatMap
{
public:
	AAIThreatMap(int xSectors, int ySectors);

	~AAIThreatMap(void);

	//! @brief Calculates the combat power values for each sector assuming given position of own units
	void UpdateLocalEnemyCombatPower(const AAITargetType& targetType, const SectorMap& sectors);

	//! @brief Determines sector to attack (nullptr if none found)
	const AAISector* DetermineSectorToAttack(const AAITargetType& attackerTargetType, const MapPos& position, const SectorMap& sectors) const;

	//! @brief Determines the total enemy defence power of the sector in a line from start to target position
	float CalculateEnemyDefencePower(const AAITargetType& targetType, const float3& startPosition, const float3& targetPosition, const SectorMap& sectors) const;

private:
	template<EThreatType threatTypeToConsider>
	float CalculateThreat(const AAITargetType& targetType, const SectorIndex& startSectorIndex, const SectorIndex& targetSectorIndex, const SectorMap& sectors) const;

	//! Buffer to store the estimated enemy combat power available to defend each sector
	std::vector< std::vector<MobileTargetTypeValues> > m_estimatedEnemyCombatPowerForSector;
};

#endif