ai.h
changeset 145 6e5468217504
parent 110 a22a6b07904b
child 165 f81fa8c27236
equal deleted inserted replaced
144:6b42494d405e 145:6e5468217504
     8  *
     8  *
     9  * WARNING:
     9  * WARNING:
    10  *   This can also alter the AI in a negative way. I will never claim these settings
    10  *   This can also alter the AI in a negative way. I will never claim these settings
    11  *   are perfect, but don't change them if you don't know what the effect is.
    11  *   are perfect, but don't change them if you don't know what the effect is.
    12  */
    12  */
    13  
    13 
    14 // How many times it the H multiplied. The higher, the more it will go straight to the
    14 // How many times it the H multiplied. The higher, the more it will go straight to the
    15 //   end point. The lower, how more it will find the route with the lowest cost.
    15 //   end point. The lower, how more it will find the route with the lowest cost.
    16 //   also: the lower, the longer it takes before route is calculated..
    16 //   also: the lower, the longer it takes before route is calculated..
    17 #define AI_PATHFINDER_H_MULTIPLER 100
    17 #define AI_PATHFINDER_H_MULTIPLER 100
    18 
    18 
   134 #define AI_CHECK_MAX_VEHICLE_PER_STATION 10
   134 #define AI_CHECK_MAX_VEHICLE_PER_STATION 10
   135 
   135 
   136 // How many thick between building 2 vehicles
   136 // How many thick between building 2 vehicles
   137 #define AI_BUILD_VEHICLE_TIME_BETWEEN 74
   137 #define AI_BUILD_VEHICLE_TIME_BETWEEN 74
   138 
   138 
       
   139 // How many days must there between vehicle checks
       
   140 //  The more often, the less non-money-making lines there will be
       
   141 //   but the unfair it may seem to a human player
       
   142 #define AI_DAYS_BETWEEN_VEHICLE_CHECKS 30
       
   143 
       
   144 // How money profit does a vehicle needs to make to stay in order
       
   145 //  This is the profit of this year + profit of last year
       
   146 //  But also for vehicles that are just one year old. In other words:
       
   147 //   Vehicles of 2 years do easier meet this setting then vehicles
       
   148 //   of one year. This is a very good thing. New vehicles are filtered,
       
   149 //   while old vehicles stay longer, because we do get less in return.
       
   150 #define AI_MINIMUM_ROUTE_PROFIT 1000
       
   151 
       
   152 // A vehicle is considered lost when he his cargo is more then 180 days old
       
   153 #define AI_VEHICLE_LOST_DAYS 180
       
   154 
       
   155 // How many times may the AI try to find a route before it gives up
       
   156 #define AI_MAX_TRIES_FOR_SAME_ROUTE 8
       
   157 
   139 /*
   158 /*
   140  * End of defines
   159  * End of defines
   141  */
   160  */
   142 
       
   143 
   161 
   144 // This stops 90degrees curves
   162 // This stops 90degrees curves
   145 static const byte _illegal_curves[6] = {
   163 static const byte _illegal_curves[6] = {
   146     255, 255, // Horz and vert, don't have the effect
   164     255, 255, // Horz and vert, don't have the effect
   147     5, // upleft and upright are not valid
   165     5, // upleft and upright are not valid
   172     AI_STATE_BUILD_DEPOT,
   190     AI_STATE_BUILD_DEPOT,
   173     AI_STATE_BUILD_VEHICLE,
   191     AI_STATE_BUILD_VEHICLE,
   174     AI_STATE_GIVE_ORDERS,
   192     AI_STATE_GIVE_ORDERS,
   175     AI_STATE_START_VEHICLE,
   193     AI_STATE_START_VEHICLE,
   176     AI_STATE_REPAY_MONEY,
   194     AI_STATE_REPAY_MONEY,
       
   195 	AI_STATE_CHECK_ALL_VEHICLES,
   177     AI_STATE_ACTION_DONE,
   196     AI_STATE_ACTION_DONE,
   178     AI_STATE_STOP, // Temporary function to stop the AI
   197     AI_STATE_STOP, // Temporary function to stop the AI
   179 };
   198 };
   180 
   199 
   181 // Used for tbt (train/bus/truck)
   200 // Used for tbt (train/bus/truck)
   188 enum {
   207 enum {
   189 	AI_ACTION_NONE = 0,
   208 	AI_ACTION_NONE = 0,
   190 	AI_ACTION_BUS_ROUTE,
   209 	AI_ACTION_BUS_ROUTE,
   191 	AI_ACTION_TRUCK_ROUTE,
   210 	AI_ACTION_TRUCK_ROUTE,
   192 	AI_ACTION_REPAY_LOAN,
   211 	AI_ACTION_REPAY_LOAN,
       
   212 	AI_ACTION_CHECK_ALL_VEHICLES,
   193 };
   213 };
   194 
   214 
   195 // Used for from_type/to_type
   215 // Used for from_type/to_type
   196 enum {
   216 enum {
   197     AI_NO_TYPE = 0,
   217     AI_NO_TYPE = 0,
   198 	AI_CITY,
   218 	AI_CITY,
   199 	AI_INDUSTRY,
   219 	AI_INDUSTRY,
       
   220 };
       
   221 
       
   222 // Flags for in the vehicle
       
   223 enum {
       
   224 	AI_VEHICLEFLAG_SELL = 1,
       
   225 	// Remember, flags must be in power of 2
   200 };
   226 };
   201 
   227 
   202 #define AI_NO_CARGO 0xFF // Means that there is no cargo defined yet (used for industry)
   228 #define AI_NO_CARGO 0xFF // Means that there is no cargo defined yet (used for industry)
   203 #define AI_NEED_CARGO 0xFE // Used when the AI needs to find out a cargo for the route
   229 #define AI_NEED_CARGO 0xFE // Used when the AI needs to find out a cargo for the route
   204 #define AI_STATION_RANGE TILE_XY(TILE_X_MAX, TILE_Y_MAX)
   230 #define AI_STATION_RANGE TILE_XY(TILE_X_MAX, TILE_Y_MAX)
   227 
   253 
   228 // ai_shared.c
   254 // ai_shared.c
   229 int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c);
   255 int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c);
   230 int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c);
   256 int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c);
   231 int AiNew_GetDirection(uint tile_a, uint tile_b);
   257 int AiNew_GetDirection(uint tile_a, uint tile_b);
       
   258 bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
       
   259 uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
   232 
   260 
   233 // ai_build.c
   261 // ai_build.c
   234 bool AiNew_Build_CompanyHQ(Player *p, uint tile);
   262 bool AiNew_Build_CompanyHQ(Player *p, uint tile);
   235 int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag);
   263 int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag);
   236 int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag);
   264 int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag);