ai.h
author bjarni
Sat, 22 Jan 2005 23:11:25 +0000
changeset 1096 ce698f7e4621
parent 1047 d4c04332d837
child 1494 36882c64a497
permissions -rw-r--r--
(svn r1597) fix: autoreplace vehicle lists are now redrawn when a new vehicle becomes available (thanks LordOfThePigs for pointing this one out)
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     1
#ifndef AI_H
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     2
#define AI_H
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     3
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     4
#include "aystar.h"
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     6
/*
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     7
 * These defines can be altered to change the behavoir of the AI
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     8
 *
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     9
 * WARNING:
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    10
 *   This can also alter the AI in a negative way. I will never claim these settings
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    11
 *   are perfect, but don't change them if you don't know what the effect is.
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    12
 */
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
    13
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    14
// How many times it the H multiplied. The higher, the more it will go straight to the
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    15
//   end point. The lower, how more it will find the route with the lowest cost.
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    16
//   also: the lower, the longer it takes before route is calculated..
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    17
#define AI_PATHFINDER_H_MULTIPLER 100
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    18
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    19
// How many loops may AyStar do before it stops
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    20
//   0 = infinite
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    21
#define AI_PATHFINDER_LOOPS_PER_TICK 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    22
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    23
// How long may the AI search for one route?
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    24
//   0 = infinite
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    25
// This number is the number of tiles tested.
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    26
//  It takes (AI_PATHFINDER_MAX_SEARCH_NODES / AI_PATHFINDER_LOOPS_PER_TICK) ticks
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    27
//  to get here.. with 5000 / 10 = 500. 500 / 74 (one day) = 8 days till it aborts
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    28
//   (that is: if the AI is on VERY FAST! :p
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    29
#define AI_PATHFINDER_MAX_SEARCH_NODES 5000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    30
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    31
// If you enable this, the AI is not allowed to make 90degree turns
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    32
#define AI_PATHFINDER_NO_90DEGREES_TURN
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    33
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    34
// Below are defines for the g-calculation
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    35
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    36
// Standard penalty given to a tile
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    37
#define AI_PATHFINDER_PENALTY 150
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    38
// The penalty given to a tile that is going up
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    39
#define AI_PATHFINDER_TILE_GOES_UP_PENALTY 450
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    40
// Changing direction is a penalty, to prevent curved ways (with that: slow ways)
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    41
#define AI_PATHFINDER_DIRECTION_CHANGE_PENALTY 200
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    42
// Same penalty, only for when road already exists
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    43
#define AI_PATHFINDER_DIRECTION_CHANGE_ON_EXISTING_ROAD_PENALTY 50
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    44
// A diagonal track cost the same as a straigh, but a diagonal is faster... so give
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    45
//  a bonus for using diagonal track
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    46
#ifdef AI_PATHFINDER_NO_90DEGREES_TURN
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    47
#define AI_PATHFINDER_DIAGONAL_BONUS 95
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    48
#else
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    49
#define AI_PATHFINDER_DIAGONAL_BONUS 75
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    50
#endif
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    51
// If a roadblock already exists, it gets a bonus
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    52
#define AI_PATHFINDER_ROAD_ALREADY_EXISTS_BONUS 140
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    53
// To prevent 3 direction changes in 3 tiles, this penalty is given in such situation
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    54
#define AI_PATHFINDER_CURVE_PENALTY 200
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    55
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    56
// Penalty a bridge gets per length
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    57
#define AI_PATHFINDER_BRIDGE_PENALTY 180
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    58
// The penalty for a bridge going up
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    59
#define AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY 1000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    60
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    61
// Tunnels are expensive...
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    62
//  Because of that, every tile the cost is increased with 1/8th of his value
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    63
//  This is also true if you are building a tunnel yourself
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    64
#define AI_PATHFINDER_TUNNEL_PENALTY 350
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    65
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    66
/*
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    67
 * Ai_New defines
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    68
 */
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    69
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    70
// How long may we search cities and industry for a new route?
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    71
#define AI_LOCATE_ROUTE_MAX_COUNTER 200
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    72
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    73
// How many days must there be between building the first station and the second station
826
0e2b569b737b (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 165
diff changeset
    74
//  within one city. This number is in days and should be more than 4 months.
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    75
#define AI_CHECKCITY_DATE_BETWEEN 180
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    76
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    77
// How many cargo is needed for one station in a city?
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    78
#define AI_CHECKCITY_CARGO_PER_STATION 60
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    79
// How much cargo must there not be used in a city before we can build a new station?
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    80
#define AI_CHECKCITY_NEEDED_CARGO 50
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    81
// When there is already a station which takes the same good and the rating of that
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    82
//  city is higher then this numer, we are not going to attempt to build anything
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    83
//  there
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    84
#define AI_CHECKCITY_CARGO_RATING 50
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    85
// But, there is a chance of 1 out of this number, that we do ;)
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    86
#define AI_CHECKCITY_CARGO_RATING_CHANCE 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    87
// If a city is too small to contain a station, there is a small chance
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    88
//  that we still do so.. just to make the city bigger!
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    89
#define AI_CHECKCITY_CITY_CHANCE 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    90
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    91
// This number indicates for every unit of cargo, how many tiles two stations maybe be away
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    92
//  from eachother. In other words: if we have 120 units of cargo in one station, and 120 units
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    93
//  of the cargo in the other station, both stations can be 96 units away from eachother, if the
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    94
//  next number is 0.4.
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    95
#define AI_LOCATEROUTE_BUS_CARGO_DISTANCE 0.4
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    96
#define AI_LOCATEROUTE_TRUCK_CARGO_DISTANCE 0.7
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    97
// In whole tiles, the minimum distance for a truck route
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    98
#define AI_LOCATEROUTE_TRUCK_MIN_DISTANCE 30
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    99
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   100
// The amount of tiles in a square from -X to +X that is scanned for a station spot
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   101
//  (so if this number is 10, 20x20 = 400 tiles are scanned for _the_ perfect spot
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   102
// Safe values are between 15 and 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   103
#define AI_FINDSTATION_TILE_RANGE 10
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   104
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   105
// Building on normal speed goes very fast. Idle this amount of ticks between every
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   106
//  building part. It is calculated like this: (4 - competitor_speed) * num + 1
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   107
//  where competitor_speed is between 0 (very slow) to 4 (very fast)
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   108
#define AI_BUILDPATH_PAUSE 10
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   109
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   110
// Minimum % of reliabilty a vehicle has to have before the AI buys it
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   111
#define AI_VEHICLE_MIN_RELIABILTY 60
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   112
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   113
// The minimum amount of money a player should always have
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   114
#define AI_MINIMUM_MONEY 15000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   115
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   116
// If the most cheap route is build, how much is it going to cost..
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   117
// This is to prevent the AI from trying to build a route which can not be paid for
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   118
#define AI_MINIMUM_BUS_ROUTE_MONEY 25000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   119
#define AI_MINIMUM_TRUCK_ROUTE_MONEY 35000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   120
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   121
// The minimum amount of money before we are going to repay any money
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   122
#define AI_MINIMUM_LOAN_REPAY_MONEY 40000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   123
// How many repays do we do if we have enough money to do so?
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   124
//  Every repay is 10000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   125
#define AI_LOAN_REPAY 2
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   126
// How much income must we have before paying back a loan? Month-based (and looked at the last month)
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   127
#define AI_MINIMUM_INCOME_FOR_LOAN 7000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   128
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   129
// If there is <num> time as much cargo in the station then the vehicle can handle
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   130
//  reuse the station instead of building a new one!
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   131
#define AI_STATION_REUSE_MULTIPLER 2
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   132
826
0e2b569b737b (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 165
diff changeset
   133
// No more than this amount of vehicles per station..
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   134
#define AI_CHECK_MAX_VEHICLE_PER_STATION 10
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   135
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   136
// How many thick between building 2 vehicles
165
f81fa8c27236 (svn r166) -Codechange: change 74 for constant DAY_TICKS
darkvater
parents: 145
diff changeset
   137
#define AI_BUILD_VEHICLE_TIME_BETWEEN DAY_TICKS
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   138
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   139
// How many days must there between vehicle checks
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   140
//  The more often, the less non-money-making lines there will be
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   141
//   but the unfair it may seem to a human player
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   142
#define AI_DAYS_BETWEEN_VEHICLE_CHECKS 30
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   143
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   144
// How money profit does a vehicle needs to make to stay in order
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   145
//  This is the profit of this year + profit of last year
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   146
//  But also for vehicles that are just one year old. In other words:
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   147
//   Vehicles of 2 years do easier meet this setting then vehicles
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   148
//   of one year. This is a very good thing. New vehicles are filtered,
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   149
//   while old vehicles stay longer, because we do get less in return.
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   150
#define AI_MINIMUM_ROUTE_PROFIT 1000
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   151
826
0e2b569b737b (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 165
diff changeset
   152
// A vehicle is considered lost when he his cargo is more than 180 days old
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   153
#define AI_VEHICLE_LOST_DAYS 180
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   154
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   155
// How many times may the AI try to find a route before it gives up
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   156
#define AI_MAX_TRIES_FOR_SAME_ROUTE 8
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   157
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   158
/*
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   159
 * End of defines
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   160
 */
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   161
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   162
// This stops 90degrees curves
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   163
static const byte _illegal_curves[6] = {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   164
    255, 255, // Horz and vert, don't have the effect
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   165
    5, // upleft and upright are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   166
    4, // downright and downleft are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   167
    2, // downleft and upleft are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   168
    3, // upright and downright are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   169
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   170
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   171
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   172
    AI_STATE_STARTUP = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   173
    AI_STATE_FIRST_TIME,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   174
    AI_STATE_NOTHING,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   175
    AI_STATE_WAKE_UP,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   176
    AI_STATE_LOCATE_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   177
    AI_STATE_FIND_STATION,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   178
    AI_STATE_FIND_PATH,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   179
    AI_STATE_FIND_DEPOT,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   180
    AI_STATE_VERIFY_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   181
    AI_STATE_BUILD_STATION,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   182
    AI_STATE_BUILD_PATH,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   183
    AI_STATE_BUILD_DEPOT,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   184
    AI_STATE_BUILD_VEHICLE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   185
    AI_STATE_GIVE_ORDERS,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   186
    AI_STATE_START_VEHICLE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   187
    AI_STATE_REPAY_MONEY,
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   188
	AI_STATE_CHECK_ALL_VEHICLES,
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   189
    AI_STATE_ACTION_DONE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   190
    AI_STATE_STOP, // Temporary function to stop the AI
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   191
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   192
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   193
// Used for tbt (train/bus/truck)
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   194
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   195
	AI_TRAIN = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   196
	AI_BUS,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   197
	AI_TRUCK,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   198
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   199
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   200
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   201
	AI_ACTION_NONE = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   202
	AI_ACTION_BUS_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   203
	AI_ACTION_TRUCK_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   204
	AI_ACTION_REPAY_LOAN,
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   205
	AI_ACTION_CHECK_ALL_VEHICLES,
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   206
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   207
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   208
// Used for from_type/to_type
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   209
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   210
    AI_NO_TYPE = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   211
	AI_CITY,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   212
	AI_INDUSTRY,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   213
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   214
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   215
// Flags for in the vehicle
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   216
enum {
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   217
	AI_VEHICLEFLAG_SELL = 1,
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   218
	// Remember, flags must be in power of 2
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   219
};
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   220
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   221
#define AI_NO_CARGO 0xFF // Means that there is no cargo defined yet (used for industry)
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   222
#define AI_NEED_CARGO 0xFE // Used when the AI needs to find out a cargo for the route
856
07dc27d0503e (svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents: 826
diff changeset
   223
#define AI_STATION_RANGE TILE_XY(MapMaxX(), MapMaxY())
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   224
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   225
#define AI_PATHFINDER_NO_DIRECTION (byte)-1
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   226
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   227
// Flags used in user_data
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   228
#define AI_PATHFINDER_FLAG_BRIDGE 1
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   229
#define AI_PATHFINDER_FLAG_TUNNEL 2
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   230
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   231
typedef void AiNew_StateFunction(Player *p);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   232
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   233
// ai_new.c
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   234
void AiNewDoGameLoop(Player *p);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   235
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   236
// ai_pathfinder.c
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   237
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   238
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   239
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   240
// ai_shared.c
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   241
int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   242
int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   243
int AiNew_GetDirection(uint tile_a, uint tile_b);
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   244
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   245
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   246
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   247
// ai_build.c
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   248
bool AiNew_Build_CompanyHQ(Player *p, uint tile);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   249
int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   250
int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   251
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   252
int AiNew_PickVehicle(Player *p);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   253
int AiNew_Build_Vehicle(Player *p, uint tile, byte flag);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   254
int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   255
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   256
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   257
#endif