home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xconq55.zip / xc5.5 / mplay.h < prev    next >
C/C++ Source or Header  |  1991-06-13  |  6KB  |  163 lines

  1. /* All the definitions needed by the machine code. */
  2.  
  3. /* the non-group */
  4.  
  5. #define NOGROUP 0
  6.  
  7. /* Goals for both groups and individuals. */
  8.  
  9. #define NOGOAL 0
  10. #define DRIFT 1
  11. #define HITTARGET 2
  12. #define CAPTARGET 3
  13. #define BESIEGE 4
  14. #define OCCUPYHEX 5
  15. #define EXPLORE 6
  16. #define DEFEND 7
  17. #define LOAD 8
  18. #define APPROACH 9
  19. #define RELOAD 10
  20. #define FINDTRANS 11
  21.  
  22. /* router flags */
  23.  
  24. #define SAMEPATH 1
  25. #define EXPLORE_PATH 2
  26.  
  27. extern bool delaymove;
  28.  
  29. typedef struct a_area {
  30.   short number;           /* area number */
  31.   short x, y;             /* center of area */
  32.   short allied_units;     /* How many units on our side here. */
  33.   short allied_makers;    /* How many of our makers */
  34.   short neutral_makers;    /* How many of neutral makers */
  35.   short makers;           /* Total number of makers */
  36.   short unexplored;       /* Number of unseem hexes in area. */
  37.   short allied_bases;     /* Total number of our bases, includes towns */
  38.   short border;           /* True if this is a border area. */
  39.   short nearby;           /* Is this close to a location we have bases. */
  40.   short unit_request;     /* Priority on request for units. */
  41.   struct a_unit *units[MAXUTYPES]; /* Units in area */
  42.   short requested_units[MAXUTYPES]; /* units we should move to area. */
  43.   short num_units[MAXUTYPES]; /* units we should move to area. */
  44. } Area;
  45.  
  46. /* values for unit_request */
  47. #define NO_UNITS 0
  48. #define GUARD_BASE 1
  49. #define PATROL_AREA 2
  50. #define EXPLORE_AREA 3
  51. #define DEFEND_AREA 4
  52. #define GUARD_TOWN 6
  53. #define GUARD_BORDER 2
  54. #define GUARD_BORDER_TOWN 10
  55. #define DEFEND_BASE 20
  56. #define DEFEND_TOWN 50
  57.  
  58. /* This structure is where machine sides keep all the plans and planning */
  59. /* related data. */
  60. /* Group 0 is never actually used (a sort of a dummy for various purposes). */
  61.  
  62. typedef struct a_plan {
  63.     short estimate[MAXSIDES][MAXUTYPES];  /* estimated numbers of units */
  64.     short allies[MAXSIDES][MAXUTYPES];  /* strength of other alliances */
  65.     short cx, cy;               /* "centroid" of all our units */
  66.     short lastreplan;           /* last turn we rechecked the plans */
  67.     short demand[MAXUTYPES];    /* worth of each utype w.r.t. strategy */
  68. } Plan;
  69.  
  70. /* Encapsulate some pointer-chasing and casting messiness. */
  71.  
  72. #define side_plan(s) ((Plan *) (s)->plan)
  73.  
  74. /* Malloced integer array accessors and modifers. */
  75.  
  76. #define aref(m,x,y) ((m)[(x)+world.width*(y)])
  77.  
  78. #define aset(m,x,y,v) ((m)[(x)+world.width*(y)] = (v))
  79.  
  80. extern int movetries;
  81.  
  82. extern int unit_count;
  83. extern int explore_priority;
  84. extern int defend_priority;
  85. extern int attack_priority;
  86. extern bool worths_known;
  87.  
  88. extern int evaluate_hex(), maximize_worth();
  89.  
  90. extern char shortbuf[BUFSIZE];         /* buffer for short unit description */
  91.  
  92. /* General collections of numbers used by all machine players. */
  93.  
  94. extern int fraction[MAXTTYPES];        /* percentages of terrain types in world */
  95. extern int unit_hexes[MAXUTYPES];      /* hexes of terrain in world unit can move on */
  96. extern int bw[MAXUTYPES];              /* how much is a unit worth */
  97. extern int bhw[MAXUTYPES][MAXUTYPES];  /* basic worth for hitting */
  98. extern int bcw[MAXUTYPES][MAXUTYPES];  /* basic worth for capturing */
  99. extern int maxoccupant[MAXUTYPES];     /* total capacity of a transport */
  100. extern int ave_build_time[MAXUTYPES];  /* Average length of time to build a unit */
  101. extern int *localworth;                /* for evaluation of nearby hexes */
  102. #ifdef REGIONS
  103. extern short *unit_region[MAXUTYPES];  
  104.      /* Regions a unit within which unit can move */
  105. extern int *unit_region_size[MAXUTYPES];
  106.     /* How many hexes in each region. not necessarily contiguous,
  107.        but decent estimate.  Allows lakes to be spotted. */
  108. extern short num_regions[MAXUTYPES];   /* Number of regions for this unit type */
  109. extern short *units_in_region[MAXUTYPES]; /* Number of units currently in region */
  110. extern long munit_regions;            /* Regions current unit can reach */
  111. #endif
  112. extern Area *area_info;       /* info about areas, shared for all sides */
  113. extern short areas_wide;      /* number of areas in x direction */
  114. extern short areas_high;      /* number of areas in y direction */
  115. #define NUMTOPAREAS 5
  116. extern Area *top_areas[NUMTOPAREAS];       /* Areas requesting the most units. */
  117.  
  118. extern bool can_move_in_dir[NUMDIRS];  /* directions it make sence to try to move in */
  119.  
  120. /* Some basic ranges for prioritizing a units tasks. */
  121. #define EXPLORE_VAL 2500
  122. #define FAVORABLE_COMBAT 5000
  123. #define UNFAVORABLE_COMBAT 4000
  124. #define CAPTURE_MAKER 50000
  125. #define CAPTURE_OTHER 20000
  126. #define PATROL_VAL 100
  127. #define HEAD_FOR_GOAL 2300
  128. #define MEET_TRANSPORT 3000
  129.  
  130. extern int bestworth, bestx, besty;
  131.  
  132. extern Unit *munit;                    /* Unit being decided about */
  133.  
  134. extern Side *mside;                    /* Side whose unit is being decided about */
  135. extern bool base_building;             /* true if base building is possible. */
  136.  
  137. extern int explore_priority, defend_priority, attack_priority;
  138. extern bool worths_known;
  139. extern int route_max_distance;
  140.  
  141. /* in mutil.c */
  142. extern char *unit_desig();
  143. extern int units_nearby();
  144. extern bool survive_to_build_base(), exact_survive_to_build_base();
  145. extern bool base_nearby(), any_base_nearby();
  146. extern bool occupant_can_capture();
  147. extern bool occupant_can_capture_neighbor();
  148. extern bool find_closest_unit(), can_produce(), can_move();
  149. extern int out_of_ammo();
  150. extern int fullness(), survival_time();
  151. extern bool haven_p(), shop_p(), good_haven_p();
  152. extern Mplan *find_route(), *find_route_aux(), *make_plan_for_route();
  153. extern Mplan *make_plan_step();
  154. extern void free_plan();
  155. extern bool follow_plan();
  156. extern int unit_strength();
  157. extern void update_areas();
  158.  
  159. /* in mproduce.c */
  160. extern bool change_machine_product();
  161. extern int machine_product();
  162.  
  163.