Merge lp:~mxsscott/widelands/carli2-ai-improvements into lp:widelands
- carli2-ai-improvements
- Merge into trunk
Proposed by
Mark Scott
Status: | Rejected |
---|---|
Rejected by: | SirVer |
Proposed branch: | lp:~mxsscott/widelands/carli2-ai-improvements |
Merge into: | lp:widelands |
Diff against target: |
752 lines (+358/-242) 5 files modified
src/ai/ai_help_structs.h (+1/-0) src/ai/defaultai.cc (+351/-242) src/ai/defaultai.h (+4/-0) src/logic/militarysite.h (+1/-0) tribes/barbarians/fernery/conf (+1/-0) |
To merge this branch: | bzr merge lp:~mxsscott/widelands/carli2-ai-improvements |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Needs Fixing | ||
Review via email: mp+142009@code.launchpad.net |
Commit message
Description of the change
(Branch author is carli2: https:/
- Add "demand" to wares
- missing input wares count as demand
- missing soldiers add demand to weapons
- a depth pass filter is applied to demand in order to get stable values
- enhancements are now priorized correctly
gains:
- all three tribes manage to recruit soldiers
- the AI is able to finish its enemy after 90 minutes
- great improvement for AIs economy
To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote : | # |
Setting to rejected because there was no followup - feel free to reopen or discuss more.
Unmerged revisions
- 6478. By carli <https://launchpad.net/~s3734770>
-
AI improvements
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/ai/ai_help_structs.h' | |||
2 | --- src/ai/ai_help_structs.h 2012-09-21 21:36:07 +0000 | |||
3 | +++ src/ai/ai_help_structs.h 2013-01-05 13:44:24 +0000 | |||
4 | @@ -274,6 +274,7 @@ | |||
5 | 274 | uint8_t producers; | 274 | uint8_t producers; |
6 | 275 | uint8_t consumers; | 275 | uint8_t consumers; |
7 | 276 | uint8_t preciousness; | 276 | uint8_t preciousness; |
8 | 277 | float demand; | ||
9 | 277 | }; | 278 | }; |
10 | 278 | 279 | ||
11 | 279 | #endif | 280 | #endif |
12 | 280 | 281 | ||
13 | === modified file 'src/ai/defaultai.cc' | |||
14 | --- src/ai/defaultai.cc 2012-09-21 21:36:07 +0000 | |||
15 | +++ src/ai/defaultai.cc 2013-01-05 13:44:24 +0000 | |||
16 | @@ -30,6 +30,7 @@ | |||
17 | 30 | #include "economy/economy.h" | 30 | #include "economy/economy.h" |
18 | 31 | #include "economy/flag.h" | 31 | #include "economy/flag.h" |
19 | 32 | #include "economy/road.h" | 32 | #include "economy/road.h" |
20 | 33 | #include "economy/wares_queue.h" | ||
21 | 33 | #include "logic/findimmovable.h" | 34 | #include "logic/findimmovable.h" |
22 | 34 | #include "logic/findnode.h" | 35 | #include "logic/findnode.h" |
23 | 35 | #include "log.h" | 36 | #include "log.h" |
24 | @@ -75,7 +76,8 @@ | |||
25 | 75 | next_attack_consideration_due(300000), | 76 | next_attack_consideration_due(300000), |
26 | 76 | inhibit_road_building (0), | 77 | inhibit_road_building (0), |
27 | 77 | time_of_last_construction (0), | 78 | time_of_last_construction (0), |
29 | 78 | numof_warehouses (0) | 79 | numof_warehouses (0), |
30 | 80 | military_demand (0.0) | ||
31 | 79 | {} | 81 | {} |
32 | 80 | 82 | ||
33 | 81 | DefaultAI::~DefaultAI() | 83 | DefaultAI::~DefaultAI() |
34 | @@ -136,6 +138,9 @@ | |||
35 | 136 | // handled by the AI itself. | 138 | // handled by the AI itself. |
36 | 137 | update_all_not_buildable_fields(); | 139 | update_all_not_buildable_fields(); |
37 | 138 | 140 | ||
38 | 141 | // now update the statistics of what we need (wares and military power) | ||
39 | 142 | update_demand(); | ||
40 | 143 | |||
41 | 139 | // IF defaultAI is AGGRESSIVE - we definitely should consider to attack as | 144 | // IF defaultAI is AGGRESSIVE - we definitely should consider to attack as |
42 | 140 | // often as possible. | 145 | // often as possible. |
43 | 141 | if (type == AGGRESSIVE) | 146 | if (type == AGGRESSIVE) |
44 | @@ -234,6 +239,7 @@ | |||
45 | 234 | wares.at(i).producers = 0; | 239 | wares.at(i).producers = 0; |
46 | 235 | wares.at(i).consumers = 0; | 240 | wares.at(i).consumers = 0; |
47 | 236 | wares.at(i).preciousness = tribe->get_ware_descr(i)->preciousness(); | 241 | wares.at(i).preciousness = tribe->get_ware_descr(i)->preciousness(); |
48 | 242 | wares.at(i).demand = 0; | ||
49 | 237 | } | 243 | } |
50 | 238 | 244 | ||
51 | 239 | // collect information about the different buildings our tribe can construct | 245 | // collect information about the different buildings our tribe can construct |
52 | @@ -472,6 +478,85 @@ | |||
53 | 472 | } | 478 | } |
54 | 473 | } | 479 | } |
55 | 474 | 480 | ||
56 | 481 | /*** | ||
57 | 482 | * updates all needs of the economy | ||
58 | 483 | */ | ||
59 | 484 | void DefaultAI::update_demand() | ||
60 | 485 | { | ||
61 | 486 | // military buildings need soldiers: count them! | ||
62 | 487 | for | ||
63 | 488 | (std::list<MilitarySiteObserver>::iterator i = | ||
64 | 489 | militarysites.begin(); | ||
65 | 490 | i != militarysites.end(); | ||
66 | 491 | ++i) | ||
67 | 492 | { | ||
68 | 493 | military_demand += i->site->missingSoldiers(); | ||
69 | 494 | } | ||
70 | 495 | military_demand += 1; // some extra points such that we always get new soldiers | ||
71 | 496 | military_demand *= 0.99; | ||
72 | 497 | military_demand = std::max(military_demand, (type + 2) * (float) 2000.0); // then limit it to some degree. | ||
73 | 498 | // enable logging for debug purpose | ||
74 | 499 | //printf("mil = %f\n", military_demand); | ||
75 | 500 | |||
76 | 501 | // now we know how much military we need, so we | ||
77 | 502 | // need the wares to build the soldiers | ||
78 | 503 | Ware_Index const nr_workers = tribe->get_nrworkers(); | ||
79 | 504 | for (Ware_Index i = Ware_Index::First(); i < nr_workers; ++i) { | ||
80 | 505 | // Find all build costs for soldiers | ||
81 | 506 | // is it a soldier? | ||
82 | 507 | if(tribe->get_worker_descr(i)->get_worker_type() == Worker_Descr::SOLDIER) { | ||
83 | 508 | Worker_Descr::Buildcost::const_iterator end = tribe->get_worker_descr(i)->buildcost().end(); | ||
84 | 509 | for(Worker_Descr::Buildcost::const_iterator it = tribe->get_worker_descr(i)->buildcost().begin(); it != end; ++it) { | ||
85 | 510 | if(tribe->ware_index(it->first)) | ||
86 | 511 | wares.at(tribe->ware_index(it->first)).demand += it->second * military_demand / 100.0; // Add soldier-need priority | ||
87 | 512 | } | ||
88 | 513 | } | ||
89 | 514 | } | ||
90 | 515 | |||
91 | 516 | |||
92 | 517 | // production buildings need inputs | ||
93 | 518 | std::list<ProductionSiteObserver>::const_iterator i = | ||
94 | 519 | productionsites.begin(); | ||
95 | 520 | while(1) | ||
96 | 521 | { | ||
97 | 522 | // iterate through both: production buildings and mines | ||
98 | 523 | if(i == productionsites.end()) | ||
99 | 524 | i = mines.begin(); | ||
100 | 525 | if(i == mines.end()) | ||
101 | 526 | break; | ||
102 | 527 | // count all empty slots | ||
103 | 528 | for | ||
104 | 529 | (ProductionSite::Input_Queues::const_iterator j = | ||
105 | 530 | i->site->warequeues().begin(); | ||
106 | 531 | j != i->site->warequeues().end(); | ||
107 | 532 | j++) | ||
108 | 533 | { | ||
109 | 534 | if((*j)->get_filled() == 0) | ||
110 | 535 | // count queues that are empty | ||
111 | 536 | wares.at((*j)->get_ware()).demand += 1; | ||
112 | 537 | } | ||
113 | 538 | i++; | ||
114 | 539 | } | ||
115 | 540 | |||
116 | 541 | /* TODO: Iterate over all construction sites and add material need | ||
117 | 542 | // Remark: construction materials are also handled by other code, but this | ||
118 | 543 | // code could do it more scalable for big empires | ||
119 | 544 | |||
120 | 545 | Buildcost::const_iterator end = bld.buildcost().end(); | ||
121 | 546 | for(Buildcost::const_iterator it = bld.buildcost().begin(); it != end; ++it) { | ||
122 | 547 | wares.at(it->first).demand += it->second; // Add build-need priority | ||
123 | 548 | }*/ | ||
124 | 549 | |||
125 | 550 | // now decrease the total ammount a bit | ||
126 | 551 | Ware_Index nr_wares = tribe->get_nrwares(); | ||
127 | 552 | for (Ware_Index i = Ware_Index::First(); i < nr_wares; ++i) | ||
128 | 553 | { | ||
129 | 554 | wares.at(i).demand *= 0.99; | ||
130 | 555 | // enable logging for debug purpose | ||
131 | 556 | //printf("ware %s: %f\n", tribe->get_ware_descr(i)->name().c_str(), wares.at(i).demand); | ||
132 | 557 | } | ||
133 | 558 | } | ||
134 | 559 | |||
135 | 475 | 560 | ||
136 | 476 | /// Updates one buildable field | 561 | /// Updates one buildable field |
137 | 477 | void DefaultAI::update_buildable_field | 562 | void DefaultAI::update_buildable_field |
138 | @@ -860,245 +945,7 @@ | |||
139 | 860 | if (bo.desc->get_size() > maxsize) | 945 | if (bo.desc->get_size() > maxsize) |
140 | 861 | continue; | 946 | continue; |
141 | 862 | 947 | ||
381 | 863 | int32_t prio = 0; | 948 | int32_t prio = calculate_building_prio(bo, bf, expand_factor); |
143 | 864 | |||
144 | 865 | if (bo.type == BuildingObserver::PRODUCTIONSITE) { | ||
145 | 866 | // Don't build another building of this type, if there is already | ||
146 | 867 | // one that is unoccupied at the moment | ||
147 | 868 | if (bo.unoccupied) | ||
148 | 869 | continue; | ||
149 | 870 | if (bo.need_trees) { | ||
150 | 871 | // Priority of woodcutters depend on the number of near trees | ||
151 | 872 | prio += bf->trees_nearby * 3; | ||
152 | 873 | prio /= 3 * (1 + bf->producers_nearby.at(bo.outputs.at(0))); | ||
153 | 874 | |||
154 | 875 | // TODO improve this - it's still useless to place lumberjack huts randomly | ||
155 | 876 | /*if (prio <= 0) // no, sometimes we need wood without having a forest | ||
156 | 877 | continue;*/ | ||
157 | 878 | |||
158 | 879 | // Check if the produced wares are needed | ||
159 | 880 | Ware_Index wt(static_cast<size_t>(bo.outputs.at(0))); | ||
160 | 881 | container_iterate(std::list<EconomyObserver *>, economies, l) { | ||
161 | 882 | // Don't check if the economy has no warehouse. | ||
162 | 883 | if ((*l.current)->economy.warehouses().empty()) | ||
163 | 884 | continue; | ||
164 | 885 | if ((*l.current)->economy.needs_ware(wt)) | ||
165 | 886 | prio += 1 + wares.at(bo.outputs.at(0)).preciousness; | ||
166 | 887 | } | ||
167 | 888 | |||
168 | 889 | if (bo.total_count() < 2) { | ||
169 | 890 | prio *= 6; // big bonus for the basics | ||
170 | 891 | if (bo.total_count() == 0) | ||
171 | 892 | prio *= 4; // even more for the absolute basics | ||
172 | 893 | } | ||
173 | 894 | } else if (bo.need_stones) { | ||
174 | 895 | // Priority of quarries depend on the number of near stones | ||
175 | 896 | prio += bf->stones_nearby * 3; | ||
176 | 897 | prio /= 3 * (1 + bf->producers_nearby.at(bo.outputs.at(0))); | ||
177 | 898 | if (bo.total_count() < 2) { | ||
178 | 899 | prio *= 6; // big bonus for the basics | ||
179 | 900 | if (bo.total_count() == 0) | ||
180 | 901 | prio *= 4; // even more for the absolute basics | ||
181 | 902 | } | ||
182 | 903 | } else if (bo.production_hint >= 0) { | ||
183 | 904 | // production hint (f.e. associate forester with trunks) | ||
184 | 905 | |||
185 | 906 | // Calculate the need for this building | ||
186 | 907 | int16_t inout = wares.at(bo.production_hint).consumers; | ||
187 | 908 | if | ||
188 | 909 | (tribe->safe_ware_index("trunk").value() | ||
189 | 910 | == | ||
190 | 911 | bo.production_hint) | ||
191 | 912 | inout += total_constructionsites / 4; | ||
192 | 913 | inout -= wares.at(bo.production_hint).producers; | ||
193 | 914 | if (inout < 1) | ||
194 | 915 | inout = 1; | ||
195 | 916 | // the ware they're refreshing | ||
196 | 917 | Ware_Index wt(static_cast<size_t>(bo.production_hint)); | ||
197 | 918 | container_iterate(std::list<EconomyObserver *>, economies, l) { | ||
198 | 919 | // Don't check if the economy has no warehouse. | ||
199 | 920 | if ((*l.current)->economy.warehouses().empty()) | ||
200 | 921 | continue; | ||
201 | 922 | if ((*l.current)->economy.needs_ware(wt)) { | ||
202 | 923 | prio += wares.at(bo.production_hint).preciousness * inout * 2; | ||
203 | 924 | break; | ||
204 | 925 | } | ||
205 | 926 | } | ||
206 | 927 | |||
207 | 928 | // Do not build too many of these buildings, but still care | ||
208 | 929 | // to build at least two. | ||
209 | 930 | // And add bonus near buildings outputting production_hint ware. | ||
210 | 931 | prio += (5 * bf->producers_nearby.at(bo.production_hint)) / 2; | ||
211 | 932 | prio -= bo.total_count() * 2; | ||
212 | 933 | prio /= bo.total_count() + 1; | ||
213 | 934 | prio += (bf->producers_nearby.at(bo.production_hint) - 1) * 5; | ||
214 | 935 | if (bo.total_count() > 2) | ||
215 | 936 | prio -= bo.total_count(); | ||
216 | 937 | else { | ||
217 | 938 | prio += wares.at(bo.production_hint).preciousness; | ||
218 | 939 | prio *= 3; | ||
219 | 940 | } | ||
220 | 941 | if (prio < 0) | ||
221 | 942 | continue; | ||
222 | 943 | } else if (bo.recruitment) { | ||
223 | 944 | // "recruitment centeres" like the donkey farm should be build up | ||
224 | 945 | // as soon as a basic infrastructure was completed. | ||
225 | 946 | // and of course the defaultAI should think of further | ||
226 | 947 | // constructions of that type later in game. | ||
227 | 948 | prio -= 12; // start calculation with an offset | ||
228 | 949 | prio += productionsites.size() + mines.size(); | ||
229 | 950 | prio -= (bo.total_count()) * 40; | ||
230 | 951 | prio *= 2; | ||
231 | 952 | |||
232 | 953 | // take care about borders and enemies | ||
233 | 954 | prio = recalc_with_border_range(*bf, prio); | ||
234 | 955 | } else { // "normal" productionsites | ||
235 | 956 | |||
236 | 957 | // ToDo: prefer soldier producing things | ||
237 | 958 | // Ware_Index const soldier_index = tribe().worker_index("soldier"); | ||
238 | 959 | |||
239 | 960 | if (bo.is_basic && (bo.total_count() == 0)) | ||
240 | 961 | prio += 100; // for very important buildings | ||
241 | 962 | |||
242 | 963 | // Check if the produced wares are needed | ||
243 | 964 | container_iterate(std::list<EconomyObserver *>, economies, l) { | ||
244 | 965 | // Don't check if the economy has no warehouse. | ||
245 | 966 | if ((*l.current)->economy.warehouses().empty()) | ||
246 | 967 | continue; | ||
247 | 968 | for (uint32_t m = 0; m < bo.outputs.size(); ++m) { | ||
248 | 969 | Ware_Index wt(static_cast<size_t>(bo.outputs.at(m))); | ||
249 | 970 | |||
250 | 971 | // if we have too much of it (avoids mass storage) | ||
251 | 972 | if | ||
252 | 973 | ((*l.current)->economy.stock_ware(wt) > 6 * | ||
253 | 974 | (*l.current)->economy.ware_target_quantity(wt).permanent) | ||
254 | 975 | prio -= 20; | ||
255 | 976 | |||
256 | 977 | // if the economy needs this ware | ||
257 | 978 | if ((*l.current)->economy.needs_ware(wt)) { | ||
258 | 979 | prio += 1 + wares.at(bo.outputs.at(m)).preciousness; | ||
259 | 980 | if (bo.total_count() == 0) | ||
260 | 981 | // big bonus, this site might be elemental | ||
261 | 982 | prio += 3 * wares.at(bo.outputs.at(m)).preciousness; | ||
262 | 983 | } | ||
263 | 984 | |||
264 | 985 | // we can enhance this building. build more | ||
265 | 986 | // maybe the enhancement can produce needed ware | ||
266 | 987 | if (bo.desc->enhancements().size() > 0) { | ||
267 | 988 | // this code builds more metalworks | ||
268 | 989 | if (bo.total_count() == 0) | ||
269 | 990 | prio += 2; | ||
270 | 991 | if (bo.total_count() == 1) | ||
271 | 992 | prio += 8; | ||
272 | 993 | } | ||
273 | 994 | } | ||
274 | 995 | for (uint32_t m = 0; m < bo.inputs.size(); ++m) { | ||
275 | 996 | Ware_Index wt(static_cast<size_t>(bo.inputs.at(m))); | ||
276 | 997 | |||
277 | 998 | // if the economies don't need it: "waste" it | ||
278 | 999 | if (!(*l.current)->economy.needs_ware(wt)) { | ||
279 | 1000 | if (bo.total_count() == 0 && bo.prod_build_material) | ||
280 | 1001 | // big bonus, this site might be elemental | ||
281 | 1002 | prio += 3 * wares.at(bo.inputs.at(m)).preciousness; | ||
282 | 1003 | } | ||
283 | 1004 | } | ||
284 | 1005 | } | ||
285 | 1006 | |||
286 | 1007 | // If the produced wares are needed | ||
287 | 1008 | if (prio > 0) { | ||
288 | 1009 | int32_t inout_prio = 0; | ||
289 | 1010 | for (size_t k = 0; k < bo.inputs.size(); ++k) { | ||
290 | 1011 | inout_prio += bf->producers_nearby.at(bo.inputs.at(k)); | ||
291 | 1012 | inout_prio -= bf->consumers_nearby.at(bo.inputs.at(k)) / 2; | ||
292 | 1013 | } | ||
293 | 1014 | for (size_t k = 0; k < bo.outputs.size(); ++k) | ||
294 | 1015 | inout_prio += bf->consumers_nearby.at(bo.outputs.at(k)); | ||
295 | 1016 | prio += 2 * inout_prio; | ||
296 | 1017 | prio = calculate_need_for_ps(bo, prio); | ||
297 | 1018 | } else | ||
298 | 1019 | continue; | ||
299 | 1020 | |||
300 | 1021 | // take care about borders and enemies | ||
301 | 1022 | prio = recalc_with_border_range(*bf, prio); | ||
302 | 1023 | |||
303 | 1024 | // do not construct more than one building, | ||
304 | 1025 | // if supply line is already broken. | ||
305 | 1026 | if (!check_supply(bo) && bo.total_count() > 0) | ||
306 | 1027 | prio -= 12; | ||
307 | 1028 | |||
308 | 1029 | } | ||
309 | 1030 | } else if (bo.type == BuildingObserver::MILITARYSITE) { | ||
310 | 1031 | if (!bf->unowned_land_nearby) | ||
311 | 1032 | continue; | ||
312 | 1033 | prio = bf->unowned_land_nearby * (1 + type); | ||
313 | 1034 | prio -= bf->military_influence * (5 - type); | ||
314 | 1035 | // set to at least 1 | ||
315 | 1036 | prio = prio > 0 ? prio : 1; | ||
316 | 1037 | prio *= expand_factor; | ||
317 | 1038 | prio /= 2; | ||
318 | 1039 | |||
319 | 1040 | if (bf->enemy_nearby) | ||
320 | 1041 | prio *= 2; | ||
321 | 1042 | else | ||
322 | 1043 | prio -= bf->military_influence * 2; | ||
323 | 1044 | |||
324 | 1045 | if (bf->avoid_military) | ||
325 | 1046 | prio /= 5; | ||
326 | 1047 | |||
327 | 1048 | prio -= militarysites.size() - productionsites.size() / (3 - type); | ||
328 | 1049 | |||
329 | 1050 | } else if (bo.type == BuildingObserver::WAREHOUSE) { | ||
330 | 1051 | // Build one warehouse for ~every 35 productionsites and mines. | ||
331 | 1052 | // Militarysites are slightly important as well, to have a bigger | ||
332 | 1053 | // chance for a warehouses (containing waiting soldiers or wares | ||
333 | 1054 | // needed for soldier training) near the frontier. | ||
334 | 1055 | prio += productionsites.size() + mines.size(); | ||
335 | 1056 | prio += militarysites.size() / 3; | ||
336 | 1057 | prio -= (bo.cnt_under_construction + numof_warehouses) * 35; | ||
337 | 1058 | prio *= 2; | ||
338 | 1059 | |||
339 | 1060 | // take care about borders and enemies | ||
340 | 1061 | prio = recalc_with_border_range(*bf, prio); | ||
341 | 1062 | |||
342 | 1063 | } else if (bo.type == BuildingObserver::TRAININGSITE) { | ||
343 | 1064 | // Start building trainingsites when there are already more than 50 | ||
344 | 1065 | // other buildings. That should be enough for a working economy. | ||
345 | 1066 | // On the other hand only build more trainingsites of the same | ||
346 | 1067 | // type if the economy is really big. | ||
347 | 1068 | prio += productionsites.size() + militarysites.size(); | ||
348 | 1069 | prio += mines.size(); | ||
349 | 1070 | prio += type * 10; // +0 / +10 / +20 for DEFF/NORM/AGGR | ||
350 | 1071 | prio = prio / (bo.total_count() + 1); | ||
351 | 1072 | prio -= (bo.total_count() + 1) * 70; | ||
352 | 1073 | |||
353 | 1074 | // take care about borders and enemies | ||
354 | 1075 | prio = recalc_with_border_range(*bf, prio); | ||
355 | 1076 | } | ||
356 | 1077 | |||
357 | 1078 | // avoid to have too many construction sites | ||
358 | 1079 | // but still enable the player to build up basic productionsites | ||
359 | 1080 | if | ||
360 | 1081 | (bo.type != BuildingObserver::PRODUCTIONSITE || | ||
361 | 1082 | !bo.is_basic || bo.total_count() > 0) | ||
362 | 1083 | prio /= | ||
363 | 1084 | 1 + bo.cnt_under_construction * (bo.cnt_under_construction + 1); | ||
364 | 1085 | |||
365 | 1086 | // add big penalty if water is needed, but is not near | ||
366 | 1087 | if (bo.need_water) { | ||
367 | 1088 | if (bf->water_nearby < 3) | ||
368 | 1089 | continue; | ||
369 | 1090 | int effect = bf->water_nearby - 8; | ||
370 | 1091 | prio += | ||
371 | 1092 | effect > 0 ? | ||
372 | 1093 | static_cast<int>(sqrt(static_cast<double>(effect))) : effect; | ||
373 | 1094 | // if same producers are nearby, then give some penalty | ||
374 | 1095 | for (size_t k = 0; k < bo.outputs.size(); ++k) | ||
375 | 1096 | if (bf->producers_nearby.at(bo.outputs.at(k)) > 0) | ||
376 | 1097 | prio -= 3; | ||
377 | 1098 | } | ||
378 | 1099 | |||
379 | 1100 | // think of space consuming buildings nearby like farms or vineyards | ||
380 | 1101 | prio /= 1 + bf->space_consumers_nearby; | ||
382 | 1102 | 949 | ||
383 | 1103 | // Stop here, if priority is 0 or less. | 950 | // Stop here, if priority is 0 or less. |
384 | 1104 | if (prio <= 0) | 951 | if (prio <= 0) |
385 | @@ -1199,6 +1046,7 @@ | |||
386 | 1199 | uint32_t ioprio = 0; | 1046 | uint32_t ioprio = 0; |
387 | 1200 | for (uint32_t m = 0; m < bo.outputs.size(); ++m) { | 1047 | for (uint32_t m = 0; m < bo.outputs.size(); ++m) { |
388 | 1201 | ioprio += 5 * wares.at(bo.outputs.at(m)).preciousness; | 1048 | ioprio += 5 * wares.at(bo.outputs.at(m)).preciousness; |
389 | 1049 | ioprio += round(wares.at(bo.outputs.at(m)).demand / 100.0); | ||
390 | 1202 | } | 1050 | } |
391 | 1203 | 1051 | ||
392 | 1204 | // tribes that have enhanceable mines should build more mines | 1052 | // tribes that have enhanceable mines should build more mines |
393 | @@ -1214,7 +1062,7 @@ | |||
394 | 1214 | // multiply with current statistics of all other buildings of this | 1062 | // multiply with current statistics of all other buildings of this |
395 | 1215 | // type to avoid constructing buildings where already some are running | 1063 | // type to avoid constructing buildings where already some are running |
396 | 1216 | // on low resources. | 1064 | // on low resources. |
398 | 1217 | prio *= 5 + bo.current_stats; | 1065 | prio *= 45 + bo.current_stats; |
399 | 1218 | prio /= 100; | 1066 | prio /= 100; |
400 | 1219 | 1067 | ||
401 | 1220 | if (onlymissing) // mines aren't *that* important | 1068 | if (onlymissing) // mines aren't *that* important |
402 | @@ -1252,6 +1100,262 @@ | |||
403 | 1252 | return true; | 1100 | return true; |
404 | 1253 | } | 1101 | } |
405 | 1254 | 1102 | ||
406 | 1103 | int32_t DefaultAI::calculate_building_prio(BuildingObserver & bo, BuildableField * const bf, uint32_t expand_factor) | ||
407 | 1104 | { | ||
408 | 1105 | int32_t prio = 0; | ||
409 | 1106 | |||
410 | 1107 | if (bo.type == BuildingObserver::PRODUCTIONSITE) { | ||
411 | 1108 | // Don't build another building of this type, if there is already | ||
412 | 1109 | // one that is unoccupied at the moment | ||
413 | 1110 | if (bo.unoccupied) | ||
414 | 1111 | return -1; | ||
415 | 1112 | if (bo.need_trees) { | ||
416 | 1113 | // Priority of woodcutters depend on the number of near trees | ||
417 | 1114 | prio += bf->trees_nearby * 3; | ||
418 | 1115 | prio /= 3 * (1 + bf->producers_nearby.at(bo.outputs.at(0))); | ||
419 | 1116 | |||
420 | 1117 | // TODO improve this - it's still useless to place lumberjack huts randomly | ||
421 | 1118 | /*if (prio <= 0) // no, sometimes we need wood without having a forest | ||
422 | 1119 | return -1;*/ | ||
423 | 1120 | |||
424 | 1121 | // Check if the produced wares are needed | ||
425 | 1122 | Ware_Index wt(static_cast<size_t>(bo.outputs.at(0))); | ||
426 | 1123 | container_iterate(std::list<EconomyObserver *>, economies, l) { | ||
427 | 1124 | // Don't check if the economy has no warehouse. | ||
428 | 1125 | if ((*l.current)->economy.warehouses().empty()) | ||
429 | 1126 | continue; | ||
430 | 1127 | if ((*l.current)->economy.needs_ware(wt)) | ||
431 | 1128 | prio += 1 + wares.at(bo.outputs.at(0)).preciousness; | ||
432 | 1129 | } | ||
433 | 1130 | |||
434 | 1131 | if (bo.total_count() < 2) { | ||
435 | 1132 | prio *= 6; // big bonus for the basics | ||
436 | 1133 | if (bo.total_count() == 0) | ||
437 | 1134 | prio *= 4; // even more for the absolute basics | ||
438 | 1135 | } | ||
439 | 1136 | } else if (bo.need_stones) { | ||
440 | 1137 | // Priority of quarries depend on the number of near stones | ||
441 | 1138 | prio += bf->stones_nearby * 3; | ||
442 | 1139 | prio /= 3 * (1 + bf->producers_nearby.at(bo.outputs.at(0))); | ||
443 | 1140 | if (bo.total_count() < 2) { | ||
444 | 1141 | prio *= 6; // big bonus for the basics | ||
445 | 1142 | if (bo.total_count() == 0) | ||
446 | 1143 | prio *= 4; // even more for the absolute basics | ||
447 | 1144 | } | ||
448 | 1145 | } else if (bo.production_hint >= 0) { | ||
449 | 1146 | // production hint (f.e. associate forester with trunks) | ||
450 | 1147 | |||
451 | 1148 | // Calculate the need for this building | ||
452 | 1149 | int16_t inout = wares.at(bo.production_hint).consumers; | ||
453 | 1150 | if | ||
454 | 1151 | (tribe->safe_ware_index("trunk").value() | ||
455 | 1152 | == | ||
456 | 1153 | bo.production_hint) | ||
457 | 1154 | inout += total_constructionsites / 4; | ||
458 | 1155 | inout -= wares.at(bo.production_hint).producers; | ||
459 | 1156 | if (inout < 1) | ||
460 | 1157 | inout = 1; | ||
461 | 1158 | // the ware they're refreshing | ||
462 | 1159 | Ware_Index wt(static_cast<size_t>(bo.production_hint)); | ||
463 | 1160 | container_iterate(std::list<EconomyObserver *>, economies, l) { | ||
464 | 1161 | // Don't check if the economy has no warehouse. | ||
465 | 1162 | if ((*l.current)->economy.warehouses().empty()) | ||
466 | 1163 | continue; | ||
467 | 1164 | if ((*l.current)->economy.needs_ware(wt)) { | ||
468 | 1165 | prio += wares.at(bo.production_hint).preciousness * inout * 2; | ||
469 | 1166 | break; | ||
470 | 1167 | } | ||
471 | 1168 | } | ||
472 | 1169 | |||
473 | 1170 | // Do not build too many of these buildings, but still care | ||
474 | 1171 | // to build at least two. | ||
475 | 1172 | // And add bonus near buildings outputting production_hint ware. | ||
476 | 1173 | prio += (5 * bf->producers_nearby.at(bo.production_hint)) / 2; | ||
477 | 1174 | prio -= bo.total_count() * 2; | ||
478 | 1175 | prio /= bo.total_count() + 1; | ||
479 | 1176 | prio += (bf->producers_nearby.at(bo.production_hint) - 1) * 5; | ||
480 | 1177 | if (bo.total_count() > 2) | ||
481 | 1178 | prio -= bo.total_count(); | ||
482 | 1179 | else { | ||
483 | 1180 | prio += wares.at(bo.production_hint).preciousness; | ||
484 | 1181 | prio *= 3; | ||
485 | 1182 | } | ||
486 | 1183 | if (prio < 0) | ||
487 | 1184 | return -1; | ||
488 | 1185 | } else if (bo.recruitment) { | ||
489 | 1186 | // "recruitment centeres" like the donkey farm should be build up | ||
490 | 1187 | // as soon as a basic infrastructure was completed. | ||
491 | 1188 | // and of course the defaultAI should think of further | ||
492 | 1189 | // constructions of that type later in game. | ||
493 | 1190 | prio -= 12; // start calculation with an offset | ||
494 | 1191 | prio += productionsites.size() + mines.size(); | ||
495 | 1192 | prio -= (bo.total_count()) * 40; | ||
496 | 1193 | prio *= 2; | ||
497 | 1194 | |||
498 | 1195 | // take care about borders and enemies | ||
499 | 1196 | prio = recalc_with_border_range(*bf, prio); | ||
500 | 1197 | } else { // "normal" productionsites | ||
501 | 1198 | |||
502 | 1199 | if (bo.is_basic && (bo.total_count() == 0)) | ||
503 | 1200 | prio += 100; // for very important buildings | ||
504 | 1201 | |||
505 | 1202 | // we can enhance this building. build more | ||
506 | 1203 | // maybe the enhancement can produce needed ware | ||
507 | 1204 | // TODO: rather plan an enhanced building from bottom up | ||
508 | 1205 | for (std::set<Building_Index>::const_iterator enhancement = | ||
509 | 1206 | bo.desc->enhancements().begin(); | ||
510 | 1207 | enhancement != bo.desc->enhancements().end(); | ||
511 | 1208 | enhancement++) { | ||
512 | 1209 | // when we build a, we can build b, too... | ||
513 | 1210 | BuildingObserver & bo2 = buildings[*enhancement]; | ||
514 | 1211 | // so simply add the score of the building behind it... | ||
515 | 1212 | uint32_t prio2 = calculate_building_prio(bo2, bf, expand_factor); | ||
516 | 1213 | if (prio2 * (1 + bo.total_count()) > prio * (1 + bo2.total_count())) | ||
517 | 1214 | prio = prio / 2 + prio2; // we want to build the enhanced building instead of this | ||
518 | 1215 | } | ||
519 | 1216 | |||
520 | 1217 | |||
521 | 1218 | // Check if the produced wares are needed | ||
522 | 1219 | container_iterate(std::list<EconomyObserver *>, economies, l) { | ||
523 | 1220 | // Don't check if the economy has no warehouse. | ||
524 | 1221 | if ((*l.current)->economy.warehouses().empty()) | ||
525 | 1222 | continue; | ||
526 | 1223 | for (uint32_t m = 0; m < bo.outputs.size(); ++m) { | ||
527 | 1224 | Ware_Index wt(static_cast<size_t>(bo.outputs.at(m))); | ||
528 | 1225 | |||
529 | 1226 | // Our main instinct: what we actually need | ||
530 | 1227 | // for military, production and construction | ||
531 | 1228 | prio += round(wares.at(bo.outputs.at(m)).demand / 50.0); | ||
532 | 1229 | |||
533 | 1230 | // if we have too much of it (avoids mass storage) | ||
534 | 1231 | if | ||
535 | 1232 | ((*l.current)->economy.stock_ware(wt) > 6 * | ||
536 | 1233 | (*l.current)->economy.ware_target_quantity(wt).permanent) | ||
537 | 1234 | prio -= 20; | ||
538 | 1235 | |||
539 | 1236 | // if the economy needs this ware | ||
540 | 1237 | if ((*l.current)->economy.needs_ware(wt)) { | ||
541 | 1238 | prio += 1 + wares.at(bo.outputs.at(m)).preciousness; | ||
542 | 1239 | if (bo.total_count() == 0) | ||
543 | 1240 | // big bonus, this site might be elemental | ||
544 | 1241 | prio += 3 * wares.at(bo.outputs.at(m)).preciousness; | ||
545 | 1242 | } | ||
546 | 1243 | } | ||
547 | 1244 | for (uint32_t m = 0; m < bo.inputs.size(); ++m) { | ||
548 | 1245 | Ware_Index wt(static_cast<size_t>(bo.inputs.at(m))); | ||
549 | 1246 | |||
550 | 1247 | // Wares that are needed should not be consumed too much | ||
551 | 1248 | prio -= round(wares.at(wt).demand / 100.0); | ||
552 | 1249 | |||
553 | 1250 | // if the economies don't need it: "waste" it | ||
554 | 1251 | if (!(*l.current)->economy.needs_ware(wt)) { | ||
555 | 1252 | prio++; | ||
556 | 1253 | if (bo.total_count() == 0 && bo.prod_build_material) | ||
557 | 1254 | // big bonus, this site might be elemental | ||
558 | 1255 | prio += 3 * wares.at(bo.inputs.at(m)).preciousness; | ||
559 | 1256 | } | ||
560 | 1257 | } | ||
561 | 1258 | } | ||
562 | 1259 | |||
563 | 1260 | // If the produced wares are needed | ||
564 | 1261 | if (prio > 0) { | ||
565 | 1262 | int32_t inout_prio = 0; | ||
566 | 1263 | for (size_t k = 0; k < bo.inputs.size(); ++k) { | ||
567 | 1264 | inout_prio += bf->producers_nearby.at(bo.inputs.at(k)); | ||
568 | 1265 | inout_prio -= bf->consumers_nearby.at(bo.inputs.at(k)) / 2; | ||
569 | 1266 | } | ||
570 | 1267 | for (size_t k = 0; k < bo.outputs.size(); ++k) | ||
571 | 1268 | inout_prio += bf->consumers_nearby.at(bo.outputs.at(k)); | ||
572 | 1269 | prio += 2 * inout_prio; | ||
573 | 1270 | prio = calculate_need_for_ps(bo, prio); | ||
574 | 1271 | } else | ||
575 | 1272 | return -1; | ||
576 | 1273 | |||
577 | 1274 | // take care about borders and enemies | ||
578 | 1275 | prio = recalc_with_border_range(*bf, prio); | ||
579 | 1276 | |||
580 | 1277 | // do not construct more than one building, | ||
581 | 1278 | // if supply line is already broken. | ||
582 | 1279 | if (!check_supply(bo) && bo.total_count() > 0) | ||
583 | 1280 | prio -= 12; | ||
584 | 1281 | |||
585 | 1282 | } | ||
586 | 1283 | } else if (bo.type == BuildingObserver::MILITARYSITE) { | ||
587 | 1284 | if (!bf->unowned_land_nearby) | ||
588 | 1285 | return -1; | ||
589 | 1286 | prio = bf->unowned_land_nearby * (1 + type); | ||
590 | 1287 | prio -= bf->military_influence * (5 - type); | ||
591 | 1288 | // set to at least 1 | ||
592 | 1289 | prio = prio > 0 ? prio : 1; | ||
593 | 1290 | prio *= expand_factor; | ||
594 | 1291 | prio /= 2; | ||
595 | 1292 | |||
596 | 1293 | if (bf->enemy_nearby) | ||
597 | 1294 | prio *= 2; | ||
598 | 1295 | else | ||
599 | 1296 | prio -= bf->military_influence * 2; | ||
600 | 1297 | |||
601 | 1298 | if (bf->avoid_military) | ||
602 | 1299 | prio /= 5; | ||
603 | 1300 | |||
604 | 1301 | prio -= militarysites.size() - productionsites.size() / (3 - type); | ||
605 | 1302 | |||
606 | 1303 | } else if (bo.type == BuildingObserver::WAREHOUSE) { | ||
607 | 1304 | // Build one warehouse for ~every 35 productionsites and mines. | ||
608 | 1305 | // Militarysites are slightly important as well, to have a bigger | ||
609 | 1306 | // chance for a warehouses (containing waiting soldiers or wares | ||
610 | 1307 | // needed for soldier training) near the frontier. | ||
611 | 1308 | prio += productionsites.size() + mines.size(); | ||
612 | 1309 | prio += militarysites.size() / 3; | ||
613 | 1310 | prio -= (bo.cnt_under_construction + numof_warehouses) * 35; | ||
614 | 1311 | prio *= 2; | ||
615 | 1312 | |||
616 | 1313 | // take care about borders and enemies | ||
617 | 1314 | prio = recalc_with_border_range(*bf, prio); | ||
618 | 1315 | |||
619 | 1316 | } else if (bo.type == BuildingObserver::TRAININGSITE) { | ||
620 | 1317 | // Start building trainingsites when there are already more than 50 | ||
621 | 1318 | // other buildings. That should be enough for a working economy. | ||
622 | 1319 | // On the other hand only build more trainingsites of the same | ||
623 | 1320 | // type if the economy is really big. | ||
624 | 1321 | prio += productionsites.size() + militarysites.size(); | ||
625 | 1322 | prio += mines.size(); | ||
626 | 1323 | prio += type * 10; // +0 / +10 / +20 for DEFF/NORM/AGGR | ||
627 | 1324 | prio = prio / (bo.total_count() + 1); | ||
628 | 1325 | prio -= (bo.total_count() + 1) * 70; | ||
629 | 1326 | |||
630 | 1327 | // take care about borders and enemies | ||
631 | 1328 | prio = recalc_with_border_range(*bf, prio); | ||
632 | 1329 | } | ||
633 | 1330 | |||
634 | 1331 | // avoid to have too many construction sites | ||
635 | 1332 | // but still enable the player to build up basic productionsites | ||
636 | 1333 | if | ||
637 | 1334 | (bo.type != BuildingObserver::PRODUCTIONSITE || | ||
638 | 1335 | !bo.is_basic || bo.total_count() > 0) | ||
639 | 1336 | prio /= | ||
640 | 1337 | 1 + bo.cnt_under_construction * (bo.cnt_under_construction + 1); | ||
641 | 1338 | |||
642 | 1339 | // add big penalty if water is needed, but is not near | ||
643 | 1340 | if (bo.need_water) { | ||
644 | 1341 | if (bf->water_nearby < 3) | ||
645 | 1342 | return -1; | ||
646 | 1343 | int effect = bf->water_nearby - 8; | ||
647 | 1344 | prio += | ||
648 | 1345 | effect > 0 ? | ||
649 | 1346 | static_cast<int>(sqrt(static_cast<double>(effect))) : effect; | ||
650 | 1347 | // if same producers are nearby, then give some penalty | ||
651 | 1348 | for (size_t k = 0; k < bo.outputs.size(); ++k) | ||
652 | 1349 | if (bf->producers_nearby.at(bo.outputs.at(k)) > 0) | ||
653 | 1350 | prio -= 3; | ||
654 | 1351 | } | ||
655 | 1352 | |||
656 | 1353 | // think of space consuming buildings nearby like farms or vineyards | ||
657 | 1354 | prio /= 1 + bf->space_consumers_nearby; | ||
658 | 1355 | |||
659 | 1356 | return prio; | ||
660 | 1357 | } | ||
661 | 1358 | |||
662 | 1255 | /** | 1359 | /** |
663 | 1256 | * This function searches for places where a new road is needed to connect two | 1360 | * This function searches for places where a new road is needed to connect two |
664 | 1257 | * economies. It then sends the request to build the road. | 1361 | * economies. It then sends the request to build the road. |
665 | @@ -1722,7 +1826,9 @@ | |||
666 | 1722 | if (!site.site->has_workers(*x.current, game())) | 1826 | if (!site.site->has_workers(*x.current, game())) |
667 | 1723 | continue; | 1827 | continue; |
668 | 1724 | 1828 | ||
670 | 1725 | int32_t prio = 0; // priority for enhancement | 1829 | /*BuildableField bf(map.get_fcoords(site.site->get_position())); |
671 | 1830 | int32_t prio = calculate_building_prio(en_bo, &bf, 0); // priority for enhancement*/ | ||
672 | 1831 | int32_t prio = 0; | ||
673 | 1726 | 1832 | ||
674 | 1727 | // Find new outputs of enhanced building | 1833 | // Find new outputs of enhanced building |
675 | 1728 | std::vector<int16_t> & current_outputs = site.bo->outputs; | 1834 | std::vector<int16_t> & current_outputs = site.bo->outputs; |
676 | @@ -1742,6 +1848,7 @@ | |||
677 | 1742 | // Check if the new wares are needed in economy of the building | 1848 | // Check if the new wares are needed in economy of the building |
678 | 1743 | for (uint32_t i = 0; i < new_outputs.size(); ++i) { | 1849 | for (uint32_t i = 0; i < new_outputs.size(); ++i) { |
679 | 1744 | Ware_Index wt(static_cast<size_t>(new_outputs.at(i))); | 1850 | Ware_Index wt(static_cast<size_t>(new_outputs.at(i))); |
680 | 1851 | prio += round(wares.at(new_outputs.at(i)).demand / 50.0); | ||
681 | 1745 | if (site.site->economy().needs_ware(wt)) | 1852 | if (site.site->economy().needs_ware(wt)) |
682 | 1746 | prio += 2 + wares.at(new_outputs.at(i)).preciousness; | 1853 | prio += 2 + wares.at(new_outputs.at(i)).preciousness; |
683 | 1747 | } | 1854 | } |
684 | @@ -2012,6 +2119,7 @@ | |||
685 | 2012 | for (uint32_t k = 0; k < bo.inputs.size(); ++k) { | 2119 | for (uint32_t k = 0; k < bo.inputs.size(); ++k) { |
686 | 2013 | prio += 2 * wares.at(bo.inputs.at(k)).producers; | 2120 | prio += 2 * wares.at(bo.inputs.at(k)).producers; |
687 | 2014 | prio -= wares.at(bo.inputs.at(k)).consumers; | 2121 | prio -= wares.at(bo.inputs.at(k)).consumers; |
688 | 2122 | prio -= round(wares.at(bo.inputs.at(k)).demand / 100.0); | ||
689 | 2015 | } | 2123 | } |
690 | 2016 | if (bo.inputs.empty()) | 2124 | if (bo.inputs.empty()) |
691 | 2017 | prio += 4; | 2125 | prio += 4; |
692 | @@ -2021,6 +2129,7 @@ | |||
693 | 2021 | WareObserver & wo = wares.at(bo.outputs.at(k)); | 2129 | WareObserver & wo = wares.at(bo.outputs.at(k)); |
694 | 2022 | if (wo.consumers > 0) { | 2130 | if (wo.consumers > 0) { |
695 | 2023 | output_prio += wo.preciousness; | 2131 | output_prio += wo.preciousness; |
696 | 2132 | output_prio += round(wo.demand / 100.0); | ||
697 | 2024 | output_prio += wo.consumers * 2; | 2133 | output_prio += wo.consumers * 2; |
698 | 2025 | output_prio -= wo.producers * 2; | 2134 | output_prio -= wo.producers * 2; |
699 | 2026 | if (bo.total_count() == 0) | 2135 | if (bo.total_count() == 0) |
700 | 2027 | 2136 | ||
701 | === modified file 'src/ai/defaultai.h' | |||
702 | --- src/ai/defaultai.h 2012-02-20 15:54:26 +0000 | |||
703 | +++ src/ai/defaultai.h 2013-01-05 13:44:24 +0000 | |||
704 | @@ -118,6 +118,7 @@ | |||
705 | 118 | void update_all_buildable_fields (int32_t); | 118 | void update_all_buildable_fields (int32_t); |
706 | 119 | void update_all_mineable_fields (int32_t); | 119 | void update_all_mineable_fields (int32_t); |
707 | 120 | void update_all_not_buildable_fields (); | 120 | void update_all_not_buildable_fields (); |
708 | 121 | void update_demand(); | ||
709 | 121 | 122 | ||
710 | 122 | void update_buildable_field(BuildableField &, uint16_t = 6, bool = false); | 123 | void update_buildable_field(BuildableField &, uint16_t = 6, bool = false); |
711 | 123 | void update_mineable_field (MineableField &); | 124 | void update_mineable_field (MineableField &); |
712 | @@ -138,6 +139,7 @@ | |||
713 | 138 | 139 | ||
714 | 139 | int32_t recalc_with_border_range(const BuildableField &, int32_t); | 140 | int32_t recalc_with_border_range(const BuildableField &, int32_t); |
715 | 140 | int32_t calculate_need_for_ps(BuildingObserver &, int32_t); | 141 | int32_t calculate_need_for_ps(BuildingObserver &, int32_t); |
716 | 142 | int32_t calculate_building_prio(BuildingObserver & bo, BuildableField * const bf, uint32_t expand_factor); | ||
717 | 141 | 143 | ||
718 | 142 | void consider_productionsite_influence | 144 | void consider_productionsite_influence |
719 | 143 | (BuildableField &, Widelands::Coords, BuildingObserver const &); | 145 | (BuildableField &, Widelands::Coords, BuildingObserver const &); |
720 | @@ -193,6 +195,8 @@ | |||
721 | 193 | int32_t time_of_last_construction; | 195 | int32_t time_of_last_construction; |
722 | 194 | 196 | ||
723 | 195 | uint16_t numof_warehouses; | 197 | uint16_t numof_warehouses; |
724 | 198 | |||
725 | 199 | float military_demand; | ||
726 | 196 | }; | 200 | }; |
727 | 197 | 201 | ||
728 | 198 | #endif | 202 | #endif |
729 | 199 | 203 | ||
730 | === modified file 'src/logic/militarysite.h' | |||
731 | --- src/logic/militarysite.h 2012-02-15 21:25:34 +0000 | |||
732 | +++ src/logic/militarysite.h 2013-01-05 13:44:24 +0000 | |||
733 | @@ -75,6 +75,7 @@ | |||
734 | 75 | // Begin implementation of SoldierControl | 75 | // Begin implementation of SoldierControl |
735 | 76 | virtual std::vector<Soldier *> presentSoldiers() const; | 76 | virtual std::vector<Soldier *> presentSoldiers() const; |
736 | 77 | virtual std::vector<Soldier *> stationedSoldiers() const; | 77 | virtual std::vector<Soldier *> stationedSoldiers() const; |
737 | 78 | virtual uint32_t missingSoldiers() { return m_capacity - stationedSoldiers().size(); } | ||
738 | 78 | virtual uint32_t minSoldierCapacity() const throw (); | 79 | virtual uint32_t minSoldierCapacity() const throw (); |
739 | 79 | virtual uint32_t maxSoldierCapacity() const throw (); | 80 | virtual uint32_t maxSoldierCapacity() const throw (); |
740 | 80 | virtual uint32_t soldierCapacity() const; | 81 | virtual uint32_t soldierCapacity() const; |
741 | 81 | 82 | ||
742 | === modified file 'tribes/barbarians/fernery/conf' | |||
743 | --- tribes/barbarians/fernery/conf 2011-09-12 17:29:32 +0000 | |||
744 | +++ tribes/barbarians/fernery/conf 2013-01-05 13:44:24 +0000 | |||
745 | @@ -3,6 +3,7 @@ | |||
746 | 3 | 3 | ||
747 | 4 | [aihints] | 4 | [aihints] |
748 | 5 | space_consumer=true | 5 | space_consumer=true |
749 | 6 | is_basic=true | ||
750 | 6 | 7 | ||
751 | 7 | [buildcost] | 8 | [buildcost] |
752 | 8 | trunk=5 | 9 | trunk=5 |
see http:// wl.widelands. org/forum/ topic/648/ ?page=3# post-8562. More comments and review welcome.