Loading

Revision differences

Old revision #p7wwtf7xnNew revision #pstwsbjfb
1/* method 1 */         1        local closestTownscopy = AIList();
2//        for (local tile = 0; tile <= AIMap.GetMapSize(); tile++) {  2        for (local town = closestTowns.Begin(); closestTowns.HasNext(); town = closestTowns.Next()) {
3//            if (!AIMap.IsValidTile(tile)) continue;  3            local closest_town = AITile.GetClosestTown(tile);
4//            local dist = AITile.GetDistanceSquareToTile(tile, airport1_tile);  4            if (closestTowns.HasItem(closest_town) {
5//            local fake = WrightAI.DistanceRealFake(tile, airport1_tile);  5                closestTownscopy.AddItem(town);
6//            if (dist <= max_dist && dist >= min_dist && fake <= fakedist * 11 / 10) {    
7//                tileList.AddItem(tile, dist);    
8//                AISign.BuildSign(tile, ("" + dist + ""));    
9//            }    
10//        }    
11//        if (tileList.Count() == 0) {    
12//            //continue;    
13//            AILog.Info("tileList.Count() is 0");    
14//        }    
15//        local closestTownscopy = AIList();    
16//        closestTownscopy.AddList(closestTowns);    
17//        for (local town = closestTownscopy.Begin(); closestTownscopy.HasNext(); town = closestTownscopy.Next()) {    
18//            if (!tileList.HasItem(AITown.GetLocation(town))) {    
19//                closestTowns.RemoveItem(town);    
20//            }    
21//        }    
22    
23/* method 2 */    
24        local closestTownscopy = AIList();    
25        closestTownscopy.AddList(closestTowns);    
26        for (local town = closestTownscopy.Begin(); closestTownscopy.HasNext(); town = closestTownscopy.Next()) {    
27            local dist = AITile.GetDistanceSquareToTile(AITown.GetLocation(town), airport1_tile);    
28            local fake = WrightAI.DistanceRealFake(AITown.GetLocation(town), airport1_tile);    
29            if (!(dist <= max_dist && dist >= min_dist && fake <= fakedist * 11 / 10)) {    
30                closestTowns.RemoveItem(town);    
31            }  6            }  
32        }  32        }
33        AILog.Info("There are " + closestTowns.Count() + " towns near " + AITown.GetName(AITile.GetClosestTown(airport1_tile)));    
34        closestTowns.KeepTop(10);    
35    }