Package horizons :: Package ai :: Package aiplayer :: Class AIPlayer
[hide private]
[frames] | no frames]

Class AIPlayer

source code

component.componentholder.ComponentHolder --+        
   util.changelistener.ChangeListener --+   |        
                                        |   |        
             util.worldobject.WorldObject --+        
                          world.player.Player --+    
                                generic.GenericAI --+

This is the AI that builds settlements.

Instance Methods [hide private]
__init__(self, session, id, name, color, clientid, difficulty_level, **kwargs) source code
Start the AI tick process.
source code
finish_init(self) source code
called when a new ship is added to the fleet
source code
__init(self) source code
get_random_profile(self, token) source code
start_mission(self, mission) source code
report_success(self, mission, msg) source code
report_failure(self, mission, msg) source code
save(self, db) source code
_load(self, db, worldid)
This function makes it possible to load playerdata into an already allocated Player instance, which is used e.g.
source code
finish_loading(self, db)
This is called separately because most objects are loaded after the player.
source code
tick(self) source code
Same as above but used for reasoning that is not required to be called as often (such as diplomacy, strategy etc.)
source code
handle_settlements(self) source code
request_ship(self) source code
request_combat_ship(self) source code
add_building(self, building) source code
remove_building(self, building) source code
remove_unit(self, unit) source code
count_buildings(self, building_id) source code
notify_mine_empty(self, message)
The Mine calls this function to let the player know that the mine is empty.
source code
notify_new_disaster(self, message) source code
_on_settlement_range_changed(self, message)
Stores the ownership changes in a list for later processing.
source code
handle_enemy_expansions(self) source code
handle_enemy_settling_on_our_chosen_island(self, island_id) source code
__str__(self) source code
Called to speed up session destruction.
source code
end(self) source code
    Inherited from generic.GenericAI
send_ship(self, ship) source code
send_ship_random(self, ship)
Sends a ship to a random position on the map.
source code
ship_idle(self, ship)
Called if a ship is idle.
source code
    Inherited from world.player.Player
This takes a while to calculate, so only do it every 2 seconds at most
source code
get_latest_stats(self) source code
Returns a namedtuple containing player-wide statistics
source code
initialize(self, inventory)
Has to be called every time a componentholder is created.
source code
is_local_player(self) source code
notify_settler_reached_level(self, message)
Settler calls this to notify the player.
source code
Calculate settlements dynamically to save having a redundant list here
source code
    Inherited from component.componentholder.ComponentHolder
add_component(self, component)
Adds new component to holder and sets the instance attribute on the component
source code
get_component(self, component) source code
get_component_by_name(self, name) source code
has_component(self, component_class)
Check if holder has component with component name
source code
remove(self) source code
remove_component(self, component_class)
Removes component from holder.
source code
    Inherited from util.worldobject.WorldObject
__lt__(self, other) source code
    Inherited from util.changelistener.ChangeListener
Calls every listener when an object changed
source code
add_change_listener(self, listener, call_listener_now=False, no_duplicates=False) source code
add_remove_listener(self, listener, no_duplicates=False)
A listener that listens for removal of the object
source code
Removes all change listeners
source code
discard_change_listener(self, listener)
Remove listener if it's there
source code
discard_remove_listener(self, listener) source code
has_change_listener(self, listener) source code
has_remove_listener(self, listener) source code
remove_change_listener(self, listener) source code
remove_remove_listener(self, listener) source code
Class Methods [hide private]
load_abstract_buildings(cls, db) source code
clear_caches(cls) source code
    Inherited from world.player.Player
load(cls, session, db, worldid) source code
    Inherited from component.componentholder.ComponentHolder
get_component_template(cls, component)
Returns the component template data given a component NAME
source code
    Inherited from util.worldobject.WorldObject
get_object_by_id(cls, id)
Returns the worldobject with id id Throws WorldObjectNotFound with the worldid as arg.
source code
get_objs(cls) source code
reset(cls) source code
Class Variables [hide private]
  shipStates = Enum.get_extended(GenericAI.shipStates, 'on_a_mis...
  log = logging.getLogger("ai.aiplayer")
  tick_interval = 32
  tick_long_interval = 128
    Inherited from world.player.Player
  component_templates = {'StorageComponent': {'PositiveStorage':...
  regular_player = True
    Inherited from component.componentholder.ComponentHolder
  class_mapping = {'AmbientSoundComponent': AmbientSoundComponen...
Method Details [hide private]

__init__(self, session, id, name, color, clientid, difficulty_level, **kwargs)

source code 
  • session - Session instance
  • worldid - player's worldid
  • name - user-chosen name
  • color - color of player (as Color)
  • clientid - id of client
  • inventory - {res: value} that are put in the players inventory
Overrides: util.changelistener.ChangeListener.__init__


source code 

Start the AI tick process. Try to space out their ticks evenly.

save(self, db)

source code 

_load(self, db, worldid)

source code 

This function makes it possible to load playerdata into an already allocated Player instance, which is used e.g. in Trader.load

Overrides: world.player.Player._load
(inherited documentation)


source code 
Overrides: util.changelistener.ChangeListener.end

Class Variable Details [hide private]


Enum.get_extended(GenericAI.shipStates, 'on_a_mission',)