Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIStation::IsWithinTownInfluence doesn't report a station put north a town #4702

Closed
DorpsGek opened this issue Jul 30, 2011 · 4 comments
Closed
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

krinn opened the ticket and wrote:

description in the api state :

"Find out if this station is within the rating influence of a town. "
It's conflicting with just checking one tile of a station, as the ai dev expect a real answer as if any tiles of the station are within the town influence, that station will be useable with that town.

the function itself (from ai_station.cpp) isn't bug, and do what it was made for, but the logic show weakness and finally end-up returning a bad result, as a station could be in the town influence but the function will says false
/* static */ bool AIStation::IsWithinTownInfluence(StationID station_id, TownID town_id)
{
if (!IsValidStation(station_id)) return false;

return AITown::IsWithinTownInfluence(town_id, GetLocation(station_id));

It could be easy solve in squirrel with :
function IsWithinTownInfluence(stationid, townid)
{
stationtiles= (well, all tiles to check, should be all tiles of the station)
foreach (tile, dummy in stationtile) { if (AITile.IsWithinTownInfluence(tile, townid)) return true; }
return false;
}

That bug/weakness/mistake/misinterpretation... of conception isn't really seen by most ai devs because we need, not a big race condition to see it, but a special condition :
1 station tile must be within town influence + top station tile must be outside town influence.

And because of how all structure building functions works in noai (give the stration toptile position to build it) it's generally impossible to see that effect. As common use makes you filter tiles that are within a town influence, then you pick the best... any tile, and just try to build your station from that tile, and as the build station take top tile to build the station, you endup with 1/ station is too close from town and cannot find a position to put your station or 2/ you indeed have space for the station, and toptile == a tile within town influence.
So "common use" prevent building big structure north of town, and prevent that "bug" seen with their top tile outside town influence.

Now if i made an airport 10 tiles deep, 5 tiles outside station influence + 5 tiles within (of course north of the town): then toptile is outside town influence and the AIStation.IsWithinTownInfluence will return false

So:
- the function should be change to return true if any station tiles is within the town influence

or the doc:
- "Find out if this station is within the rating influence of a town." -> Find out if this station toptile is within the rating influence of a town
-"True if the tile is within the rating influence of the town."->"True if the station top tile is ...".
- And maybe an additional warning to ai dev to point out/remind them this special case

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/4702
@DorpsGek
Copy link
Member Author

frosch wrote:

You are misunderstanding the meaning of "town influence" in the game mechanics.
A station is within town influence, if the service quality at it affects the town rating. This is a property of the whole station, not of a single tile.
A tile is within town influcence, if building something on it affects the town rating. This is a property of a single tile.

Edit: I.e. what you are experiencing is the weirdness of some aspects of the game mechanics, and not a bug in the NoAI API. If the station sign is far away from the town, the station will not affect the town rating, even if some parts of the station are close to the town.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4702#comment10123

@DorpsGek
Copy link
Member Author

krinn wrote:

that's indeed kinda weird, what you are saying is that such airport would :
1/ take town rating damage by its constrution because lower tiles are own & influence the town
2/ won't take benefits to town rating because the station sign is too far

Just hope at least town rating doesn't get mad seeing the few tiles in its influence and never then see it's working (poor town rating for having a "not working" station in its influence") or the station is totally ignore ?
Also good to know how contrary works too: airport south of town with toptile within town influence area, but lower tiles outside, how this is handle from town point of view. Because it could mean a small airport with all its tiles within the boundaries of the town influence gave better results for a town vs a bigger airport that have some tiles outside the town limits.

Anyway never really think it's a bug from the api or the function itself, more the doc that need a better clarification imo.
Don't you think it might be better of such special mechanic expose to the aidev or at least a more clear "using top tile of station" than just "station" or "tile"?


This comment was imported from FlySpray: https://bugs.openttd.org/task/4702#comment10125

@DorpsGek
Copy link
Member Author

frosch wrote:

Attached diff slightly changes the wording of AITile.IsWithinTownInfluence and AITown.IsWithinTownInfluence.
While these functions are duplicate (and thus should be removed according to the API policy), they may be required both for Valuators.

The diff also adds a function AITile::GetTownAuthority which reports the town affected by tree removal/planting and station construction.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4702#comment10127

@DorpsGek
Copy link
Member Author

frosch closed the ticket.

Reason for closing: Fixed

in r22763, r22764


This comment was imported from FlySpray: https://bugs.openttd.org/task/4702

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant