Merge lp:~widelands-dev/widelands/ai-rename-bo-outputs into lp:widelands
- ai-rename-bo-outputs
- Merge into trunk
Proposed by
GunChleoc
Status: | Merged |
---|---|
Merged at revision: | 9123 |
Proposed branch: | lp:~widelands-dev/widelands/ai-rename-bo-outputs |
Merge into: | lp:widelands |
Diff against target: |
342 lines (+48/-48) 2 files modified
src/ai/ai_help_structs.h (+1/-1) src/ai/defaultai.cc (+47/-47) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/ai-rename-bo-outputs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
hessenfarmer | Approve | ||
Review via email: mp+367928@code.launchpad.net |
Commit message
Rename BuildingObserve
Description of the change
The variable name has already confused at least 2 people, so I decided to change it.
To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote : | # |
Thanks!
@bunnybot merge
Revision history for this message
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 5040. State: errored. Details: https:/
Appveyor build 4820. State: success. Details: https:/
Revision history for this message
bunnybot (widelandsofficial) wrote : | # |
Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.
Travis build 5040. State: errored. Details: https:/
Revision history for this message
GunChleoc (gunchleoc) wrote : | # |
The input queues again
@bunnybot merge force
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 2019-05-18 13:04:13 +0000 |
3 | +++ src/ai/ai_help_structs.h 2019-05-25 08:29:16 +0000 |
4 | @@ -462,7 +462,7 @@ |
5 | uint32_t basic_amount; // basic amount for basic economy as defined in init.lua |
6 | |
7 | std::vector<Widelands::DescriptionIndex> inputs; |
8 | - std::vector<Widelands::DescriptionIndex> outputs; |
9 | + std::vector<Widelands::DescriptionIndex> ware_outputs; |
10 | std::vector<Widelands::DescriptionIndex> positions; |
11 | std::vector<Widelands::DescriptionIndex> critical_building_material; |
12 | |
13 | |
14 | === modified file 'src/ai/defaultai.cc' |
15 | --- src/ai/defaultai.cc 2019-05-22 11:23:14 +0000 |
16 | +++ src/ai/defaultai.cc 2019-05-25 08:29:16 +0000 |
17 | @@ -681,7 +681,7 @@ |
18 | bo.inputs.push_back(temp_input.first); |
19 | } |
20 | for (const DescriptionIndex& temp_output : prod.output_ware_types()) { |
21 | - bo.outputs.push_back(temp_output); |
22 | + bo.ware_outputs.push_back(temp_output); |
23 | } |
24 | |
25 | // Read information about worker outputs |
26 | @@ -698,7 +698,7 @@ |
27 | } |
28 | } |
29 | } |
30 | - if (!bo.is(BuildingAttribute::kBarracks) && bo.outputs.empty()) { |
31 | + if (!bo.is(BuildingAttribute::kBarracks) && bo.ware_outputs.empty()) { |
32 | bo.set_is(BuildingAttribute::kRecruitment); |
33 | } |
34 | } |
35 | @@ -708,7 +708,7 @@ |
36 | } |
37 | |
38 | // If this is a producer, does it act also as supporter? |
39 | - if (!bo.outputs.empty() && !bo.production_hints.empty()) { |
40 | + if (!bo.ware_outputs.empty() && !bo.production_hints.empty()) { |
41 | bo.set_is(BuildingAttribute::kSupportingProducer); |
42 | } |
43 | |
44 | @@ -728,7 +728,7 @@ |
45 | mines_per_type[bo.mines] = MineTypesObserver(); |
46 | } |
47 | // Identify iron mines based on output |
48 | - if (bo.outputs[0] == tribe_->ironore()) { |
49 | + if (bo.ware_outputs[0] == tribe_->ironore()) { |
50 | bo.set_is(BuildingAttribute::kIronMine); |
51 | mines_per_type[bo.mines].is_critical = true; |
52 | mine_fields_stat.add_critical_ore(bo.mines); |
53 | @@ -739,7 +739,7 @@ |
54 | bo.set_is(BuildingAttribute::kShipyard); |
55 | } |
56 | // Identify refined log producer |
57 | - if (bo.outputs.size() == 1 && bo.outputs[0] == tribe_->refinedlog()) { |
58 | + if (bo.ware_outputs.size() == 1 && bo.ware_outputs[0] == tribe_->refinedlog()) { |
59 | bo.set_is(BuildingAttribute::kLogRefiner); |
60 | } |
61 | |
62 | @@ -758,7 +758,7 @@ |
63 | // now testing outputs of current building |
64 | // and comparing |
65 | bo.set_is(BuildingAttribute::kUpgradeSubstitutes); |
66 | - for (DescriptionIndex ware : bo.outputs) { |
67 | + for (DescriptionIndex ware : bo.ware_outputs) { |
68 | if (enh_outputs.count(ware) == 0) { |
69 | bo.unset_is(BuildingAttribute::kUpgradeSubstitutes); |
70 | break; |
71 | @@ -767,7 +767,7 @@ |
72 | |
73 | std::unordered_set<DescriptionIndex> cur_outputs; |
74 | // collecting wares that are produced in enhanced building |
75 | - for (const DescriptionIndex& ware : bo.outputs) { |
76 | + for (const DescriptionIndex& ware : bo.ware_outputs) { |
77 | cur_outputs.insert(ware); |
78 | } |
79 | // Does upgraded building produce any different outputs? |
80 | @@ -780,7 +780,7 @@ |
81 | } |
82 | |
83 | // now we identify producers of critical build materials |
84 | - for (DescriptionIndex ware : bo.outputs) { |
85 | + for (DescriptionIndex ware : bo.ware_outputs) { |
86 | // building material except for trivial material |
87 | if (tribe_->is_construction_material(ware) && |
88 | !(ware == tribe_->rawlog() || ware == tribe_->granite())) { |
89 | @@ -2512,7 +2512,7 @@ |
90 | bo.new_building == BuildingNecessity::kForced || |
91 | bo.new_building == BuildingNecessity::kAllowed || |
92 | bo.new_building == BuildingNecessity::kNeededPending) && |
93 | - (!bo.outputs.empty() || |
94 | + (!bo.ware_outputs.empty() || |
95 | bo.initial_preciousness > |
96 | 0)) { // bo.initial_preciousness signals that we have a worker output |
97 | bo.max_needed_preciousness = |
98 | @@ -2672,7 +2672,7 @@ |
99 | // Some productionsites strictly require supporting sites nearby |
100 | if (bo.requires_supporters) { |
101 | uint16_t supporters_nearby = 0; |
102 | - for (auto output : bo.outputs) { |
103 | + for (auto output : bo.ware_outputs) { |
104 | supporters_nearby += bf->supporters_nearby.at(output); |
105 | } |
106 | if (supporters_nearby == 0) { |
107 | @@ -3067,7 +3067,7 @@ |
108 | (40 - current_stocklevel) / 2, kAbsValue); |
109 | } |
110 | // This considers supporters nearby |
111 | - for (auto ph : bo.outputs) { |
112 | + for (auto ph : bo.ware_outputs) { |
113 | prio += management_data.neuron_pool[52].get_result_safe( |
114 | bf->supporters_nearby.at(ph) * 5, kAbsValue) / |
115 | 2; |
116 | @@ -3089,8 +3089,8 @@ |
117 | // +1 if any consumers_ are nearby |
118 | consumers_nearby_count = 0; |
119 | |
120 | - for (size_t k = 0; k < bo.outputs.size(); ++k) |
121 | - consumers_nearby_count += bf->consumers_nearby.at(bo.outputs.at(k)); |
122 | + for (size_t k = 0; k < bo.ware_outputs.size(); ++k) |
123 | + consumers_nearby_count += bf->consumers_nearby.at(bo.ware_outputs.at(k)); |
124 | |
125 | if (consumers_nearby_count > 0) { |
126 | prio += std::abs(management_data.get_military_number_at(107)) / 3; |
127 | @@ -5006,8 +5006,8 @@ |
128 | // Calulate preciousness |
129 | bo.max_preciousness = bo.initial_preciousness; |
130 | bo.max_needed_preciousness = bo.initial_preciousness; |
131 | - for (uint32_t m = 0; m < bo.outputs.size(); ++m) { |
132 | - DescriptionIndex wt(static_cast<size_t>(bo.outputs.at(m))); |
133 | + for (uint32_t m = 0; m < bo.ware_outputs.size(); ++m) { |
134 | + DescriptionIndex wt(static_cast<size_t>(bo.ware_outputs.at(m))); |
135 | |
136 | uint16_t target = tribe_->get_ware_descr(wt)->default_target_quantity(tribe_->name()); |
137 | if (target == Widelands::kInvalidWare) { |
138 | @@ -5022,7 +5022,7 @@ |
139 | // positive value here. |
140 | // TODO(GunChleoc): Since we require in Tribes::postload() that this is set for all wares used |
141 | // by a tribe, something seems to be wrong here. It should always be > 0. |
142 | - const uint16_t preciousness = std::max<uint16_t>(wares.at(bo.outputs.at(m)).preciousness, 1); |
143 | + const uint16_t preciousness = std::max<uint16_t>(wares.at(bo.ware_outputs.at(m)).preciousness, 1); |
144 | |
145 | if (calculate_stocklevel(wt) < target || |
146 | site_needed_for_economy == BasicEconomyBuildingStatus::kEncouraged) { |
147 | @@ -5067,7 +5067,7 @@ |
148 | // Do we have suppliers productionsites? |
149 | const bool suppliers_exist = check_supply(bo); |
150 | |
151 | - if (!bo.outputs.empty()) { |
152 | + if (!bo.ware_outputs.empty()) { |
153 | assert(bo.max_preciousness > 0); |
154 | } |
155 | |
156 | @@ -5573,7 +5573,7 @@ |
157 | inputs[4] = (bo.max_needed_preciousness >= 10) ? |
158 | std::abs(management_data.get_military_number_at(2)) / 10 : |
159 | 0; |
160 | - inputs[5] = (!bo.outputs.empty() && bo.current_stats > 10 + 70 / bo.outputs.size()) ? |
161 | + inputs[5] = (!bo.ware_outputs.empty() && bo.current_stats > 10 + 70 / bo.ware_outputs.size()) ? |
162 | management_data.get_military_number_at(3) / 10 : |
163 | 0; |
164 | inputs[6] = (needs_second_for_upgrade) ? |
165 | @@ -5581,7 +5581,7 @@ |
166 | 0; |
167 | inputs[7] = (bo.cnt_under_construction + bo.unoccupied_count) * -1 * |
168 | std::abs(management_data.get_military_number_at(9)) / 5; |
169 | - inputs[8] = (!bo.outputs.empty() && bo.current_stats > 25 + 70 / bo.outputs.size()) ? |
170 | + inputs[8] = (!bo.ware_outputs.empty() && bo.current_stats > 25 + 70 / bo.ware_outputs.size()) ? |
171 | management_data.get_military_number_at(7) / 8 : |
172 | 0; |
173 | inputs[9] = (bo.is(BuildingAttribute::kBuildingMatProducer)) ? |
174 | @@ -5621,7 +5621,7 @@ |
175 | 0; |
176 | inputs[22] = |
177 | (bo.total_count() == 0 && bo.is(BuildingAttribute::kBuildingMatProducer)) ? 3 : 0; |
178 | - if (bo.cnt_built > 0 && !bo.outputs.empty()) { |
179 | + if (bo.cnt_built > 0 && !bo.ware_outputs.empty()) { |
180 | inputs[22] += bo.current_stats / 10; |
181 | } |
182 | inputs[23] = (!player_statistics.strong_enough(player_number())) ? 5 : 0; |
183 | @@ -5639,24 +5639,24 @@ |
184 | inputs[31] = ((bo.cnt_under_construction + bo.unoccupied_count) > 0) ? -5 : 0; |
185 | inputs[32] = bo.max_needed_preciousness / 2; |
186 | inputs[33] = -(bo.cnt_under_construction + bo.unoccupied_count) * 4; |
187 | - if (bo.cnt_built > 0 && !bo.outputs.empty() && !bo.inputs.empty()) { |
188 | + if (bo.cnt_built > 0 && !bo.ware_outputs.empty() && !bo.inputs.empty()) { |
189 | inputs[34] += |
190 | bo.current_stats / std::abs(management_data.get_military_number_at(192)) * 10; |
191 | } |
192 | - inputs[35] = (!bo.outputs.empty() && !bo.inputs.empty() && |
193 | - bo.current_stats > 10 + 70 / bo.outputs.size()) ? |
194 | + inputs[35] = (!bo.ware_outputs.empty() && !bo.inputs.empty() && |
195 | + bo.current_stats > 10 + 70 / bo.ware_outputs.size()) ? |
196 | 2 : |
197 | 0; |
198 | - inputs[36] = (!bo.outputs.empty() && !bo.inputs.empty() && |
199 | + inputs[36] = (!bo.ware_outputs.empty() && !bo.inputs.empty() && |
200 | bo.cnt_under_construction + bo.unoccupied_count == 0) ? |
201 | bo.current_stats / 12 : |
202 | 0; |
203 | - if (bo.cnt_built > 0 && !bo.inputs.empty() && !bo.outputs.empty() && |
204 | + if (bo.cnt_built > 0 && !bo.inputs.empty() && !bo.ware_outputs.empty() && |
205 | bo.current_stats < 20) { |
206 | inputs[37] = -5; |
207 | } |
208 | inputs[38] = (bo.cnt_under_construction + bo.unoccupied_count > 0) ? -10 : 0; |
209 | - if (bo.cnt_built > 0 && !bo.outputs.empty() && bo.current_stats < 15) { |
210 | + if (bo.cnt_built > 0 && !bo.ware_outputs.empty() && bo.current_stats < 15) { |
211 | inputs[39] = -10; |
212 | } |
213 | inputs[40] = (expansion_type.get_expansion_type() == ExpansionMode::kEconomy) ? 3 : 0; |
214 | @@ -5666,8 +5666,8 @@ |
215 | inputs[44] = (bo.inputs.empty() && bo.max_needed_preciousness >= 10) ? 3 : 0; |
216 | inputs[45] = bo.max_needed_preciousness / 2; |
217 | inputs[46] = |
218 | - (!bo.outputs.empty() && bo.current_stats > 10 + 70 / bo.outputs.size()) ? 4 : 0; |
219 | - inputs[47] = (!bo.outputs.empty() && bo.current_stats > 85) ? 4 : 0; |
220 | + (!bo.ware_outputs.empty() && bo.current_stats > 10 + 70 / bo.ware_outputs.size()) ? 4 : 0; |
221 | + inputs[47] = (!bo.ware_outputs.empty() && bo.current_stats > 85) ? 4 : 0; |
222 | inputs[48] = (bo.max_needed_preciousness >= 10 && |
223 | (bo.cnt_under_construction + bo.unoccupied_count) == 1) ? |
224 | 5 : |
225 | @@ -5692,7 +5692,7 @@ |
226 | bo.cnt_under_construction + bo.unoccupied_count == 0) ? |
227 | 6 : |
228 | 0; |
229 | - inputs[63] = (!bo.outputs.empty() && !bo.inputs.empty()) ? bo.current_stats / 10 : 0; |
230 | + inputs[63] = (!bo.ware_outputs.empty() && !bo.inputs.empty()) ? bo.current_stats / 10 : 0; |
231 | inputs[64] = (gametime > 20 * 60 * 1000 && bo.total_count() == 0) ? 3 : 0; |
232 | inputs[65] = (gametime > 45 * 60 * 1000 && bo.total_count() == 0) ? 3 : 0; |
233 | inputs[66] = (gametime > 60 * 60 * 1000 && bo.total_count() <= 1) ? 3 : 0; |
234 | @@ -5760,12 +5760,12 @@ |
235 | std::abs(management_data.get_military_number_at(163)) / 10 : |
236 | 0; |
237 | inputs[110] = |
238 | - (bo.outputs.size() == 1) ? |
239 | - (tribe_->get_ware_descr(bo.outputs.at(0))->default_target_quantity(tribe_->name()) - |
240 | + (bo.ware_outputs.size() == 1) ? |
241 | + (tribe_->get_ware_descr(bo.ware_outputs.at(0))->default_target_quantity(tribe_->name()) - |
242 | get_stocklevel(bo, gametime)) * |
243 | std::abs(management_data.get_military_number_at(165)) / 20 : |
244 | 0; |
245 | - inputs[111] = bo.current_stats / (bo.outputs.size() + 1); |
246 | + inputs[111] = bo.current_stats / (bo.ware_outputs.size() + 1); |
247 | |
248 | int16_t tmp_score = 0; |
249 | for (uint8_t i = 0; i < kFNeuronBitSize; ++i) { |
250 | @@ -5842,7 +5842,7 @@ |
251 | return BuildingNecessity::kNeeded; |
252 | } else if (bo.max_preciousness >= 10 && bo.total_count() == 2) { |
253 | return BuildingNecessity::kNeeded; |
254 | - } else if (!bo.outputs.empty() && bo.current_stats > (10 + 60 / bo.outputs.size()) / 2) { |
255 | + } else if (!bo.ware_outputs.empty() && bo.current_stats > (10 + 60 / bo.ware_outputs.size()) / 2) { |
256 | return BuildingNecessity::kNeeded; |
257 | } else if (bo.inputs.size() == 1 && |
258 | calculate_stocklevel(static_cast<size_t>(bo.inputs.at(0))) > |
259 | @@ -5878,7 +5878,7 @@ |
260 | uint32_t |
261 | DefaultAI::get_stocklevel(BuildingObserver& bo, const uint32_t gametime, const WareWorker what) { |
262 | if (bo.stocklevel_time < gametime - 5 * 1000) { |
263 | - if (what == WareWorker::kWare && (!bo.production_hints.empty() || !bo.outputs.empty())) { |
264 | + if (what == WareWorker::kWare && (!bo.production_hints.empty() || !bo.ware_outputs.empty())) { |
265 | // looking for smallest value |
266 | bo.stocklevel_count = std::numeric_limits<uint32_t>::max(); |
267 | for (auto ph : bo.production_hints) { |
268 | @@ -5887,7 +5887,7 @@ |
269 | bo.stocklevel_count = res; |
270 | } |
271 | } |
272 | - for (auto ph : bo.outputs) { |
273 | + for (auto ph : bo.ware_outputs) { |
274 | const uint32_t res = calculate_stocklevel(static_cast<size_t>(ph), what); |
275 | if (res < bo.stocklevel_count) { |
276 | bo.stocklevel_count = res; |
277 | @@ -5965,8 +5965,8 @@ |
278 | ++field.consumers_nearby.at(bo.inputs.at(i)); |
279 | } |
280 | |
281 | - for (size_t i = 0; i < bo.outputs.size(); ++i) { |
282 | - ++field.producers_nearby.at(bo.outputs.at(i)); |
283 | + for (size_t i = 0; i < bo.ware_outputs.size(); ++i) { |
284 | + ++field.producers_nearby.at(bo.ware_outputs.at(i)); |
285 | } |
286 | if (bo.collected_map_resource != INVALID_INDEX) { |
287 | ++field.collecting_producers_nearby.at(bo.collected_map_resource); |
288 | @@ -6299,8 +6299,8 @@ |
289 | ++fishers_count_; |
290 | } |
291 | |
292 | - for (uint32_t i = 0; i < bo.outputs.size(); ++i) |
293 | - ++wares.at(bo.outputs.at(i)).producers; |
294 | + for (uint32_t i = 0; i < bo.ware_outputs.size(); ++i) |
295 | + ++wares.at(bo.ware_outputs.at(i)).producers; |
296 | |
297 | for (uint32_t i = 0; i < bo.inputs.size(); ++i) |
298 | ++wares.at(bo.inputs.at(i)).consumers; |
299 | @@ -6314,8 +6314,8 @@ |
300 | assert(mines_.back().dismantle_pending_since == kNever); |
301 | mines_.back().bo->unoccupied_count += 1; |
302 | |
303 | - for (uint32_t i = 0; i < bo.outputs.size(); ++i) |
304 | - ++wares.at(bo.outputs.at(i)).producers; |
305 | + for (uint32_t i = 0; i < bo.ware_outputs.size(); ++i) |
306 | + ++wares.at(bo.ware_outputs.at(i)).producers; |
307 | |
308 | for (uint32_t i = 0; i < bo.inputs.size(); ++i) |
309 | ++wares.at(bo.inputs.at(i)).consumers; |
310 | @@ -6418,8 +6418,8 @@ |
311 | break; |
312 | } |
313 | |
314 | - for (uint32_t i = 0; i < bo.outputs.size(); ++i) { |
315 | - --wares.at(bo.outputs.at(i)).producers; |
316 | + for (uint32_t i = 0; i < bo.ware_outputs.size(); ++i) { |
317 | + --wares.at(bo.ware_outputs.at(i)).producers; |
318 | } |
319 | |
320 | for (uint32_t i = 0; i < bo.inputs.size(); ++i) { |
321 | @@ -6439,8 +6439,8 @@ |
322 | } |
323 | } |
324 | |
325 | - for (uint32_t i = 0; i < bo.outputs.size(); ++i) { |
326 | - --wares.at(bo.outputs.at(i)).producers; |
327 | + for (uint32_t i = 0; i < bo.ware_outputs.size(); ++i) { |
328 | + --wares.at(bo.ware_outputs.at(i)).producers; |
329 | } |
330 | |
331 | for (uint32_t i = 0; i < bo.inputs.size(); ++i) { |
332 | @@ -6502,8 +6502,8 @@ |
333 | for (const Widelands::DescriptionIndex& temp_inputs : bo.inputs) { |
334 | for (const BuildingObserver& temp_building : buildings_) { |
335 | if (temp_building.cnt_built && |
336 | - std::find(temp_building.outputs.begin(), temp_building.outputs.end(), temp_inputs) != |
337 | - temp_building.outputs.end() && |
338 | + std::find(temp_building.ware_outputs.begin(), temp_building.ware_outputs.end(), temp_inputs) != |
339 | + temp_building.ware_outputs.end() && |
340 | check_supply(temp_building)) { |
341 | ++supplied; |
342 | break; |
checked if all instances are caught.
LGTM ;-)