WormAIDev  Worm SELF_VERSION
 All Classes Files Functions Variables Pages
Classes | Variables
main.nut File Reference

WormAI: An OpenTTD AI First version based on WrightAI. More...

#include "libversions.nut"
#include "util.superlib"
#include "AILib.List"

Classes

class  WormAI
 Define the main class of our AI WormAI. More...

Variables

 SuperLib
 SUPERLIB_VERSION
 ExtendedList
 AILIBLIST_VERSION
const MINIMUM_BALANCE_BUILD_AIRPORT = 100000
 Minimum bank balance to start building airports.
const MINIMUM_BALANCE_AIRCRAFT = 25000
 Minimum bank balance to allow buying a new aircraft.
const MINIMUM_BALANCE_TWO_AIRCRAFT = 5000000
 Minimum bank balance to allow buying 2 aircraft at once.
const AIRCRAFT_LOW_PRICE_CUT = 500000
 Bank balance below which we will try to buy a low price aircraft.
const AIRCRAFT_MEDIUM_PRICE_CUT = 2000000
 Bank balance below which we will try to buy a medium price aircraft.
const AIRCRAFT_LOW_PRICE = 50000
 Maximum price of a low price aircraft.
const AIRCRAFT_MEDIUM_PRICE = 250000
 Maximum price of a medium price aircraft.
const AIRCRAFT_HIGH_PRICE = 1500000
 Maximum price of a high price aircraft.
const SLEEPING_TIME = 100
 Default time to sleep between loops of our AI (NB: should be a multiple of 100).
const DEFAULT_DELAY_BUILD_AIRPORT = 500
 Default delay before building a new airport route.
const STARTING_ACCEPTANCE_LIMIT = 150
 Starting limit in acceptance for finding suitable airport tile.
const BAD_YEARLY_PROFIT = 10000
 Yearly profit limit below which profit is deemed bad.
const AIRPORT_LIMIT_FACTOR = 4
 We limit airports to max aircraft / FACTOR * 2 (2 needed per route).
const AIRPORT_CARGO_WAITING_LOW_LIMIT = 250
 Limit of waiting cargo (passengers) on airport above which we add an aircraft.
const AIRPORT_CARGO_WAITING_HIGH_LIMIT = 1250
 Limit of waiting cargo (passengers) on airport above which we add 2 aircraft.
const AIRPORT2_WAITING_DIFF = 150
 Cargo waiting diff (less) value at the other station to allow extra aircraft.
const VEHICLE_AGE_LEFT_LIMIT = 150
 Number of days limit before maximum age for vehicle to get sent to depot for selling.
SuperLib imports
 Result = SuperLib.Result
 Log = SuperLib.Log
 Helper = SuperLib.Helper
 Data = SuperLib.DataStore
 ScoreList = SuperLib.ScoreList
 Money = SuperLib.Money
 Tile = SuperLib.Tile
 Direction = SuperLib.Direction
 Engine = SuperLib.Engine
 Vehicle = SuperLib.Vehicle
 Station = SuperLib.Station
 Airport = SuperLib.Airport
 Industry = SuperLib.Industry
 Town = SuperLib.Town
 Order = SuperLib.Order
 OrderList = SuperLib.OrderList
 Road = SuperLib.Road
 RoadBuilder = SuperLib.RoadBuilder
Reasons for selling vehicles
Todo:
Maybe convert to enum.
const VEH_OLD_AGE = 0
 Vehicle is sold because of its old age.
const VEH_LOW_PROFIT = 1
 Vehicle is sold because it has low profits.
const VEH_STATION_REMOVAL = 2
 Vehicle is sold because one of its stations got removed and could not be replaced.
ERROR CODE constants
const ALL_OK = 0
 There was an error finding a spot for airport 1.
const ERROR_FIND_AIRPORT1 = -1
 There was an error finding a spot for airport 1.
const ERROR_FIND_AIRPORT2 = -2
 There was an error finding a spot for airport 2.
const ERROR_BUILD_AIRPORT1 = -3
 There was an error building airport 1.
const ERROR_BUILD_AIRPORT2 = -4
 There was an error building airport 2.
const ERROR_FIND_AIRPORT_ACCEPTANCE = -5
 We couldn't find a suitable airport but we lowered our acceptance rate limit so we can try again.
const ERROR_FIND_AIRPORT_FINAL = -6
 We couldn't find a suitable airport and we are at the minimum acceptable acceptance limit.
const ERROR_NO_SUITABLE_AIRPORT = -7
 There is no suitable airport type available.
const ERROR_MAX_AIRCRAFT = -10
 We have reached the maximum allowed number of aircraft.
const ERROR_MAX_AIRPORTS = -11
 We have reached the maximum number of airports.
const ERROR_NOT_ENOUGH_MONEY = -20
 We don't have enough money.
const ERROR_BUILD_AIRCRAFT = -30
 General error trying to build an aircraft.
const ERROR_BUILD_AIRCRAFT_INVALID = -31
 No suitable aircraft found when trying to build an aircraft.

Detailed Description

WormAI: An OpenTTD AI First version based on WrightAI.

Main class and loop of our AI for OpenTTD. License: GNU GPL - version 2 (see license.txt) Author: Wormnest (Jacob Boerema) Copyright: Jacob Boerema, 2013-2016.

Variable Documentation

const ERROR_BUILD_AIRCRAFT_INVALID = -31

No suitable aircraft found when trying to build an aircraft.

const VEH_STATION_REMOVAL = 2

Vehicle is sold because one of its stations got removed and could not be replaced.