[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_trainingsites_proportion into lp:widelands

2017-06-17 Thread noreply
The proposal to merge lp:~widelands-dev/widelands/ai_trainingsites_proportion 
into lp:widelands has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/ai_trainingsites_proportion/+merge/324607
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.

___
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_trainingsites_proportion into lp:widelands

2017-06-16 Thread bunnybot
Refusing to merge, since Travis is not green. Use @bunnybot merge force for 
merging anyways.

Travis build 2306. State: failed. Details: 
https://travis-ci.org/widelands/widelands/builds/243567535.
-- 
https://code.launchpad.net/~widelands-dev/widelands/ai_trainingsites_proportion/+merge/324607
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.

___
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_trainingsites_proportion into lp:widelands

2017-06-16 Thread bunnybot
Continuous integration builds have changed state:

Travis build 2306. State: failed. Details: 
https://travis-ci.org/widelands/widelands/builds/243567535.
Appveyor build 2140. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_ai_trainingsites_proportion-2140.
-- 
https://code.launchpad.net/~widelands-dev/widelands/ai_trainingsites_proportion/+merge/324607
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.

___
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_trainingsites_proportion into lp:widelands

2017-06-16 Thread GunChleoc
Thanks for the review :)

@bunnybot merge
-- 
https://code.launchpad.net/~widelands-dev/widelands/ai_trainingsites_proportion/+merge/324607
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.

___
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_trainingsites_proportion into lp:widelands

2017-06-15 Thread TiborB
Review: Approve

The code was already merged and thus tested in AI branch, so this should be 
safe to merge to trunk. Though I must admit I did not specifically look if this 
does what it should. Anyway I think it can go
-- 
https://code.launchpad.net/~widelands-dev/widelands/ai_trainingsites_proportion/+merge/324607
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.

___
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_trainingsites_proportion into lp:widelands

2017-05-25 Thread bunnybot
Continuous integration builds have changed state:

Travis build 2246. State: passed. Details: 
https://travis-ci.org/widelands/widelands/builds/236078100.
Appveyor build 2081. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_ai_trainingsites_proportion-2081.
-- 
https://code.launchpad.net/~widelands-dev/widelands/ai_trainingsites_proportion/+merge/324607
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.

___
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_trainingsites_proportion into lp:widelands

2017-05-25 Thread GunChleoc
GunChleoc has proposed merging 
lp:~widelands-dev/widelands/ai_trainingsites_proportion into lp:widelands.

Commit message:
Added new entry "trainingsites_max_percent" to AI building hints. If this is 
not set, the percentages will be evenly distributed while loading the tribe. 
TribeDescr now has a new convenience function trainingsites().

Requested reviews:
  TiborB (tiborb95)

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

Let's get this in before the big AI change, to make the diff smaller.
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.
=== modified file 'data/tribes/buildings/trainingsites/empire/arena/init.lua'
--- data/tribes/buildings/trainingsites/empire/arena/init.lua	2017-02-10 09:40:17 +
+++ data/tribes/buildings/trainingsites/empire/arena/init.lua	2017-05-25 09:38:21 +
@@ -38,6 +38,7 @@
 
aihints = {
   trainingsite_type = "basic",
+  trainingsites_max_percent = 20,
   prohibited_till = 900,
   very_weak_ai_limit = 1,
   weak_ai_limit = 2,

=== modified file 'src/ai/ai_hints.cc'
--- src/ai/ai_hints.cc	2017-01-25 18:55:59 +
+++ src/ai/ai_hints.cc	2017-05-25 09:38:21 +
@@ -44,7 +44,10 @@
  very_weak_ai_limit_(
 table->has_key("very_weak_ai_limit") ? table->get_int("very_weak_ai_limit") : -1),
  weak_ai_limit_(table->has_key("weak_ai_limit") ? table->get_int("weak_ai_limit") : -1),
- trainingsite_type_(TrainingSiteType::kNoTS) {
+ trainingsite_type_(TrainingSiteType::kNoTS),
+ trainingsites_max_percent_(table->has_key("trainingsites_max_percent") ?
+   table->get_int("trainingsites_max_percent") :
+   0) {
 
 	if (table->has_key("trainingsite_type")) {
 		if (table->get_string("trainingsite_type") == "basic") {
@@ -54,3 +57,11 @@
 		}
 	}
 }
+
+void BuildingHints::set_trainingsites_max_percent(uint8_t percent) {
+	trainingsites_max_percent_ = percent;
+}
+
+uint8_t BuildingHints::trainingsites_max_percent() const {
+	return trainingsites_max_percent_;
+}

=== modified file 'src/ai/ai_hints.h'
--- src/ai/ai_hints.h	2017-01-25 18:55:59 +
+++ src/ai/ai_hints.h	2017-05-25 09:38:21 +
@@ -115,6 +115,10 @@
 		return trainingsite_type_;
 	}
 
+	void set_trainingsites_max_percent(uint8_t percent);
+
+	uint8_t trainingsites_max_percent() const;
+
 private:
 	std::string renews_map_resource_;
 	std::string mines_;
@@ -134,6 +138,7 @@
 	int16_t very_weak_ai_limit_;
 	int16_t weak_ai_limit_;
 	TrainingSiteType trainingsite_type_;
+	int trainingsites_max_percent_;
 
 	DISALLOW_COPY_AND_ASSIGN(BuildingHints);
 };

=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc	2017-05-21 06:14:28 +
+++ src/logic/map_objects/tribes/building.cc	2017-05-25 09:38:21 +
@@ -189,6 +189,14 @@
 	   size_ <= (fc.field->nodecaps() & Widelands::BUILDCAPS_SIZEMASK);
 }
 
+const BuildingHints& BuildingDescr::hints() const {
+	return hints_;
+}
+
+void BuildingDescr::set_hints_trainingsites_max_percent(int percent) {
+	hints_.set_trainingsites_max_percent(percent);
+}
+
 /**
  * Normal buildings don't conquer anything, so this returns 0 by default.
  *

=== modified file 'src/logic/map_objects/tribes/building.h'
--- src/logic/map_objects/tribes/building.h	2017-05-21 11:16:46 +
+++ src/logic/map_objects/tribes/building.h	2017-05-25 09:38:21 +
@@ -156,10 +156,9 @@
 
 	WorkareaInfo workarea_info_;
 
-	bool suitability(const Map&, const FCoords&) const;
-	const BuildingHints& hints() const {
-		return hints_;
-	}
+	virtual bool suitability(const Map&, const FCoords&) const;
+	const BuildingHints& hints() const;
+	void set_hints_trainingsites_max_percent(int percent);
 
 protected:
 	virtual Building& create_object() const = 0;

=== modified file 'src/logic/map_objects/tribes/tribe_descr.cc'
--- src/logic/map_objects/tribes/tribe_descr.cc	2017-04-30 10:30:02 +
+++ src/logic/map_objects/tribes/tribe_descr.cc	2017-05-25 09:38:21 +
@@ -172,6 +172,11 @@
 }
 buildings_.push_back(index);
 
+// Register trainigsites
+if (get_building_descr(index)->type() == MapObjectType::TRAININGSITE) {
+	trainingsites_.push_back(index);
+}
+
 // Register construction materials
 for (const auto& build_cost : get_building_descr(index)->buildcost()) {
 	if (!is_construction_material(build_cost.first)) {
@@ -188,6 +193,36 @@
 			}
 		}
 
+		// Set default trainingsites proportions for AI. Make sure that we get a sum of ca. 100
+		float trainingsites_without_percent = 0.f;
+		int used_percent = 0;
+		for (const DescriptionIndex& index : trainingsites_) {
+			const BuildingDescr& descr = *tribes_.get_building_descr(index);
+			if (descr.hints().trainingsites_max_percent() == 0) {
+++trainingsites_without_percent;
+			} else {
+used_percent += 

[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_trainingsites_proportion into lp:widelands

2017-05-25 Thread GunChleoc
The proposal to merge lp:~widelands-dev/widelands/ai_trainingsites_proportion 
into lp:widelands has been updated.

Commit Message changed to:

Added new entry "trainingsites_max_percent" to AI building hints. If this is 
not set, the percentages will be evenly distributed while loading the tribe. 
TribeDescr now has a new convenience function trainingsites().

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/ai_trainingsites_proportion/+merge/324607
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_trainingsites_proportion.

___
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