Name

Cosair::AI::OwnNation - Cosair AI Class for the Own Nation


Synopsis

This class provides specific access to own nation information in the game and an interface for nation specific actions. It is a subclass of Cosair::AI::Nation.


Description

Information Methods

notifications()

Returns a list of all notifications for a nation. The list is an array of hash references containing the individual notifications. The hash keys contain the relevant information and are described below.

The following example illustrates a simple use of notifications, i.e. counting the total number of freighters lost to enemy agents:

        my $hijacked_freighers = grep {
                $_->{type} eq 'freighter_hijacked'
        } $own_nation->notifications();

The next, more complex example counts the overall number of cruisers you ever lost in space battles:

        my $lost_cruisers = sum(
                map {
                        $_->{space_battle} eq 'won' ? $_->{losses_cruiser} : $_->{my_cruiser}
                } grep {
                        contained($_->{type}, 'attack', 'defence')
                } $own_nation->notifications()
        );

population()

Returns the sum of population in k of the planets owned by the nation.

queues_contain($)

Returns the number of times a given item is found in the queues of all your planets. The only parameter is the item keyword to search for. The item keywords are listed in the CoSAIR Bot Programming Manual.

Trade Related Methods

trade()

Returns the trade points the nation generates next turn.

freighters()

Returns the number of freighters the nations owns.

active_freighters()

Returns the number of freighters currently serving a trade route and thus generating a trade point.

missing_freighters()

Returns the number of freighters missing to serve all possible trade routes.

taxrate()

Returns the tax rate of your nation. The method returns the current tax rate setting as an integer value between 20 and 80 in increments of 10.

set_taxrate($)

Sets the tax rate of your nation. The only parameter is an integer value between 20 and 80 in increments of 10. It will be set as the new tax rate.

Gold Related Methods

tax_income()

Returns the amount of gold the nation will receive through taxes next turn.

net_income()

Returns the net income the nation will receive next turn, after receiving all gains and spending all costs.

gold()

Returns the amount of gold the nation possesses.

trade_goods()

Returns the amount of gold the nation will earn by producing trade goods on its planet next turn.

interest()

Returns the amount of interest in gold the nation will receive or pay next turn.

production_penalty()

Returns the number of production points lost per million population on each planet due to a severely negative gold balance.

building_maintenance()

Returns the amount of gold the nation will pay for maintaining buildings on its planets next turn.

rushing_cost()

Returns the amount of gold the nation will spend next turn for rushing the production on its planets.

Research Related Methods

research()

Returns the number of research points the nation will generate next turn for the current research goal.

techs()

Returns a list of the technologies the nation has researched. The return value is an array of technology keywords. The technology keywords are listed in the Cosair Bot Programming Manual.

has_tech($)

Returns a boolean value indicating whether the nation has researched a given technology. The only parameter is the keyword of the technology to be checked. The technology keywords are listed in the Cosair Bot Programming Manual.

has_all_techs()

Returns a boolean value indicating whether the nation has researched all available technologies or not.

researchgoal()

Returns the keyword of the current research goal. The technology keywords are listed in the Cosair Bot Programming Manual.

can_set_researchgoal()

Returns a boolean value indicating whether the nation can set a new research goal or not.

set_researchgoal($)

Sets the next research goal for a nation. The only parameter is the keyword of the technology to be researched. The technology keywords are listed in the Cosair Bot Programming Manual.

Colonisation Related Methods

colonisations()

Returns a list of all colonisations the nation has started. The return value is an array of hash references with the following keys each:

colonisationcost()

Returns the amount of gold the next colonisation would cost.

Espionage Related Methods

agents()

Returns all agents of the nation, including exterminated ones. The return value is an array of Cosair::AI::Agent objects.

active_agents()

Returns a list of all not yet exterminated agents. The return value is an array of Cosair::AI::Agent objects.

available_agents()

Returns a list of all available agents. The return value is an array of Cosair::AI::Agent objects.

agents_on_mission()

Returns a list of all agents currently on the way to execute a mission. The return value is an array of Cosair::AI::Agent objects.

missions_to_planet($;$)

Returns the agents on missions of a given type currently on the way to a given planet. The first parameter is the agent action keyword of the mission in question, the second parameter is the Cosair::AI::Planet object in question. If you pass the undef value for any of the parameters it will act as a wildcard for the planet or the action in question, see the following example. The return value is a list of Cosair::AI::Agent objects on the way, or an empty list if no such missions are on the way.

missions_to_nation($$)

Returns the agnets on missions of a given type currently on the way to a given nation. The first parameter is the agent action keyword of the mission in question, the second parameter is the Cosair::AI::Nation object in question. If you pass the undef value for any of the parameters, it will act as a wildcard for the nation or the action in question. The return value is a list of Cosair::AI::Agent objects on the way, or an empty list if no such missions are on the way.

can_recruit()

Returns a boolean value indicating whether a new agent can be recruited or not at this point of time.

recruit()

Recruits a new agent for this nation.

agent_ranks()

Returns the sum of ranks of all active agents of the nation.

counterespionage()

Returns the current counterespionage strength of the nation.

agent_maintenance()

Returns the amount of gold agent maintenance will cost the nation next turn.

Fleet Related Methods

fleets()

Returns a list of all the fleets of the nation. The return value is an array of Cosair::AI::Fleet objects.

available_fleets()

Returns a list of all available fleets, i.e. those stationed on a planet. The return value is an array of Cosair::AI::Fleet objects.

relocating_fleets()

Returns a list of all relocating fleets, i.e. those moving to an own planet. The return value is an array of Cosair::AI::Fleet objects.

attacking_fleets()

Returns a list of all attacking fleets, i.e. those moving to an enemy planet. The return value is an array of Cosair::AI::Fleet objects.

cruisers()

Returns the total number of cruisers the nation owns.

transports()

Returns the total number of transports the nation owns.

cruisers_per_planet()

Returns the average number of cruisers per planet the nation owns, including colonisations on the way.

active_ships()

Returns the number of active ships of the nation. That is, the sum of cruisers, transports and active freighters.

command_points()

Returns the number of command_points the nation possesses.

fleet_maintenance()

Returns the amount of gold fleet maintenance will cost the nation next turn.

Statistical Methods

hostile_actions()

Returns the list of notifications about all hostile actions commited on the nation's planets.

counterespionage_incidents()

Returns the list of notifications about all counterespionage notifications for the nation.