[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/ai_small_requests into lp:widelands has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Continuous integration builds have changed state: Travis build 2756. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/297200705. Appveyor build 2568. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_ai_small_requests-2568. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
@bunnybot merge -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Error merging this proposal: Output: stdout: stderr: M src/ai/ai_help_structs.cc M src/ai/ai_help_structs.h M src/ai/defaultai.cc M src/ai/defaultai_warfare.cc Text conflict in src/ai/ai_help_structs.h 1 conflicts encountered. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
@bunnybot merge force -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways. Travis build 2742. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/296463258. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Now tested and confirmed as working :) @bunnybot merge -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Continuous integration builds have changed state: Travis build 2742. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/296463258. Appveyor build 2554. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_ai_small_requests-2554. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
I just run game with seafaring map and AI was building ports as expected. But I had not tested opposite scenario... -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
> Does this still need testing for the seafaring buildings? Yes. Bug 1722376 needs testing (if Tibor didn't test it already), but bug 1724073 is fixed with this branch. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
That was more of a question for Kaputtnik - you are fixing 2 things here. He commented that 1724073 is fixed, but not on the other bug. I don't want to spend time testing whether the other bug is indeed fixed if he has already done so. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
I removed the variable altogether. I am bit surprised that it is not needed What testing do you mean? -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Review: Approve Code LGTM, just 1 tiny nit. Does this still need testing for the seafaring buildings? Diff comments: > > === modified file 'src/ai/defaultai.cc' > --- src/ai/defaultai.cc 2017-09-29 16:10:25 + > +++ src/ai/defaultai.cc 2017-10-19 19:37:15 + > @@ -4291,7 +4302,8 @@ > // dismantle > BuildingNecessity DefaultAI::check_building_necessity(BuildingObserver& bo, >const PerfEvaluation > purpose, > - const uint32_t > gametime) { > + const uint32_t > gametime, > + const bool > seafaring_map) { Call this seafaring_economy for consistency > > bo.primary_priority = 0; > -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/ai_small_requests into lp:widelands has been updated. Commit Message changed to: Prohibits seafaring buildings for AI on non-seafaring maps, fixes 1724073 when AI crashed when some AI slots were empty, allows reseting of teams via LUA during game For more details, see: https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Review: Approve testing This fixes https://bugs.launchpad.net/widelands/+bug/1724073 :-) So for this bug approval. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_small_requests. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
Continuous integration builds have changed state: Travis build 2711. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/290174782. Appveyor build 2525. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_ai_small_requests-2525. -- https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/ai_small_requests into lp:widelands. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_small_requests into lp:widelands
TiborB has proposed merging lp:~widelands-dev/widelands/ai_small_requests into lp:widelands. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1722376 in widelands: "AI builds Barbarian Weaving Mill on non-seafaring maps" https://bugs.launchpad.net/widelands/+bug/1722376 Bug #1724073 in widelands: "ai_help_structs: Assertion `all_stats.count(pl2) > 0' failed." https://bugs.launchpad.net/widelands/+bug/1724073 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/ai_small_requests/+merge/332519 Changes: - prohibits seafaring-specific buildings for AI if map does not have at least two ports - fixes weird bug in AI when number of players was lower than number of game slots - AI now recognizes changes in teams setup during the game -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/ai_small_requests into lp:widelands. === modified file 'src/ai/ai_help_structs.cc' --- src/ai/ai_help_structs.cc 2017-09-29 16:10:25 + +++ src/ai/ai_help_structs.cc 2017-10-19 19:37:15 + @@ -1037,7 +1037,6 @@ // Constructor to be used PlayersStrengths::PlayerStat::PlayerStat(Widelands::TeamNumber tc, - bool e, uint32_t pp, uint32_t op, uint32_t o60p, @@ -1046,7 +1045,6 @@ uint32_t oland, uint32_t o60l) : team_number(tc), - is_enemy(e), players_power(pp), old_players_power(op), old60_players_power(o60p), @@ -1079,17 +1077,9 @@ uint32_t oland, uint32_t o60l) { if (all_stats.count(opn) == 0) { - bool enemy = false; - if (pn == opn) { - ; - } else if (pltn == 0 || mytn == 0) { - enemy = true; - } else if (pltn != mytn) { - enemy = true; - } this_player_number = pn; - all_stats.insert( - std::make_pair(opn, PlayerStat(pltn, enemy, pp, op, o60p, cs, land, oland, o60l))); + this_player_team = mytn; + all_stats.insert(std::make_pair(opn, PlayerStat(pltn, pp, op, o60p, cs, land, oland, o60l))); } else { all_stats[opn].players_power = pp; all_stats[opn].old_players_power = op; @@ -1098,6 +1088,25 @@ all_stats[opn].players_land = land; all_stats[opn].old_players_land = oland; all_stats[opn].old60_players_land = oland; + assert(this_player_number == pn); + if (this_player_team != mytn) { + log("%2d: Team changed %d -> %d\n", pn, this_player_team, mytn); + this_player_team = mytn; + }; + if (all_stats[opn].team_number != pltn) { + log("%2d: Team changed for player %d: %d -> %d\n", pn, opn, all_stats[opn].team_number, + pltn); + all_stats[opn].team_number = pltn; + }; + } +} + +// Very tiny possibility that player that has a statistics info here +// does not exist anymore +void PlayersStrengths::remove_stat(const Widelands::PlayerNumber pn) { + if (all_stats.count(pn) > 0) { + log("%d: AI: Erasing statistics for player %d\n", this_player_number, pn); + all_stats.erase(pn); } } @@ -1118,7 +1127,7 @@ // This just goes over information about all enemies and where they were seen the last time bool PlayersStrengths::any_enemy_seen_lately(const uint32_t gametime) { for (auto& item : all_stats) { - if (item.second.is_enemy && player_seen_lately(item.first, gametime)) { + if (get_is_enemy(item.first) && player_seen_lately(item.first, gametime)) { return true; } } @@ -1129,7 +1138,7 @@ uint8_t PlayersStrengths::enemies_seen_lately_count(const uint32_t gametime) { uint8_t count = 0; for (auto& item : all_stats) { - if (item.second.is_enemy && player_seen_lately(item.first, gametime)) { + if (get_is_enemy(item.first) && player_seen_lately(item.first, gametime)) { count += 1; } } @@ -1144,13 +1153,23 @@ all_stats[pn].last_time_seen = seentime; } -bool PlayersStrengths::get_is_enemy(Widelands::PlayerNumber pn) { - if (all_stats.count(pn) == 0) { +bool PlayersStrengths::get_is_enemy(Widelands::PlayerNumber other_player_number) { + // So this is me + if (other_player_number == this_player_number) { + return false; + } + // If we do not belong to any team, all others are our enemies + if (this_player_team == 0) { + return true; + } + if (all_stats.count(other_player_number) == 0) { // Should happen only rarely so we print a warning here - log("%d: WARNING: player has no statistics yet\n", this_player_number); + log("%d: WARNING: player has no statistics yet for player %d\n", this_player_number, + other_player_number); return false; } - return all_stats[pn].is_enemy; + // finally we compare my team number of the other player team number + return all_stats[other_playe