1 #ifndef DEFINES_H
2 #define DEFINES_H
3 
4 #include <bitset>
5 #include <string>
6 
7 #include "../AIExport.h"
8 
9 #define MAX_INT   2147483647
10 #define MAX_FLOAT float(MAX_INT)
11 #define EPS 0.0001f
12 
13 #define ERRORVECTOR float3(-1.0f,0.0f,0.0f)
14 #define ZEROVECTOR  float3(0.0f,0.0f,0.0f)
15 
16 /* AI meta data */
17 #define AI_VERSION_NR  aiexport_getVersion()
18 #define AI_NAME        std::string("E323AI")
19 #define AI_VERSION     AI_NAME + " " + AI_VERSION_NR + " - High Templar (" + __DATE__ + ")"
20 #define AI_CREDITS     "Error323 & Simon Logic"
21 #define AI_NOTES       "This A.I. mainly focusses on the XTA and BA mods"
22 
23 /* Folders */
24 #define LOG_FOLDER   "logs/"
25 #define CFG_FOLDER   "configs/"
26 #define CACHE_FOLDER "cache/"
27 
28 /* Templates */
29 #define CONFIG_TEMPLATE "template-config.cfg"
30 
31 /* Misc macro's */
32 #define UD(udid) (ai->cb->GetUnitDef(udid))
33 #define UT(udid) (&(ai->unittable->units[udid]))
34 #define UC(udid) (ai->unittable->units[udid].cats)
35 #define ID(x,z) ((z)*X+(x))
36 #define ID_GRAPH(x,z) ((z)*XX+(x))
37 
38 /* Metal to Energy ratio */
39 #define METAL2ENERGY 60
40 
41 /* Max features for range scan */
42 #define MAX_FEATURES 15
43 
44 /* Max enemies for range scan */
45 #define MAX_ENEMIES 30
46 
47 /* Max enemy units (used by CThreatMap; TODO: avoid) */
48 #define MAX_UNITS_AI 500
49 
50 /* Map ratios */
51 #define FOOTPRINT2REAL 8
52 #define HEIGHT2REAL FOOTPRINT2REAL
53 #define SLOPE2HEIGHT 2
54 #define PATH2SLOPE 8
55 #define PATH2REAL (PATH2SLOPE * SLOPE2HEIGHT * HEIGHT2REAL)
56 
57 /* Max factory Assisters */
58 #define FACTORY_ASSISTERS 6
59 
60 /* Max number of scouts per group */
61 #define MAX_SCOUTS_IN_GROUP 3
62 
63 /* Max number of idle scout groups to prevent building unnecessary scouts */
64 #define MAX_IDLE_SCOUT_GROUPS 3
65 
66 /* Critical number of units per group when regrouping for moving group
67    stalls the game */
68 #define GROUP_CRITICAL_MASS 20
69 
70 /* Max unit weapon range to be considered by threatmap algo (a hack!) */
71 #define MAX_WEAPON_RANGE_FOR_TM 1200.0f
72 
73 /* Max distance at which groups can merge */
74 #define MERGE_DISTANCE 1500.0f
75 
76 /* Number of multiplex iterations */
77 #define MULTIPLEXER 10
78 
79 /* Number of frames a new unit can not accept tasks */
80 #define IDLE_UNIT_TIMEOUT (5*30)
81 
82 #define BAD_TARGET_TIMEOUT (60*30)
83 
84 /* Number of unique tasks allowed to be executed per update */
85 #define MAX_TASKS_PER_UPDATE 3
86 
87 /* Draw time */
88 #define DRAW_TIME MULTIPLEXER*30
89 
90 /* Stats url (NOT used) */
91 #define UPLOAD_URL "http://fhuizing.pythonic.nl/ai-stats.php"
92 
93 /* We gonna use math.h constants */
94 #define _USE_MATH_DEFINES
95 
96 #define MIN_TECHLEVEL 1
97 #define MAX_TECHLEVEL 5
98 
99 #define MAX_CATEGORIES 46
100 
101 typedef std::bitset<MAX_CATEGORIES> unitCategory;
102 
103 const unitCategory
104 	TECH1      (1UL<<0), // hardcored techlevels for now
105 	TECH2      (1UL<<1),
106 	TECH3      (1UL<<2),
107 	TECH4      (1UL<<3),
108 	TECH5      (1UL<<4),
109 
110 	AIR        (1UL<<5), // can fly
111 	SEA        (1UL<<6), // can float
112 	LAND       (1UL<<7), // can walk/drive
113 	SUB        (1UL<<8), // can dive
114 
115 	STATIC     (1UL<<9),
116 	MOBILE     (1UL<<10),
117 
118 	FACTORY    (1UL<<11),
119 	BUILDER    (1UL<<12),
120 	ASSISTER   (1UL<<13),
121 	RESURRECTOR(1UL<<14),
122 
123 	COMMANDER  (1UL<<15),
124 	ATTACKER   (1UL<<16),
125 	ANTIAIR    (1UL<<17),
126 	SCOUTER    (1UL<<18),
127 	ARTILLERY  (1UL<<19),
128 	SNIPER     (1UL<<20),
129 	ASSAULT    (1UL<<21),
130 
131 	MEXTRACTOR (1UL<<22),
132 	MMAKER     (1UL<<23),
133 	EMAKER     (1UL<<24),
134 	MSTORAGE   (1UL<<25),
135 	ESTORAGE   (1UL<<26),
136 
137 	DEFENSE    (1UL<<27),
138 
139 	KBOT       (1UL<<28), // produces kbots
140 	VEHICLE    (1UL<<29), // produces vehicles
141 	HOVER      (1UL<<30), // produces hovercraft
142 	AIRCRAFT   (1UL<<31), // produces aircraft
143 	NAVAL      ('1' + std::string(32, '0')), // produces naval units
144 
145 	JAMMER     ('1' + std::string(33, '0')),
146 	NUKE       ('1' + std::string(34, '0')),
147 	ANTINUKE   ('1' + std::string(35, '0')),
148 	PARALYZER  ('1' + std::string(36, '0')),
149 	TORPEDO	   ('1' + std::string(37, '0')),
150 	TRANSPORT  ('1' + std::string(38, '0')),
151 	EBOOSTER   ('1' + std::string(39, '0')),
152 	MBOOSTER   ('1' + std::string(40, '0')),
153 	SHIELD     ('1' + std::string(41, '0')),
154 	NANOTOWER  ('1' + std::string(42, '0')),
155 	REPAIRPAD  ('1' + std::string(43, '0')),
156 
157 	WIND       ('1' + std::string(44, '0')),
158 	TIDAL      ('1' + std::string(45, '0'));
159 
160 const unitCategory
161 	CATS_ANY     (std::string(MAX_CATEGORIES, '1')),
162 	CATS_ENV     (AIR|LAND|SEA|SUB),
163 	CATS_ECONOMY (FACTORY|BUILDER|ASSISTER|RESURRECTOR|COMMANDER|MEXTRACTOR|MMAKER|EMAKER|MSTORAGE|ESTORAGE|EBOOSTER|MBOOSTER);
164 
165 /* Build tasks */
166 enum buildType {
167 	BUILD_MPROVIDER,
168 	BUILD_EPROVIDER,
169 	BUILD_AA_DEFENSE,
170 	BUILD_AG_DEFENSE,
171 	BUILD_UW_DEFENSE,
172 	BUILD_FACTORY,
173 	BUILD_MSTORAGE,
174 	BUILD_ESTORAGE,
175 	BUILD_MISC_DEFENSE,
176 	BUILD_IMP_DEFENSE
177 };
178 
179 enum difficultyLevel {
180 	DIFFICULTY_EASY = 1,
181 	DIFFICULTY_NORMAL,
182 	DIFFICULTY_HARD
183 };
184 
185 #endif
186