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

NoAI can't see competitor stations and vehicles #2776

Closed
DorpsGek opened this issue Mar 30, 2009 · 5 comments
Closed

NoAI can't see competitor stations and vehicles #2776

DorpsGek opened this issue Mar 30, 2009 · 5 comments
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

bilbo opened the ticket and wrote:

When browsing NoAI API, I noticed that for station and vehicle lists, you can get only your own sattions and vehicles. This puts NoAI to disadvantageous position - humans can watch competitors construction and vehicles, NoAI can't. Knowing position of opponents station can help when building station in cities (if city is large, it is usually more profitable to build the station on the other side of city instead of building next to opponents and then competing for passengers), knowing position of road vehicles can help with road pathfinder (assign small penalty for tiles occupied by enemy vehicles, as our vehicles will have to move through the "crowd" and possibly get stuck in a traffic jam)

Both will allow the AI to learn from opponent in general (if AI sees that opponent is making most of money by transporting coal, then AI can start preferring transporting coal too, as it obviously is profitable in current game setting)

There are now:
AIStationList Creates a list of stations of which you are the owner
AIVehicleList Creates a list of vehicles of which you are the owner

I suggest to add also something like:
AICompanyStationList(CompanyID) Creates a list of stations belonging to given company
AICompanyVehicleList(CompanyID) Creates a list of vehicles belonging to given company

Similar additions can be made also to AIDepotList and AIWaypointList for consistency, though I don't think it is of much use to watch competitor's depots or waypoints.

Reported version: trunk
Operating system: All


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

Yexo wrote:

This was an explicit design decision for the API and won't be changed now. Just getting a list of StationIDs of your opponents stations isn't usefull, as all API functions have @pre IsValidStation(station_id), and IsValidStation returns false for stations not owned by you. Changed IsValidStation could break current AIs, so that's not going to happen. Therefor there is no easy solution to allow querying more information about your opponents.

I'm marking this very low severity, as it won't change now but we might want to rethink about it in the future.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2776#comment5866

@DorpsGek
Copy link
Member Author

bilbo wrote:

There could be switch of modes (
ExamineOnlyMyOwnStationsAndVehicles (being default) and ExamineAllStationsAndVehicles) that will switch the isValidStation/isValidVehicle/etc... to stop checking for owner (or only check the owner for attempts to modify the given station/vehicle) for AI that called it.

This won't break any current AI's (they won't know of the modes, so they won't switch to "see all stations" mode and they won't know about the new functions so they won't call them) and AI's that know of the modes can use it to examine the opponents. And of course they have to be aware of consequences and know that not all stuff is theirs. In that case, perhaps in AIVehicle and AIStation some function to ask about owner could be added for completeness.

So if AI receives AIEventStationFirstVehicle for opponents vehicle, any attempts to discover whose vehicle or station it is will fail with "invalid vehicle/station"?


This comment was imported from FlySpray: https://bugs.openttd.org/task/2776#comment5868

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 1, 2009

Yexo wrote:

"So if AI receives AIEventStationFirstVehicle for opponents vehicle, any attempts to discover whose vehicle or station it is will fail with "invalid vehicle/station"?"

An AI will never receive that events for vehicles from other companies.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2776#comment5875

@DorpsGek
Copy link
Member Author

bilbo wrote:

I got idea how this could be done relatively easily without breaking the API.

Add AIController.SetFilter(FilterFlags)

where FilterFlags would be be bitflags of:

SEE_OWN_VEHICLES - Allow seeing/querying my own vehicles
SEE_OTHER_VEHICLES - Allow seeing/querying my own vehicles
SEE_OWN_STATIONS - Allow seeing/querying my own stations
SEE_OTHER_STATIONS - Allow seeing/querying my own stations
EVENT_OWN - Allow receiving events about my vehicles/stations/etc...
EVENT_OTHERS - Allow receiving events about opponents vehicles/stations/etc...

Default would be (SEE_OWN_STATIONS | SEE_OWN_VEHICLES | EVENT_OWN)

Every company will have field with its filter.

And checks like "v->owner == _current_company" in IsValidVehicle could be replaced by some inline function that will check also with the filter:
->
"CheckOwnerFilter(v->owner == _current_company, filter)"

inline bool CheckOwnerFilter(bool my_vehicle,Filter filter) {
if (my_vehicle) return (Filter & VEHICLE_MINE) else return (Filter & VEHICLE_OTHERS);
}

Also, maybe adding few functions to query owner to objects that don't have them (like AIBridge have no method to query ownerID) would be useful if tyhis is implemented.

Overall the change will be relatively minimal and AI not knowing of it will behave as before.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2776#comment5951

@DorpsGek
Copy link
Member Author

andythenorth closed the ticket.

Reason for closing: Won't implement

Flyspray clean up: more than 5 years old, and not obvious what should be done with this next, so closing. If this offends, discuss with andythenorth in irc. Thanks.


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

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) wontfix component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 6, 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