(svn r1998) Give penalty 100 to the AI for using foundations (buildonslopes). This prevents it from building long road lines on foundations unless really necessary.
authorpasky
Sat, 12 Mar 2005 08:52:40 +0000
changeset 1494 31436e59176a
parent 1493 414b3608df4d
child 1495 a9e4e2b78877
(svn r1998) Give penalty 100 to the AI for using foundations (buildonslopes). This prevents it from building long road lines on foundations unless really necessary.
ai.h
ai_pathfinder.c
--- a/ai.h	Sat Mar 12 01:02:17 2005 +0000
+++ b/ai.h	Sat Mar 12 08:52:40 2005 +0000
@@ -37,6 +37,8 @@
 #define AI_PATHFINDER_PENALTY 150
 // The penalty given to a tile that is going up
 #define AI_PATHFINDER_TILE_GOES_UP_PENALTY 450
+// The penalty given to a tile which would have to use fundation
+#define AI_PATHFINDER_FOUNDATION_PENALTY 100
 // Changing direction is a penalty, to prevent curved ways (with that: slow ways)
 #define AI_PATHFINDER_DIRECTION_CHANGE_PENALTY 200
 // Same penalty, only for when road already exists
--- a/ai_pathfinder.c	Sat Mar 12 01:02:17 2005 +0000
+++ b/ai_pathfinder.c	Sat Mar 12 08:52:40 2005 +0000
@@ -394,7 +394,11 @@
 	}
 
 	// We should give a penalty when the tile is going up or down.. this is one way to do so!
-	//  Too bad we have to count it from the parent.. but that is not so bad
+	//  Too bad we have to count it from the parent.. but that is not so bad.
+	// We also dislike long routes on slopes, since they do not look too realistic
+	//  when there is a flat land all around, they are more expensive to build, and
+	//  especially they essentially block the ability to connect or cross the road
+	//  from one side.
 	if (parent_ti.tileh != 0 && parent->path.parent != NULL) {
 		// Skip if the tile was from a bridge or tunnel
 		if (parent->path.node.user_data[0] == 0 && current->user_data[0] == 0) {
@@ -403,12 +407,16 @@
 				// Maybe is BRIDGE_NO_FOUNDATION a bit strange here, but it contains just the right information..
 				if (r >= 15 || (r == 0 && (BRIDGE_NO_FOUNDATION & (1 << ti.tileh)))) {
 					res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
+				} else {
+					res += AI_PATHFINDER_FOUNDATION_PENALTY;
 				}
 			} else {
 				if (!(IsRoad(parent->path.node.tile) && IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE))) {
 					r = GetRoadFoundation(parent_ti.tileh, AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
 					if (r >= 15 || r == 0)
 						res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
+					else
+						res += AI_PATHFINDER_FOUNDATION_PENALTY;
 				}
 			}
 		}