← Back to team overview

widelands-dev team mailing list archive

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

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/ai_buildinglimit_savegames into lp:widelands.

Commit message:
Removed cnt_limit_by_aimode asserts from AI code because they're breaking savegame compatibility.

Requested reviews:
  TiborB (tiborb95)

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

The asserts are causing problems for me when I want to test with older savegames in debug mode. I hope the log messages will be sufficient for AI development.
-- 
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_buildinglimit_savegames.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc	2017-11-09 17:37:13 +0000
+++ src/ai/defaultai.cc	2017-11-12 16:57:44 +0000
@@ -3639,12 +3639,11 @@
 	// Get link to productionsite that should be checked
 	ProductionSiteObserver& site = productionsites.front();
 
-	// Make sure we are not above ai type limit
+	// Inform if we are above ai type limit.
 	if (site.bo->total_count() > site.bo->cnt_limit_by_aimode) {
-		log("Too many %s: %d, ai limit: %d\n", site.bo->name, site.bo->total_count(),
+		log("AI check_productionsites: Too many %s: %d, ai limit: %d\n", site.bo->name, site.bo->total_count(),
 		    site.bo->cnt_limit_by_aimode);
 	}
-	assert(site.bo->total_count() <= site.bo->cnt_limit_by_aimode);
 
 	// first we werify if site is working yet (can be unoccupied since the start)
 	if (!site.site->can_start_working()) {
@@ -4564,7 +4563,12 @@
 	// And finally the 'core' of this function
 	// First deal with construction of new sites
 	if (purpose == PerfEvaluation::kForConstruction) {
-		assert(bo.total_count() <= bo.cnt_limit_by_aimode);
+		// Inform if we are above ai type limit.
+		if (bo.total_count() > bo.cnt_limit_by_aimode) {
+			log("AI check_building_necessity: Too many %s: %d, ai limit: %d\n", bo.name, bo.total_count(),
+				 bo.cnt_limit_by_aimode);
+		}
+
 		if (bo.forced_after < gametime && bo.total_count() == 0 && !has_substitution_building) {
 			if (!bo.is(BuildingAttribute::kBarracks)) {
 				bo.max_needed_preciousness = bo.max_preciousness;

=== modified file 'src/ai/defaultai_warfare.cc'
--- src/ai/defaultai_warfare.cc	2017-11-06 20:19:56 +0000
+++ src/ai/defaultai_warfare.cc	2017-11-12 16:57:44 +0000
@@ -575,12 +575,11 @@
 	TrainingSite* ts = trainingsites.front().site;
 	TrainingSiteObserver& tso = trainingsites.front();
 
-	// Make sure we are not above ai type limit
+	// Inform if we are above ai type limit.
 	if (tso.bo->total_count() > tso.bo->cnt_limit_by_aimode) {
-		log("AI player %d: count of %s exceeds an AI limit %d: actual count: %d\n", player_number(),
+		log("AI check_trainingsites: AI player %d: count of %s exceeds an AI limit %d: actual count: %d\n", player_number(),
 		    tso.bo->name, tso.bo->cnt_limit_by_aimode, tso.bo->total_count());
 	}
-	assert(tso.bo->total_count() <= tso.bo->cnt_limit_by_aimode);
 
 	const DescriptionIndex enhancement = ts->descr().enhancement();
 
@@ -810,8 +809,11 @@
 	// Make sure we have statistics about our enemies up-to-date
 	update_player_stat(gametime);
 
-	// Make sure we are not above ai type limit
-	assert(militarysites.front().bo->total_count() <= militarysites.front().bo->cnt_limit_by_aimode);
+	// Inform if we are above ai type limit.
+	if (militarysites.front().bo->total_count() > militarysites.front().bo->cnt_limit_by_aimode) {
+		log("AI check_militarysites: Too many %s: %d, ai limit: %d\n", militarysites.front().bo->name, militarysites.front().bo->total_count(),
+		    militarysites.front().bo->cnt_limit_by_aimode);
+	}
 
 	FCoords f = game().map().get_fcoords(ms->get_position());
 


Follow ups