Author Topic: [done] AI should space out the buildings such that units don't get stuck  (Read 594 times)

sojourner

  • Guest
At the moment the AI appears to place buildings at a constant spacing of '1' unit distance. That is smaller than some of the larger sized units. The most common of the units that get 'stuck' are the horsemen of tech faction and the turtle formation of the Roman faction.

Ideal spacing in my opinion is one which will allow any unit of one's faction and allies' factions to pass between any two buildings. However, just increasing the spacing from 1 to 2 seems to help matters a great deal.

Here is the code change I made:
Code: [Select]
Index: source/glest_game/ai/ai.cpp
===================================================================
--- source/glest_game/ai/ai.cpp (revision 2152)
+++ source/glest_game/ai/ai.cpp (working copy)
@@ -330,7 +330,7 @@

 bool Ai::findPosForBuilding(const UnitType* building, const Vec2i &searchPos, Vec2i &outPos){

-       const int spacing= 1;
+       const int spacing= 2; /*Sojo: half the max size of any unit ?*/

     for(int currRadius=0; currRadius<maxBuildRadius; ++currRadius){
         for(int i=searchPos.x-currRadius; i<searchPos.x+currRadius; ++i){

Edit: Possible to set for every faction separately by ai-behavior control
« Last Edit: 24 July 2016, 16:23:21 by filux »

 

anything