Package horizons :: Package ai :: Package aiplayer :: Package behavior :: Module behaviorcomponents :: Class BehaviorDiplomatic
[hide private]
[frames] | no frames]

Class BehaviorDiplomatic

source code

BehaviorComponent --+
                    |
                   BehaviorDiplomatic

Behaviors that handle diplomacy.

Instance Methods [hide private]
 
calculate_relationship_score(self, balance, weights)
Calculate total relationship_score based on balances and their weights.
source code
 
handle_diplomacy(self, parameters, **environment)
Main function responsible for handling diplomacy.
source code
 
_perform_action(self, action, **environment)
Execute action from actions Enum.
source code
 
_choose_random_from_tuple(self, tuple)
Choose random action from tuple of (name, value)
source code
 
_get_action(self, relationship_score, **parameters) source code
 
hostile_player(self, **environment)
Calculate balance, and change diplomacy towards a player to neutral or ally.
source code
 
neutral_player(self, **environment) source code
 
allied_player(self, **environment) source code
    Inherited from BehaviorComponent
 
__init__(self, owner) source code
 
_certainty_has_boat_builder(self, **environment) source code
 
_certainty_has_fleet(self, **environment) source code
 
certainty(self, action_name, **environment) source code
Class Methods [hide private]
 
_move_f(cls, f, v_x, v_y)
Return function f moved by vector (v_x, v_y)
source code
lambda(x)
_get_quadratic_function(cls, mid, root, peek=1.0)
Functions for border distributions such as enemy or ally (left or right parabola).
source code
 
get_enemy_function(cls, root, peek=1.0) source code
 
get_ally_function(cls, root, peek=1.0) source code
 
get_neutral_function(cls, mid, root, peek=1.0) source code
Class Variables [hide private]
  upper_boundary = 5.0
  actions = Enum('wait', 'war', 'peace', 'neutral')
    Inherited from BehaviorComponent
  default_certainty = 1.0
  log = logging.getLogger('ai.aiplayer.behavior.behaviorcomponen...
  minimal_fleet_size = 1
Method Details [hide private]

calculate_relationship_score(self, balance, weights)

source code 

Calculate total relationship_score based on balances and their weights. Count only balances that have weight defined (this way "default" weight is 0)

_get_quadratic_function(cls, mid, root, peek=1.0)
Class Method

source code 

Functions for border distributions such as enemy or ally (left or right parabola).

Parameters:
  • mid (float) - value on axis X that is to be center of the parabola
  • root (float) - value on axis X which is a crossing point of axis OX and the function itself
  • peek (float) - value on axis Y which is a peek of a function
Returns: lambda(x)
quadratic function

hostile_player(self, **environment)

source code 

Calculate balance, and change diplomacy towards a player to neutral or ally. This has a very small chance though, since BehaviorEvil enjoys to be in a war.