function TilesInCity(city)
{
tiles = AITileList();
neighbors = AITileList();
function AddNeighbor(tile)
{
if ( AITown.IsWithinTownInfuence(city, tile) )
{
neighbors.AddTile(tile);
tiles.AddTile(tile);
}
}
while ( neighbors.Count() > 0 )
{
t = neighbors.Begin();
neighbors.RemoveTop(1);
// orthogonals
AddNeighbor(tile - AIMap.GetTileIndex(1,0));
AddNeighbor(tile - AIMap.GetTileIndex(0,1));
AddNeighbor(tile - AIMap.GetTileIndex(-1,0));
AddNeighbor(tile - AIMap.GetTileIndex(0,-1));
}
return tiles;
}
function CityOutletRoads(city)
{
outlets = AITileList();
function IsOutlet(tile)
{
if ( !AIRoad.IsRoadTile(tile) )
return false;
neighbors = [
tile - AIMap.GetTileIndex(1,0),
tile - AIMap.GetTileIndex(1,1),
tile - AIMap.GetTileIndex(0,1)
tile - AIMap.GetTileIndex(0,0)
];
neighboringRoads = 0;
foreach ( tile in neighbors )
{
if ( !AITile.IsBuildable(tile) )
return false;
if ( AIRoad.IsRoadTile(tile) )
neighboringRoads++;
}
return neighboringRoads == 1;
}
foreach ( tile, val in TilesInCity(city) )
{
if ( IsOutlet(tile) )
outlets.AddTile(tile);
}
return outlets;
}