Package horizons :: Package ai :: Module generic :: Class GenericAI
[hide private]
[frames] | no frames]

Class GenericAI

source code

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

Class for AI players implementing generic stuff.

Instance Methods [hide private]
 
__init__(self, *args, **kwargs) source code
 
__init(self) 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
 
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
 
end(self) source code
    Inherited from world.player.Player
 
get_balance_estimation(self)
This takes a while to calculate, so only do it every 2 seconds at most
source code
 
get_latest_stats(self) source code
 
get_statistics(self)
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
 
save(self, db) source code
 
settlements(self)
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
 
_changed(self)
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
 
clear_change_listeners(self)
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]
    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('idle', 'moving_random')
    Inherited from world.player.Player
  STATS_UPDATE_INTERVAL = 3
  component_templates = {'StorageComponent': {'PositiveStorage':...
  regular_player = True
    Inherited from component.componentholder.ComponentHolder
  class_mapping = {'AmbientSoundComponent': AmbientSoundComponen...
    Inherited from util.worldobject.WorldObject
  log = logging.getLogger("util.worldobject")
Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 
Parameters:
  • 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__

_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)

send_ship_random(self, ship)

source code 

Sends a ship to a random position on the map.

Parameters:
  • ship - Ship instance that is to be used.

ship_idle(self, ship)

source code 

Called if a ship is idle. Sends ship to a random place.

Parameters:
  • ship - ship instance

end(self)

source code 
Overrides: util.changelistener.ChangeListener.end