00001
00002
00003
00004
00005
00006
00007
00008
00009
00017 typedef enum a_game_class {
00018 gc_none,
00019 gc_standard,
00020 gc_time,
00021 gc_advanced
00022 } GameClass;
00023
00025 typedef struct a_ai_op {
00026 char *name;
00027 char *help;
00028 int (*to_test_compat)(void);
00029 void (*to_init)(Side *side);
00030 void (*to_init_turn)(Side *side);
00031 void (*to_decide_plan)(Side *side, Unit *unit);
00032 void (*to_react_to_task_result)(Side *side, Unit *unit,
00033 Task *task, TaskOutcome rslt);
00034 void (*to_react_to_new_side)(Side *side, Side *side2);
00035 int (*to_adjust_plan)(Side *side, Unit *unit);
00036 void (*to_finish_movement)(Side *side);
00037 Obj *(*to_save_state)(Side *side);
00038 int (*region_at)(Side *side, int x, int y);
00039 char *(*at_desig)(Side *side, int x, int y);
00040 } AI_ops;
00041
00042
00043
00044 typedef struct a_ai {
00045 int dummy;
00046 } AI;
00047
00048 #define side_ai_type(s) ((s)->aitype)
00049
00050
00051
00052 #define MAXGOALS 30
00053
00054
00055
00056 #define MAXTHEATERS 98
00057
00058
00059
00060 typedef struct a_strategy {
00061 int trytowin;
00062 int report_not_understood;
00063 int creationdate;
00064 short *strengths[MAXSIDES + 1];
00065 short points[MAXSIDES + 1];
00066 short *alstrengths[MAXSIDES + 1];
00067 short alpoints[MAXSIDES + 1];
00068 short initial_strengths_computed;
00069 short *strengths0[MAXSIDES + 1];
00070 short points0[MAXSIDES + 1];
00071 short *alstrengths0[MAXSIDES + 1];
00072 short alpoints0[MAXSIDES + 1];
00073 short contacted[MAXSIDES+1];
00074 short homefound[MAXSIDES+1];
00075 int analyzegame;
00076 struct a_theater *theaters;
00077 struct a_theater **theatertable;
00078 short numtheaters;
00079 char *areatheaters;
00080 struct a_theater *homefront;
00081 struct a_theater *perimeters[NUMDIRS];
00082 struct a_theater *midranges[NUMDIRS];
00083 struct a_theater *remotes[NUMDIRS];
00084 int numgoals;
00085 struct a_goal *goals[MAXGOALS];
00086
00087 int zonewidth, zoneheight;
00088 int numzonex, numzoney;
00089 int numzones;
00090 struct a_searchzone *searchzones;
00091 short *explorertypes;
00092 short explorersneeded;
00093 short *terrainguess;
00094 short cx, cy;
00095 short *demand;
00096 int explore_priority;
00097 int defend_priority;
00098 int attack_priority;
00099 struct a_unit **unitlist;
00100 short *unitlistcount;
00101 short *actualmix;
00102 short *expectedmix;
00103 short *idealmix;
00104 short *develop_status;
00105 short *develop_on;
00106 Obj *writable_state;
00107 } Strategy;
00108
00109
00110
00111
00112
00113
00114
00115 typedef struct a_theater {
00116 short id;
00117 char *name;
00118 short x, y;
00119 short xmin, ymin;
00120 short xmax, ymax;
00121 int size;
00122 short importance;
00123 Goal *maingoal;
00124 short allied_units;
00125 short makers;
00126 short unexplored;
00127 short allied_bases;
00128 short border;
00129 short reinforce;
00130 short *numassigned;
00131 short *numneeded;
00132 short *numtotransport;
00133 short *numenemies;
00134 short *numsuspected;
00135 short *numsuspectedmax;
00136 int *people;
00137 int enemystrengthmin;
00138 int enemystrengthmax;
00139 short units_lost;
00140 struct a_theater *next;
00141 } Theater;
00142
00143 #define ai(s) ((Strategy *) (s)->ai)
00144
00145 #define strength_est(side,side2,u) ((ai(side)->strengths[side2->id])[u])
00146 #define allied_strength_est(side,side2,u) ((ai(side)->alstrengths[side2->id])[u])
00147 #define strength0_est(side,side2,u) ((ai(side)->strengths0[side2->id])[u])
00148 #define allied_strength0_est(side,side2,u) ((ai(side)->alstrengths0[side2->id])[u])
00149
00150 #define for_all_theaters(s,th) \
00151 for ((th) = ai(s)->theaters; (th) != NULL; (th) = (th)->next) \
00152
00153 #define theater_at(s,x,y) \
00154 (ai(s)->theaters ? ai(s)->theatertable[((int) ai(s)->areatheaters[(x)+area.width*(y)])] : NULL)
00155
00156 #define set_theater_at(s,x,y,th) \
00157 ((ai(s)->areatheaters[(x)+area.width*(y)]) = (th)->id)
00158
00159 #define for_all_cells_in_theater(s,x,y,th) { \
00160 for ((x) = theater->xmin; (x) < theater->xmax; ++(x)) \
00161 for ((y) = theater->ymin; (y) < theater->ymax; ++(y)) \
00162 if (theater_at((s), (x), (y)) == (th)) }
00163
00164 #define unit_theater(unit) ((Theater *) (unit)->aihook)
00165
00166 #define set_unit_theater(unit,theater) ((unit)->aihook = (char *) (theater))
00167
00168
00169
00170 #define RS_DEVELOP_NEEDED 4
00171 #define RS_DEVELOP_ASSIGNED 3
00172 #define RS_UPGRADE_NEEDED 1
00173
00174 struct weightelt {
00175 int weight;
00176 long data;
00177 };
00178
00179 extern GameClass game_class;
00180 extern int bhw_max;
00181
00182
00183
00184 extern void try_to_draw(Side *side, int flag, char *ainame);
00185 extern void give_up(Side *side, char *ainame);
00186 extern int goal_truth(Side *side, Goal *goal);
00187 extern int accelerable(int u);
00188 extern int accelerator(int u1, int u2);
00189 extern GameClass find_game_class(void);
00190 extern void update_unit_plans(Side *side);
00191 extern void update_unit_plans_randomly(Side *side);
00192 extern int need_this_type_to_collect(Side *side, int u, int m);
00193 extern void assign_to_collection(Side *side, Unit *unit, int m);
00194 extern void assign_to_improve(Side *side, Unit *unit);
00195 extern int assign_to_colonize(Side *side, Unit *unit);
00196 extern void assign_to_defend_unit(Unit *unit, Unit *unit2);
00197 extern void assign_to_exploration(Side *side, Unit *unit);
00198 extern void assign_explorer_to_theater(
00199 Side *side, Unit *unit, Theater *theater);
00200 extern void assign_to_explorer_construction(Side *side, Unit *unit);
00201 extern void assign_to_offense(Side *side, Unit *unit);
00202 extern void assign_to_offense_support(Side *side, Unit *unit);
00203 extern void assign_to_colonization_support(Side *side, Unit *unit);
00204 extern void assign_to_defense(Side *side, Unit *unit);
00205 extern void assign_to_defense_support(Side *side, Unit *unit);
00206 extern int preferred_build_type(Side *side, Unit *unit, int plantype);
00207 extern int can_develop_on(int u, int u2);
00208 extern int needs_develop(Side *side, int u);
00209 extern int assign_to_develop_on(Side *side, Unit *unit, int u2);
00210 extern int build_depot_for_self(Unit *unit);
00211 extern int desired_direction_impassable(Unit *unit, int x, int y);
00212 extern int could_be_ferried(Unit *unit, int x, int y);
00213 extern int blocked_by_enemy(Unit *unit, int x, int y, int shortest);
00214 extern int attack_blockage(Side *side, Unit *unit, int x, int y, int shortest);
00215 extern int enemy_close_by(Side *side, Unit *unit, int dist, int *xp, int *yp);
00216 extern int suitable_port(Unit *unit);
00217 extern int need_more_transportation(Side *side);
00218 extern int need_explorers(Side *side);
00219 extern void add_goal(Side *side, Goal *goal);
00220 extern Goal *has_goal(Side *side, GoalType goaltype);
00221 extern Goal *has_unsatisfied_goal(Side *side, GoalType goaltype);
00222
00223 #if 0
00224
00225 extern void assign_to_defend_cell(Unit *unit, int x, int y);
00226 extern void assign_to_defend_vicinity(Unit *unit, int x, int y, int w, int h);
00227 extern void assign_to_defend_theater(Unit *unit, Theater *theater);
00228 extern int build_base_for_self(Side *side, Unit *unit);
00229 extern int build_base_for_others(Side *side, Unit *unit);
00230
00231 #endif