ai_new.h
author tron
Thu, 21 Jul 2005 18:44:27 +0000
changeset 2153 ecfc674410b4
parent 2102 f70ff7bbc69c
child 2186 db48cf29b983
permissions -rw-r--r--
(svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
2102
f70ff7bbc69c (svn r2612) -Fix: corrected headers for ai_new.h
truelight
parents: 2096
diff changeset
     1
#ifndef AI_NEW_H
f70ff7bbc69c (svn r2612) -Fix: corrected headers for ai_new.h
truelight
parents: 2096
diff changeset
     2
#define AI_NEW_H
110
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"
2153
ecfc674410b4 (svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents: 2102
diff changeset
     5
#include "player.h"
110
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
/*
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
     8
 * 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
     9
 *
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    10
 * WARNING:
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    11
 *   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
    12
 *   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
    13
 */
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
    14
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    15
// 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
    16
//   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
    17
//   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
    18
#define AI_PATHFINDER_H_MULTIPLER 100
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    19
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    20
// 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
    21
//   0 = infinite
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    22
#define AI_PATHFINDER_LOOPS_PER_TICK 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    23
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    24
// 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
    25
//   0 = infinite
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    26
// This number is the number of tiles tested.
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    27
//  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
    28
//  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
    29
//   (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
    30
#define AI_PATHFINDER_MAX_SEARCH_NODES 5000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    31
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    32
// 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
    33
#define AI_PATHFINDER_NO_90DEGREES_TURN
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    34
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    35
// Below are defines for the g-calculation
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    36
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    37
// Standard penalty given to a tile
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    38
#define AI_PATHFINDER_PENALTY 150
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    39
// 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
    40
#define AI_PATHFINDER_TILE_GOES_UP_PENALTY 450
1494
31436e59176a (svn r1998) Give penalty 100 to the AI for using foundations (buildonslopes). This prevents it from building long road lines on foundations unless really necessary.
pasky
parents: 1047
diff changeset
    41
// The penalty given to a tile which would have to use fundation
31436e59176a (svn r1998) Give penalty 100 to the AI for using foundations (buildonslopes). This prevents it from building long road lines on foundations unless really necessary.
pasky
parents: 1047
diff changeset
    42
#define AI_PATHFINDER_FOUNDATION_PENALTY 100
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    43
// 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
    44
#define AI_PATHFINDER_DIRECTION_CHANGE_PENALTY 200
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    45
// Same penalty, only for when road already exists
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    46
#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
    47
// 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
    48
//  a bonus for using diagonal track
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    49
#ifdef AI_PATHFINDER_NO_90DEGREES_TURN
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    50
#define AI_PATHFINDER_DIAGONAL_BONUS 95
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    51
#else
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    52
#define AI_PATHFINDER_DIAGONAL_BONUS 75
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    53
#endif
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    54
// 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
    55
#define AI_PATHFINDER_ROAD_ALREADY_EXISTS_BONUS 140
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    56
// 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
    57
#define AI_PATHFINDER_CURVE_PENALTY 200
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    58
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    59
// Penalty a bridge gets per length
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    60
#define AI_PATHFINDER_BRIDGE_PENALTY 180
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    61
// The penalty for a bridge going up
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    62
#define AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY 1000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    63
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    64
// Tunnels are expensive...
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    65
//  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
    66
//  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
    67
#define AI_PATHFINDER_TUNNEL_PENALTY 350
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
 * Ai_New defines
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    71
 */
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 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
    74
#define AI_LOCATE_ROUTE_MAX_COUNTER 200
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    75
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    76
// How many days must there be between building the first station and the second station
826
fff56bbc3606 (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 165
diff changeset
    77
//  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
    78
#define AI_CHECKCITY_DATE_BETWEEN 180
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    79
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    80
// 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
    81
#define AI_CHECKCITY_CARGO_PER_STATION 60
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    82
// 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
    83
#define AI_CHECKCITY_NEEDED_CARGO 50
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    84
// 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
    85
//  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
    86
//  there
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    87
#define AI_CHECKCITY_CARGO_RATING 50
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    88
// 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
    89
#define AI_CHECKCITY_CARGO_RATING_CHANCE 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    90
// 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
    91
//  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
    92
#define AI_CHECKCITY_CITY_CHANCE 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    93
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    94
// 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
    95
//  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
    96
//  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
    97
//  next number is 0.4.
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    98
#define AI_LOCATEROUTE_BUS_CARGO_DISTANCE 0.4
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
    99
#define AI_LOCATEROUTE_TRUCK_CARGO_DISTANCE 0.7
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   100
// 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
   101
#define AI_LOCATEROUTE_TRUCK_MIN_DISTANCE 30
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   102
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   103
// 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
   104
//  (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
   105
// Safe values are between 15 and 5
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   106
#define AI_FINDSTATION_TILE_RANGE 10
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   107
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   108
// 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
   109
//  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
   110
//  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
   111
#define AI_BUILDPATH_PAUSE 10
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
// 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
   114
#define AI_VEHICLE_MIN_RELIABILTY 60
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
// 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
   117
#define AI_MINIMUM_MONEY 15000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   118
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   119
// 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
   120
// 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
   121
#define AI_MINIMUM_BUS_ROUTE_MONEY 25000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   122
#define AI_MINIMUM_TRUCK_ROUTE_MONEY 35000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   123
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   124
// 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
   125
#define AI_MINIMUM_LOAN_REPAY_MONEY 40000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   126
// 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
   127
//  Every repay is 10000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   128
#define AI_LOAN_REPAY 2
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   129
// 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
   130
#define AI_MINIMUM_INCOME_FOR_LOAN 7000
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   131
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   132
// 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
   133
//  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
   134
#define AI_STATION_REUSE_MULTIPLER 2
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   135
826
fff56bbc3606 (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 165
diff changeset
   136
// 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
   137
#define AI_CHECK_MAX_VEHICLE_PER_STATION 10
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   138
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   139
// How many thick between building 2 vehicles
165
f81fa8c27236 (svn r166) -Codechange: change 74 for constant DAY_TICKS
darkvater
parents: 145
diff changeset
   140
#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
   141
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   142
// How many days must there between vehicle checks
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   143
//  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
   144
//   but the unfair it may seem to a human player
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   145
#define AI_DAYS_BETWEEN_VEHICLE_CHECKS 30
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   146
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   147
// 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
   148
//  This is the profit of this year + profit of last year
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   149
//  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
   150
//   Vehicles of 2 years do easier meet this setting then vehicles
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   151
//   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
   152
//   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
   153
#define AI_MINIMUM_ROUTE_PROFIT 1000
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   154
826
fff56bbc3606 (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 165
diff changeset
   155
// 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
   156
#define AI_VEHICLE_LOST_DAYS 180
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   157
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   158
// 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
   159
#define AI_MAX_TRIES_FOR_SAME_ROUTE 8
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   160
110
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
 * End of defines
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   163
 */
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   164
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   165
// This stops 90degrees curves
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   166
static const byte _illegal_curves[6] = {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   167
    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
   168
    5, // upleft and upright are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   169
    4, // downright and downleft are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   170
    2, // downleft and upleft are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   171
    3, // upright and downright are not valid
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   172
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   173
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   174
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   175
    AI_STATE_STARTUP = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   176
    AI_STATE_FIRST_TIME,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   177
    AI_STATE_NOTHING,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   178
    AI_STATE_WAKE_UP,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   179
    AI_STATE_LOCATE_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   180
    AI_STATE_FIND_STATION,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   181
    AI_STATE_FIND_PATH,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   182
    AI_STATE_FIND_DEPOT,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   183
    AI_STATE_VERIFY_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   184
    AI_STATE_BUILD_STATION,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   185
    AI_STATE_BUILD_PATH,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   186
    AI_STATE_BUILD_DEPOT,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   187
    AI_STATE_BUILD_VEHICLE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   188
    AI_STATE_GIVE_ORDERS,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   189
    AI_STATE_START_VEHICLE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   190
    AI_STATE_REPAY_MONEY,
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   191
	AI_STATE_CHECK_ALL_VEHICLES,
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   192
    AI_STATE_ACTION_DONE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   193
    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
   194
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   195
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   196
// Used for tbt (train/bus/truck)
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   197
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   198
	AI_TRAIN = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   199
	AI_BUS,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   200
	AI_TRUCK,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   201
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   202
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   203
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   204
	AI_ACTION_NONE = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   205
	AI_ACTION_BUS_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   206
	AI_ACTION_TRUCK_ROUTE,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   207
	AI_ACTION_REPAY_LOAN,
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   208
	AI_ACTION_CHECK_ALL_VEHICLES,
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   209
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   210
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   211
// Used for from_type/to_type
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   212
enum {
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   213
    AI_NO_TYPE = 0,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   214
	AI_CITY,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   215
	AI_INDUSTRY,
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   216
};
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   217
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   218
// Flags for in the vehicle
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   219
enum {
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   220
	AI_VEHICLEFLAG_SELL = 1,
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   221
	// Remember, flags must be in power of 2
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   222
};
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   223
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   224
#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
   225
#define AI_NEED_CARGO 0xFE // Used when the AI needs to find out a cargo for the route
1981
3c9c682f1212 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
   226
#define AI_STATION_RANGE TileXY(MapMaxX(), MapMaxY())
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   227
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   228
#define AI_PATHFINDER_NO_DIRECTION (byte)-1
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   229
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   230
// Flags used in user_data
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   231
#define AI_PATHFINDER_FLAG_BRIDGE 1
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   232
#define AI_PATHFINDER_FLAG_TUNNEL 2
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   233
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   234
typedef void AiNew_StateFunction(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_new.c
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   237
void AiNewDoGameLoop(Player *p);
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   238
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   239
// ai_pathfinder.c
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   240
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
   241
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
   242
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   243
// ai_shared.c
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   244
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   245
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   246
int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b);
145
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   247
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
6e5468217504 (svn r146) -Fix [AI]: Tunnel/bridge bug
truelight
parents: 110
diff changeset
   248
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   249
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   250
// ai_build.c
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   251
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile);
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   252
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   253
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   254
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
   255
int AiNew_PickVehicle(Player *p);
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   256
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1494
diff changeset
   257
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag);
110
a22a6b07904b (svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents: 84
diff changeset
   258
2102
f70ff7bbc69c (svn r2612) -Fix: corrected headers for ai_new.h
truelight
parents: 2096
diff changeset
   259
#endif /* AI_NEW_H */