Merge lp:~widelands-dev/widelands/bug-1728006 into lp:widelands

Proposed by TiborB
Status: Merged
Merged at revision: 8473
Proposed branch: lp:~widelands-dev/widelands/bug-1728006
Merge into: lp:widelands
Diff against target: 84 lines (+33/-2)
2 files modified
src/ai/ai_help_structs.h (+1/-0)
src/ai/defaultai.cc (+32/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1728006
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+333094@code.launchpad.net

Commit message

Add support for productionsites that are also supporting site to the AI.

Description of the change

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.

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

You should get rid of kPureProducer. Looks good to me otherwise. Not tested yet.

Revision history for this message
TiborB (tiborb95) wrote :

Good catch:) Removed...

Revision history for this message
bunnybot (widelandsofficial) wrote :

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.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have done some testing now.

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ai/ai_help_structs.h'
--- src/ai/ai_help_structs.h 2017-09-29 16:10:25 +0000
+++ src/ai/ai_help_structs.h 2017-11-02 20:15:48 +0000
@@ -78,6 +78,7 @@
78 kUpgradeExtends,78 kUpgradeExtends,
79 kLogRefiner,79 kLogRefiner,
80 kIronMine,80 kIronMine,
81 kSupportingProducer,
81};82};
8283
83enum class AiType : uint8_t { kVeryWeak, kWeak, kNormal };84enum class AiType : uint8_t { kVeryWeak, kWeak, kNormal };
8485
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2017-09-29 16:10:25 +0000
+++ src/ai/defaultai.cc 2017-11-02 20:15:48 +0000
@@ -698,6 +698,11 @@
698 bo.positions.push_back(temp_position.first);698 bo.positions.push_back(temp_position.first);
699 }699 }
700700
701 // If this is a producer, does it act also as supporter?
702 if (!bo.outputs.empty() && !bo.production_hints.empty()) {
703 bo.set_is(BuildingAttribute::kSupportingProducer);
704 }
705
701 iron_ore_id = tribe_->ironore();706 iron_ore_id = tribe_->ironore();
702707
703 if (bo.type == BuildingObserver::Type::kMine) {708 if (bo.type == BuildingObserver::Type::kMine) {
@@ -2649,7 +2654,7 @@
2649 prio -= (bf->enemy_nearby) * 100;2654 prio -= (bf->enemy_nearby) * 100;
2650 prio -= (expansion_type.get_expansion_type() != ExpansionMode::kEconomy) * 100;2655 prio -= (expansion_type.get_expansion_type() != ExpansionMode::kEconomy) * 100;
2651 } else { // finally normal productionsites2656 } else { // finally normal productionsites
2652 assert(bo.production_hints.empty());2657 assert(bo.production_hints.empty() || bo.is(BuildingAttribute::kSupportingProducer));
26532658
2654 if (bo.new_building == BuildingNecessity::kForced) {2659 if (bo.new_building == BuildingNecessity::kForced) {
2655 prio += 150;2660 prio += 150;
@@ -2709,6 +2714,21 @@
2709 }2714 }
2710 }2715 }
27112716
2717 // This is for a special case this is also supporter, it considers
2718 // producers nearby
2719 for (auto ph : bo.production_hints) {
2720 prio += management_data.neuron_pool[51].get_result_safe(
2721 bf->producers_nearby.at(ph) * 5, kAbsValue) /
2722 2;
2723 }
2724
2725 // This considers supporters nearby
2726 for (auto ph : bo.outputs) {
2727 prio += management_data.neuron_pool[52].get_result_safe(
2728 bf->supporters_nearby.at(ph) * 5, kAbsValue) /
2729 2;
2730 }
2731
2712 if (prio <= 0) {2732 if (prio <= 0) {
2713 continue;2733 continue;
2714 }2734 }
@@ -4762,7 +4782,8 @@
4762 bo.cnt_under_construction + bo.unoccupied_count == 0) {4782 bo.cnt_under_construction + bo.unoccupied_count == 0) {
4763 bo.max_needed_preciousness = bo.max_preciousness; // even when rocks are not needed4783 bo.max_needed_preciousness = bo.max_preciousness; // even when rocks are not needed
4764 return BuildingNecessity::kAllowed;4784 return BuildingNecessity::kAllowed;
4765 } else if (!bo.production_hints.empty()) {4785 } else if (!bo.production_hints.empty() && !bo.is(BuildingAttribute::kSupportingProducer)) {
4786 // Pure supporting sites only
47664787
4767 if (bo.cnt_under_construction + bo.unoccupied_count - bo.unconnected_count > 0) {4788 if (bo.cnt_under_construction + bo.unoccupied_count - bo.unconnected_count > 0) {
4768 return BuildingNecessity::kForbidden;4789 return BuildingNecessity::kForbidden;
@@ -5126,6 +5147,15 @@
5126 inputs[99] = (wood_policy_ == WoodPolicy::kAllowRangers) ? -1 : 0;5147 inputs[99] = (wood_policy_ == WoodPolicy::kAllowRangers) ? -1 : 0;
5127 inputs[100] = (bo.total_count() == 0) ? 3 : 0;5148 inputs[100] = (bo.total_count() == 0) ? 3 : 0;
5128 inputs[101] = (bo.total_count() == 0) ? 6 : 0;5149 inputs[101] = (bo.total_count() == 0) ? 6 : 0;
5150 if (bo.is(BuildingAttribute::kSupportingProducer)) {
5151 if (bo.total_count() == 0) {
5152 inputs[102] = 1;
5153 inputs[103] = 2;
5154 inputs[104] = -2;
5155 }
5156 inputs[105] = -2;
5157 inputs[106] = -2;
5158 }
51295159
5130 int16_t tmp_score = 0;5160 int16_t tmp_score = 0;
5131 for (uint8_t i = 0; i < kFNeuronBitSize; ++i) {5161 for (uint8_t i = 0; i < kFNeuronBitSize; ++i) {

Subscribers

People subscribed via source and target branches

to status/vote changes: