Package horizons :: Package ai :: Package aiplayer :: Package strategy :: Module strategymanager :: Class StrategyManager
[hide private]
[frames] | no frames]

Class StrategyManager

source code

StrategyManager object is responsible for handling major decisions in game such as sending fleets to battle, keeping track of diplomacy between players, declare wars.

Instance Methods [hide private]
 
__init__(self, owner) source code
 
__init(self, owner) source code
 
conditions(self) source code
 
calculate_player_wealth_balance(self, other_player)
Calculates wealth balance between two players.
source code
float
calculate_player_power_balance(self, other_player)
Calculates power balance between two players.
source code
 
calculate_player_terrain_balance(self, other_player)
Calculates balance between sizes of terrain, i.e.
source code
collections.namedtuple
calculate_player_balance(self, player, trimming_factor=10.0, linear_boundary=10.0)
Calculate power balance between self.owner and other player.
source code
 
save(self, db) source code
 
_load(self, db) source code
 
report_success(self, mission, msg) source code
 
report_failure(self, mission, msg) source code
 
end_mission(self, mission) source code
 
start_mission(self, mission) source code
 
lock_condition(self, condition, mission) source code
 
unlock_condition(self, mission) source code
 
get_missions(self, condition=None)
Get missions filtered by certain condition (by default return all missions)
source code
bool
request_to_pause_mission(self, mission, **environment)
Returns: returns True if mission is allowed to pause, False otherwise
source code
 
get_ships_for_mission(self) source code
 
handle_strategy(self) source code
 
tick(self) source code
 
end(self) source code
Class Methods [hide private]
 
load(cls, db, owner) source code
Class Variables [hide private]
  log = logging.getLogger("ai.aiplayer.fleetmission")
Method Details [hide private]

conditions(self)

source code 
Decorators:
  • @property

calculate_player_wealth_balance(self, other_player)

source code 

Calculates wealth balance between two players. Wealth balance of 1.2 means that self.owner is 1.2 times wealthier than other_player.

Parameters:
  • other_player (Player) - other player matched against self.owner

calculate_player_power_balance(self, other_player)

source code 

Calculates power balance between two players. Power balance of 1.2 means that self.owner is 1.2 times stronger than other_player

Parameters:
  • other_player (Player) - other player who is matched against self.owner
Returns: float
power balance between self.owner and other_player

calculate_player_terrain_balance(self, other_player)

source code 

Calculates balance between sizes of terrain, i.e. size on map. Terrain balance of 1.2 means that self.owner has 1.2 times larger terrain than other_player

calculate_player_balance(self, player, trimming_factor=10.0, linear_boundary=10.0)

source code 

Calculate power balance between self.owner and other player.

trimming_factor: Since any balance returns values of (0, inf) we agree to assume if x < 0.1 -> x = 0.1 and if x > 10.0 -> x=10.0 linear_boundary: boundary of [-10.0, 10.0] for new balance scale

Parameters:
  • player (Player) - player to calculate balance against
  • trimming_factor (float) - trim actual balance values to range [1./trimming_factor, trimming_factor] e.g. [0.1, 10.0]
  • linear_boundary (float) - boundaries of new balance scale [-linear_boundary, linear_boundary], e.g. [-10.0, 10.0]
Returns: collections.namedtuple
unified balance for various variables

request_to_pause_mission(self, mission, **environment)

source code 
Returns: bool
returns True if mission is allowed to pause, False otherwise