[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1728006 into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/bug-1728006 into lp:widelands has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1728006/+merge/333094 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1728006. ___ 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/bug-1728006 into lp:widelands
Review: Approve I have done some testing now. @bunnybot merge -- https://code.launchpad.net/~widelands-dev/widelands/bug-1728006/+merge/333094 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1728006. ___ 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/bug-1728006 into lp:widelands
Continuous integration builds have changed state: Travis build 2740. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/296462194. Appveyor build 2552. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1728006-2552. -- https://code.launchpad.net/~widelands-dev/widelands/bug-1728006/+merge/333094 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1728006 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
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1728006 into lp:widelands
Good catch:) Removed... -- https://code.launchpad.net/~widelands-dev/widelands/bug-1728006/+merge/333094 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1728006 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
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1728006 into lp:widelands
You should get rid of kPureProducer. Looks good to me otherwise. Not tested yet. Diff comments: > === modified file 'src/ai/ai_help_structs.h' > --- src/ai/ai_help_structs.h 2017-09-29 16:10:25 + > +++ src/ai/ai_help_structs.h 2017-11-01 20:33:48 + > @@ -78,6 +78,8 @@ > kUpgradeExtends, > kLogRefiner, > kIronMine, > + kPureProducer, kPureProducer is not used anywhere, you can delete it. > + kSupportingProducer, > }; > > enum class AiType : uint8_t { kVeryWeak, kWeak, kNormal }; > > === modified file 'src/ai/defaultai.cc' > --- src/ai/defaultai.cc 2017-09-29 16:10:25 + > +++ src/ai/defaultai.cc 2017-11-01 20:33:48 + > @@ -698,6 +698,15 @@ > bo.positions.push_back(temp_position.first); > } > > + // If this is a producer, does it act also as supporter? > + if (!bo.outputs.empty()) { > + if (bo.production_hints.empty()) { > + > bo.set_is(BuildingAttribute::kPureProducer); > + } else { > + > bo.set_is(BuildingAttribute::kSupportingProducer); > + } > + } > + if (!bo.outputs.empty() && !bo.production_hints.empty()) { bo.set_is(BuildingAttribute::kSupportingProducer); } Then get rid of the pure producer - you're not using it anywhere. > iron_ore_id = tribe_->ironore(); > > if (bo.type == BuildingObserver::Type::kMine) { -- https://code.launchpad.net/~widelands-dev/widelands/bug-1728006/+merge/333094 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1728006 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/bug-1728006 into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/bug-1728006 into lp:widelands has been updated. Commit Message changed to: Add support for productionsites that are also supporting site to the AI. For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1728006/+merge/333094 -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1728006 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/bug-1728006 into lp:widelands
TiborB has proposed merging lp:~widelands-dev/widelands/bug-1728006 into lp:widelands. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1728006 in widelands: "AI crashes when a producer is also supporter" https://bugs.launchpad.net/widelands/+bug/1728006 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1728006/+merge/333094 This adds support for productionsites that are also supporting site. Needs testing with frisian branch. And AI training a bit, but not as a part of this merge request of course. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1728006 into lp:widelands. === modified file 'src/ai/ai_help_structs.h' --- src/ai/ai_help_structs.h 2017-09-29 16:10:25 + +++ src/ai/ai_help_structs.h 2017-11-01 20:08:18 + @@ -78,6 +78,8 @@ kUpgradeExtends, kLogRefiner, kIronMine, + kPureProducer, + kSupportingProducer, }; enum class AiType : uint8_t { kVeryWeak, kWeak, kNormal }; === modified file 'src/ai/defaultai.cc' --- src/ai/defaultai.cc 2017-09-29 16:10:25 + +++ src/ai/defaultai.cc 2017-11-01 20:08:18 + @@ -698,6 +698,15 @@ bo.positions.push_back(temp_position.first); } + // Now identify is it is a producer and if also supports some ware + if (!bo.outputs.empty()) { +if (bo.production_hints.empty()) { + bo.set_is(BuildingAttribute::kPureProducer); +} else { + bo.set_is(BuildingAttribute::kSupportingProducer); +} + } + iron_ore_id = tribe_->ironore(); if (bo.type == BuildingObserver::Type::kMine) { @@ -2302,7 +2311,7 @@ bo.new_building == BuildingNecessity::kForced || bo.new_building == BuildingNecessity::kAllowed || bo.new_building == BuildingNecessity::kNeededPending) && - (!bo.outputs.empty() || bo.is(BuildingAttribute::kBarracks))) { + (bo.is(BuildingAttribute::kPureProducer) || bo.is(BuildingAttribute::kBarracks))) { if (bo.max_needed_preciousness <= 0) { throw wexception("AI: Max presciousness must not be <= 0 for building: %s", bo.desc->name().c_str()); @@ -2649,7 +2658,7 @@ prio -= (bf->enemy_nearby) * 100; prio -= (expansion_type.get_expansion_type() != ExpansionMode::kEconomy) * 100; } else { // finally normal productionsites - assert(bo.production_hints.empty()); + assert(bo.production_hints.empty() || bo.is(BuildingAttribute::kSupportingProducer)); if (bo.new_building == BuildingNecessity::kForced) { prio += 150; @@ -2709,6 +2718,20 @@ } } + // This is for a special case this is also supporter + for (auto ph : bo.production_hints) { + prio += management_data.neuron_pool[51].get_result_safe( + bf->producers_nearby.at(ph) * 5, kAbsValue) / + 2; + } + + // This considers supporters nearby + for (auto ph : bo.outputs) { + prio += management_data.neuron_pool[52].get_result_safe( + bf->supporters_nearby.at(ph) * 5, kAbsValue) / + 2; + } + if (prio <= 0) { continue; } @@ -4762,7 +4785,8 @@ bo.cnt_under_construction + bo.unoccupied_count == 0) { bo.max_needed_preciousness = bo.max_preciousness; // even when rocks are not needed return BuildingNecessity::kAllowed; - } else if (!bo.production_hints.empty()) { + } else if (!bo.production_hints.empty() && !bo.is(BuildingAttribute::kSupportingProducer)) { + // Pure supporting sites only) { if (bo.cnt_under_construction + bo.unoccupied_count - bo.unconnected_count > 0) { return BuildingNecessity::kForbidden; @@ -5126,6 +5150,15 @@ inputs[99] = (wood_policy_ == WoodPolicy::kAllowRangers) ? -1 : 0; inputs[100] = (bo.total_count() == 0) ? 3 : 0; inputs[101] = (bo.total_count() == 0) ? 6 : 0; + if (bo.is(BuildingAttribute::kSupportingProducer)) { +if (bo.total_count() == 0) { + inputs[102] = 1; + inputs[103] = 2; + inputs[104] = -2; +} +inputs[105] = -2; +inputs[106] = -2; + } int16_t tmp_score = 0; for (uint8_t i = 0; i < kFNeuronBitSize; ++i) { ___ 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