Merge lp:~widelands-dev/widelands/ai_numbers_expansion into lp:widelands

Proposed by TiborB
Status: Merged
Merged at revision: 8587
Proposed branch: lp:~widelands-dev/widelands/ai_numbers_expansion
Merge into: lp:widelands
Diff against target: 316 lines (+232/-13)
6 files modified
data/ai/ai_input_1.wai (+50/-0)
data/ai/ai_input_2.wai (+50/-0)
data/ai/ai_input_3.wai (+50/-0)
data/ai/ai_input_4.wai (+50/-0)
src/game_io/game_player_ai_persistent_packet.cc (+31/-12)
src/logic/player.h (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/ai_numbers_expansion
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+337124@code.launchpad.net

Commit message

AI's magic numbers (part of 'DNA') increased to 200. No changes to AI functioning.

Description of the change

AI's magic numbers (part of 'DNA') increased to 200, as they all are almost exhausted. No changes to AI functioning.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3134. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/337054884.
Appveyor build 2941. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_ai_numbers_expansion-2941.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM, will do some testing.

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Tested.

@bunnybot merge

Revision history for this message
TiborB (tiborb95) wrote :

Thanks

As soon as findpath branch is merged, I will resume training and hope soon deliver new version of wai files

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/ai/ai_input_1.wai'
2--- data/ai/ai_input_1.wai 2017-10-01 23:56:55 +0000
3+++ data/ai/ai_input_1.wai 2018-02-03 21:23:04 +0000
4@@ -152,6 +152,56 @@
5 147="-30"
6 148="76"
7 149="-47"
8+150="-3"
9+151="-55"
10+152="58"
11+153="0"
12+154="57"
13+155="-92"
14+156="4"
15+157="-89"
16+158="41"
17+159="-44"
18+160="-100"
19+161="56"
20+162="19"
21+163="-34"
22+164="-20"
23+165="24"
24+166="-54"
25+167="84"
26+168="56"
27+169="-51"
28+170="-42"
29+171="6"
30+172="0"
31+173="0"
32+174="-36"
33+175="-4"
34+176="-96"
35+177="-34"
36+178="0"
37+179="-31"
38+180="71"
39+181="-98"
40+182="-25"
41+183="-44"
42+184="16"
43+185="53"
44+186="-7"
45+187="28"
46+188="-54"
47+189="23"
48+190="21"
49+191="53"
50+192="80"
51+193="-17"
52+194="-88"
53+195="58"
54+196="87"
55+197="27"
56+198="-57"
57+199="-65"
58
59 [neuron_values]
60 0="48"
61
62=== modified file 'data/ai/ai_input_2.wai'
63--- data/ai/ai_input_2.wai 2017-10-01 23:56:55 +0000
64+++ data/ai/ai_input_2.wai 2018-02-03 21:23:04 +0000
65@@ -152,6 +152,56 @@
66 147="-30"
67 148="76"
68 149="-47"
69+150="-3"
70+151="-55"
71+152="58"
72+153="0"
73+154="57"
74+155="-92"
75+156="4"
76+157="-89"
77+158="41"
78+159="-44"
79+160="-100"
80+161="56"
81+162="19"
82+163="-34"
83+164="-20"
84+165="24"
85+166="-54"
86+167="84"
87+168="56"
88+169="-51"
89+170="-42"
90+171="6"
91+172="0"
92+173="0"
93+174="-36"
94+175="-4"
95+176="-96"
96+177="-34"
97+178="0"
98+179="-31"
99+180="71"
100+181="-98"
101+182="-25"
102+183="-44"
103+184="16"
104+185="53"
105+186="-7"
106+187="28"
107+188="-54"
108+189="23"
109+190="21"
110+191="53"
111+192="80"
112+193="-17"
113+194="-88"
114+195="58"
115+196="87"
116+197="27"
117+198="-57"
118+199="-65"
119
120 [neuron_values]
121 0="48"
122
123=== modified file 'data/ai/ai_input_3.wai'
124--- data/ai/ai_input_3.wai 2017-10-01 23:56:55 +0000
125+++ data/ai/ai_input_3.wai 2018-02-03 21:23:04 +0000
126@@ -152,6 +152,56 @@
127 147="-30"
128 148="76"
129 149="-45"
130+150="-3"
131+151="-55"
132+152="58"
133+153="0"
134+154="57"
135+155="-92"
136+156="4"
137+157="-89"
138+158="41"
139+159="-44"
140+160="-100"
141+161="56"
142+162="19"
143+163="-34"
144+164="-20"
145+165="24"
146+166="-54"
147+167="84"
148+168="56"
149+169="-51"
150+170="-42"
151+171="6"
152+172="0"
153+173="0"
154+174="-36"
155+175="-4"
156+176="-96"
157+177="-34"
158+178="0"
159+179="-31"
160+180="71"
161+181="-98"
162+182="-25"
163+183="-44"
164+184="16"
165+185="53"
166+186="-7"
167+187="28"
168+188="-54"
169+189="23"
170+190="21"
171+191="53"
172+192="80"
173+193="-17"
174+194="-88"
175+195="58"
176+196="87"
177+197="27"
178+198="-57"
179+199="-65"
180
181 [neuron_values]
182 0="48"
183
184=== modified file 'data/ai/ai_input_4.wai'
185--- data/ai/ai_input_4.wai 2017-10-01 23:56:55 +0000
186+++ data/ai/ai_input_4.wai 2018-02-03 21:23:04 +0000
187@@ -152,6 +152,56 @@
188 147="-30"
189 148="76"
190 149="-45"
191+150="-3"
192+151="-55"
193+152="58"
194+153="0"
195+154="57"
196+155="-92"
197+156="4"
198+157="-89"
199+158="41"
200+159="-44"
201+160="-100"
202+161="56"
203+162="19"
204+163="-34"
205+164="-20"
206+165="24"
207+166="-54"
208+167="84"
209+168="56"
210+169="-51"
211+170="-42"
212+171="6"
213+172="0"
214+173="0"
215+174="-36"
216+175="-4"
217+176="-96"
218+177="-34"
219+178="0"
220+179="-31"
221+180="71"
222+181="-98"
223+182="-25"
224+183="-44"
225+184="16"
226+185="53"
227+186="-7"
228+187="28"
229+188="-54"
230+189="23"
231+190="21"
232+191="53"
233+192="80"
234+193="-17"
235+194="-88"
236+195="58"
237+196="87"
238+197="27"
239+198="-57"
240+199="-65"
241
242 [neuron_values]
243 0="48"
244
245=== modified file 'src/game_io/game_player_ai_persistent_packet.cc'
246--- src/game_io/game_player_ai_persistent_packet.cc 2017-11-28 10:57:50 +0000
247+++ src/game_io/game_player_ai_persistent_packet.cc 2018-02-03 21:23:04 +0000
248@@ -29,7 +29,9 @@
249 namespace Widelands {
250
251 // Introduction of genetic algorithm with all structures that are needed for it
252-constexpr uint16_t kCurrentPacketVersion = 4;
253+constexpr uint16_t kCurrentPacketVersion = 5;
254+// Last version with 150 magic numbers
255+constexpr uint16_t kOldMagicNumbers = 4;
256 // First version with genetics
257 constexpr uint16_t kPacketVersion3 = 3;
258 // Old Version before using genetics
259@@ -84,17 +86,34 @@
260 // Magic numbers
261 size_t magic_numbers_size = fr.unsigned_32();
262
263- // TODO(GunChleoc): We allow for smaller size for savegame compatibility.
264- // Investigate if we can make the size static after Build 20.
265- if (magic_numbers_size > Widelands::Player::AiPersistentState::kMagicNumbersSize) {
266- throw GameDataError(
267- "Too many magic numbers: We have %" PRIuS " but only %" PRIuS "are allowed",
268- magic_numbers_size, Widelands::Player::AiPersistentState::kMagicNumbersSize);
269- }
270- assert(player->ai_data.magic_numbers.size() ==
271- Widelands::Player::AiPersistentState::kMagicNumbersSize);
272- for (size_t i = 0; i < magic_numbers_size; ++i) {
273- player->ai_data.magic_numbers.at(i) = fr.signed_16();
274+ // Here we deal with old savegames that contains 150 magic numbers only
275+ if (packet_version <= kOldMagicNumbers) {
276+ // The savegame contains less then expected number of magic numbers
277+ assert(magic_numbers_size <
278+ Widelands::Player::AiPersistentState::kMagicNumbersSize);
279+ assert(player->ai_data.magic_numbers.size() ==
280+ Widelands::Player::AiPersistentState::kMagicNumbersSize);
281+ for (size_t i = 0; i < magic_numbers_size; ++i) {
282+ player->ai_data.magic_numbers.at(i) = fr.signed_16();
283+ }
284+ // Adding '50' to missing possitions
285+ for (size_t i = magic_numbers_size;
286+ i < Widelands::Player::AiPersistentState::kMagicNumbersSize; ++i) {
287+ player->ai_data.magic_numbers.at(i) = 50;
288+ }
289+ } else {
290+ if (magic_numbers_size >
291+ Widelands::Player::AiPersistentState::kMagicNumbersSize) {
292+ throw GameDataError("Too many magic numbers: We have %" PRIuS
293+ " but only %" PRIuS "are allowed",
294+ magic_numbers_size,
295+ Widelands::Player::AiPersistentState::kMagicNumbersSize);
296+ }
297+ assert(player->ai_data.magic_numbers.size() ==
298+ Widelands::Player::AiPersistentState::kMagicNumbersSize);
299+ for (size_t i = 0; i < magic_numbers_size; ++i) {
300+ player->ai_data.magic_numbers.at(i) = fr.signed_16();
301+ }
302 }
303
304 // Neurons
305
306=== modified file 'src/logic/player.h'
307--- src/logic/player.h 2017-12-19 14:35:00 +0000
308+++ src/logic/player.h 2018-02-03 21:23:04 +0000
309@@ -156,7 +156,7 @@
310 /// data
311 struct AiPersistentState {
312 // TODO(tiborb): this should be replaced by command line switch
313- static constexpr size_t kMagicNumbersSize = 150;
314+ static constexpr size_t kMagicNumbersSize = 200;
315 static constexpr size_t kNeuronPoolSize = 80;
316 static constexpr size_t kFNeuronPoolSize = 60;
317

Subscribers

People subscribed via source and target branches

to status/vote changes: