← Back to team overview

widelands-dev team mailing list archive

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

 

TiborB has proposed merging lp:~widelands-dev/widelands/ai_numbers_expansion into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/ai_numbers_expansion/+merge/337124

AI's magic numbers (part of 'DNA') increased to 200, as they all are almost exhausted. No changes to AI functioning.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/ai_numbers_expansion into lp:widelands.
=== modified file 'data/ai/ai_input_1.wai'
--- data/ai/ai_input_1.wai	2017-10-01 23:56:55 +0000
+++ data/ai/ai_input_1.wai	2018-02-03 21:23:04 +0000
@@ -152,6 +152,56 @@
 147="-30"
 148="76"
 149="-47"
+150="-3"
+151="-55"
+152="58"
+153="0"
+154="57"
+155="-92"
+156="4"
+157="-89"
+158="41"
+159="-44"
+160="-100"
+161="56"
+162="19"
+163="-34"
+164="-20"
+165="24"
+166="-54"
+167="84"
+168="56"
+169="-51"
+170="-42"
+171="6"
+172="0"
+173="0"
+174="-36"
+175="-4"
+176="-96"
+177="-34"
+178="0"
+179="-31"
+180="71"
+181="-98"
+182="-25"
+183="-44"
+184="16"
+185="53"
+186="-7"
+187="28"
+188="-54"
+189="23"
+190="21"
+191="53"
+192="80"
+193="-17"
+194="-88"
+195="58"
+196="87"
+197="27"
+198="-57"
+199="-65"
 
 [neuron_values]
 0="48"

=== modified file 'data/ai/ai_input_2.wai'
--- data/ai/ai_input_2.wai	2017-10-01 23:56:55 +0000
+++ data/ai/ai_input_2.wai	2018-02-03 21:23:04 +0000
@@ -152,6 +152,56 @@
 147="-30"
 148="76"
 149="-47"
+150="-3"
+151="-55"
+152="58"
+153="0"
+154="57"
+155="-92"
+156="4"
+157="-89"
+158="41"
+159="-44"
+160="-100"
+161="56"
+162="19"
+163="-34"
+164="-20"
+165="24"
+166="-54"
+167="84"
+168="56"
+169="-51"
+170="-42"
+171="6"
+172="0"
+173="0"
+174="-36"
+175="-4"
+176="-96"
+177="-34"
+178="0"
+179="-31"
+180="71"
+181="-98"
+182="-25"
+183="-44"
+184="16"
+185="53"
+186="-7"
+187="28"
+188="-54"
+189="23"
+190="21"
+191="53"
+192="80"
+193="-17"
+194="-88"
+195="58"
+196="87"
+197="27"
+198="-57"
+199="-65"
 
 [neuron_values]
 0="48"

=== modified file 'data/ai/ai_input_3.wai'
--- data/ai/ai_input_3.wai	2017-10-01 23:56:55 +0000
+++ data/ai/ai_input_3.wai	2018-02-03 21:23:04 +0000
@@ -152,6 +152,56 @@
 147="-30"
 148="76"
 149="-45"
+150="-3"
+151="-55"
+152="58"
+153="0"
+154="57"
+155="-92"
+156="4"
+157="-89"
+158="41"
+159="-44"
+160="-100"
+161="56"
+162="19"
+163="-34"
+164="-20"
+165="24"
+166="-54"
+167="84"
+168="56"
+169="-51"
+170="-42"
+171="6"
+172="0"
+173="0"
+174="-36"
+175="-4"
+176="-96"
+177="-34"
+178="0"
+179="-31"
+180="71"
+181="-98"
+182="-25"
+183="-44"
+184="16"
+185="53"
+186="-7"
+187="28"
+188="-54"
+189="23"
+190="21"
+191="53"
+192="80"
+193="-17"
+194="-88"
+195="58"
+196="87"
+197="27"
+198="-57"
+199="-65"
 
 [neuron_values]
 0="48"

=== modified file 'data/ai/ai_input_4.wai'
--- data/ai/ai_input_4.wai	2017-10-01 23:56:55 +0000
+++ data/ai/ai_input_4.wai	2018-02-03 21:23:04 +0000
@@ -152,6 +152,56 @@
 147="-30"
 148="76"
 149="-45"
+150="-3"
+151="-55"
+152="58"
+153="0"
+154="57"
+155="-92"
+156="4"
+157="-89"
+158="41"
+159="-44"
+160="-100"
+161="56"
+162="19"
+163="-34"
+164="-20"
+165="24"
+166="-54"
+167="84"
+168="56"
+169="-51"
+170="-42"
+171="6"
+172="0"
+173="0"
+174="-36"
+175="-4"
+176="-96"
+177="-34"
+178="0"
+179="-31"
+180="71"
+181="-98"
+182="-25"
+183="-44"
+184="16"
+185="53"
+186="-7"
+187="28"
+188="-54"
+189="23"
+190="21"
+191="53"
+192="80"
+193="-17"
+194="-88"
+195="58"
+196="87"
+197="27"
+198="-57"
+199="-65"
 
 [neuron_values]
 0="48"

=== modified file 'src/game_io/game_player_ai_persistent_packet.cc'
--- src/game_io/game_player_ai_persistent_packet.cc	2017-11-28 10:57:50 +0000
+++ src/game_io/game_player_ai_persistent_packet.cc	2018-02-03 21:23:04 +0000
@@ -29,7 +29,9 @@
 namespace Widelands {
 
 // Introduction of genetic algorithm with all structures that are needed for it
-constexpr uint16_t kCurrentPacketVersion = 4;
+constexpr uint16_t kCurrentPacketVersion = 5;
+// Last version with 150 magic numbers
+constexpr uint16_t kOldMagicNumbers = 4;
 // First version with genetics
 constexpr uint16_t kPacketVersion3 = 3;
 // Old Version before using genetics
@@ -84,17 +86,34 @@
 					// Magic numbers
 					size_t magic_numbers_size = fr.unsigned_32();
 
-					// TODO(GunChleoc): We allow for smaller size for savegame compatibility.
-					// Investigate if we can make the size static after Build 20.
-					if (magic_numbers_size > Widelands::Player::AiPersistentState::kMagicNumbersSize) {
-						throw GameDataError(
-						   "Too many magic numbers: We have %" PRIuS " but only %" PRIuS "are allowed",
-						   magic_numbers_size, Widelands::Player::AiPersistentState::kMagicNumbersSize);
-					}
-					assert(player->ai_data.magic_numbers.size() ==
-					       Widelands::Player::AiPersistentState::kMagicNumbersSize);
-					for (size_t i = 0; i < magic_numbers_size; ++i) {
-						player->ai_data.magic_numbers.at(i) = fr.signed_16();
+					// Here we deal with old savegames that contains 150 magic numbers only
+					if (packet_version <= kOldMagicNumbers) {
+						// The savegame contains less then expected number of magic numbers
+						assert(magic_numbers_size <
+						       Widelands::Player::AiPersistentState::kMagicNumbersSize);
+						assert(player->ai_data.magic_numbers.size() ==
+						       Widelands::Player::AiPersistentState::kMagicNumbersSize);
+						for (size_t i = 0; i < magic_numbers_size; ++i) {
+							player->ai_data.magic_numbers.at(i) = fr.signed_16();
+						}
+						// Adding '50' to missing possitions
+						for (size_t i = magic_numbers_size;
+						     i < Widelands::Player::AiPersistentState::kMagicNumbersSize; ++i) {
+							player->ai_data.magic_numbers.at(i) = 50;
+						}
+					} else {
+						if (magic_numbers_size >
+						    Widelands::Player::AiPersistentState::kMagicNumbersSize) {
+							throw GameDataError("Too many magic numbers: We have %" PRIuS
+							                    " but only %" PRIuS "are allowed",
+							                    magic_numbers_size,
+							                    Widelands::Player::AiPersistentState::kMagicNumbersSize);
+						}
+						assert(player->ai_data.magic_numbers.size() ==
+						       Widelands::Player::AiPersistentState::kMagicNumbersSize);
+						for (size_t i = 0; i < magic_numbers_size; ++i) {
+							player->ai_data.magic_numbers.at(i) = fr.signed_16();
+						}
 					}
 
 					// Neurons

=== modified file 'src/logic/player.h'
--- src/logic/player.h	2017-12-19 14:35:00 +0000
+++ src/logic/player.h	2018-02-03 21:23:04 +0000
@@ -156,7 +156,7 @@
 	/// data
 	struct AiPersistentState {
 		// TODO(tiborb): this should be replaced by command line switch
-		static constexpr size_t kMagicNumbersSize = 150;
+		static constexpr size_t kMagicNumbersSize = 200;
 		static constexpr size_t kNeuronPoolSize = 80;
 		static constexpr size_t kFNeuronPoolSize = 60;
 


Follow ups