Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat May 25, 2013 3:41 am

All times are UTC




Post new topic Reply to topic  [ 18 posts ] 
Author Message
 Post subject: AIStation.GetCargoRating
PostPosted: Tue Aug 10, 2010 4:08 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
As a matter of design philosophy, I was under the impression that we want to have an AI that does not cheat, but at the same time is not handicapped by missing abilities that a human player has. I may be wrong, but this would be my philosophy.

As such, I am trying to implement what is relatively simple for a human to do, to see how many stations compete for the same cargo at an industry. This is turning into a major undertaking, because we don't have an AIStationList_IndustryCargoTaken(iid,cargo) or some-such. However, that is not at issue here.

With the tools that we have it is not possible to determine if a station is taking a particular cargo. A human can take a look at the cargo rating for a station --- any station --- but the AI can only do this for its own stations, because GetCargoRating is restricted by IsValidStation, which returns false if the station is not the AI's. A number of other AIStation functions are similarly restricted.

I am hoping this is an oversight and not a design decision and that it can be fixed. My view is that IsValidStation should not check if the station is owned by the AI, just that it is a valid station that exists.

While I am at this, can we also get a AIStationList_IndustryCargoTaken(iid,cargo) or something similar. :D It should be fairly simple for the game to produce this, as it must already have such a list to distribute cargo to each station.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
PostPosted: Tue Aug 10, 2010 5:12 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
See FS#2776. At first it was a design decision to let an AI only get information about his own vehicles/stations/etc. At this time I agree that AIs need more information about their opponents, but it is not implemented yet.


Top
 Profile  
 
PostPosted: Tue Aug 10, 2010 8:06 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 3987
Location: /home/sweden
What you can do currently is to check how much cargo that was transported from the industry last month. If it is non-zero and you know that you don't transport that cargo from the industry, then it is easy to say that there is at least one opponent that is transporting away cargo from the industry.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
 Profile  
 
PostPosted: Tue Aug 10, 2010 9:50 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
Yes, I am doing this now, but I needed something better, especially when there are many AIs going after everything on the map. :)

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
PostPosted: Sat Sep 04, 2010 2:36 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
Yexo wrote:
See FS#2776. At first it was a design decision to let an AI only get information about his own vehicles/stations/etc. At this time I agree that AIs need more information about their opponents, but it is not implemented yet.


Is this something we are likely to see in the next version? At least the removal of the ownership restriction on IsValidStation could be removed without much work or effect on existing AIs.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 11:32 am 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
It seems that this topic is being ignored, so I am going to add yet another reason to remove the IsValidStation restriction that prevents getting information on opponent stations.

I want to count the number of airports around a town and if there are already two airports and we are not playing with noise, I don't want to waste time leveling an area just to find out that I can't build another airport.

This seemingly simple task cannot be accomplished, because although I can tell that a tile is a station and I can even get the station Id for it, I cannot tell if it is an airport if it does not belong to me.

So, could you please remove this unnecessary restriction and give AIs the ability to act more intelligently when it comes to evaluating their surroundings.

I am attaching a screenshot that shows the situation.


Attachments:
YATT, 26th Aug 1955.png [319.05 KiB]
Downloaded 1 time

_________________
Attila
"Artificial intelligence is no match for natural stupidity."
Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 11:56 am 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
As a workaround for the airport count issue, I found that AIAirport.IsAirportTile does return true for opponent airports, so I can use that. However, this makes the NoAI API design even more incongruous.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 12:10 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 3987
Location: /home/sweden
As an alternative you could find a clear spot and try to build a heliport (when they are available) to see if it is allowed before leveling land for a intercontinental airport.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 12:42 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
AITown::GetAllowedNoise and AIAirport::GetNoiseLevelIncrease return all the information you need to check if the noise an airport generates is allowed.

Just removing the owner check for IsValidStation creates other problems, because IsValidStation is used by several lists to determine whether or not a station should end up in a list. Because of this it can confuse AIs that are depending on the current behavior of IsValidStation. It also makes the situation even more inconsistent. This change should be implemented, but at the same time there should probably a mechanism for AIs to set whether they want information about their own stations/vehicles/... or about all stations/vehicles/... It has to be designed in a way so it's not much work to upgrade current AIs, but all information is still available. Currently I do not have the time to start this rather big project.

I have no objection to your proposed AIStationList_IndustryCargoTaken, but currently that list would include only your own stations (see above) so I don't think that is what you want.


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 1:20 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
I don't really want to start a big project, only to see info on other stations that is being prevented by IsValidStation also checking if it is MY station.

Perhaps, in the interest of backward compatibility, you could just add a function to turn off the "owned by you" check in IsValidStation.

Something like, AIStation.SetQueryMode(mode) where mode is QUERY_MY_STATIONS_ONLY (default) or QUERY_ALL_STATIONS (what I would like).

Quote:
AITown::GetAllowedNoise and AIAirport::GetNoiseLevelIncrease return all the information you need to check if the noise an airport generates is allowed.


Thanks for this tip. I did not realize that GetNoiseLevelIncrease returns different values for an airport type depending on how the "station_noise_level" is configured.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Last edited by Attila7 on Sun Sep 12, 2010 1:56 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 1:43 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Attila7 wrote:
Perhaps, in the interest of backward compatibility, you could just add a function to turns off the "owned by you" check in IsValidStation.

Something like, AIStation.SetQueryMode(mode) where mode is QUERY_MY_STATIONS_ONLY (default) or QUERY_ALL_STATIONS (what I would like).
That is exactly what I had in mind, except for all features and not only stations. Only it means checking all code that uses any of the IsValid* functions to alter their preconditions with an owner check. Adding it only for stations now means more work later when the same feature is introduced for other things like vehicles.


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 1:55 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
Well, how much work you want to do and when is up to you :) but I am writing my AI now <g> so, I will try and not bug you about this...for a while.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 2:25 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 288
Attila7 wrote:
I am attaching a screenshot that shows the situation.

How did you change the debug window font? This makes it much more readable. Is it a setting somewhere or did you have to recompile?


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 3:47 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
I have a heavily modified build of the game to help me debug the AI scripts.

The font change involves defining "large_font = Courier New" in the cfg and I had to write some code to handle this in the debug window. I also changed the colors and there is a full interactive debugger in there as well. The line you see at the bottom is a command input line and the gold text in the window is what I entered.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 4:04 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Attila7 wrote:
I have a heavily modified build of the game to help me debug the AI scripts.

The font change involves defining "large_font = Courier New" in the cfg and I had to write some code to handle this in the debug window. I also changed the colors and there is a full interactive debugger in there as well. The line you see at the bottom is a command input line and the gold text in the window is what I entered.

That sounds like it could be very useful also for other AI developers. Could you perhaps post a patch with your changes?


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 4:29 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
I intend to, but everything is under development right now.

At some point I will release YATT and then I will document and release the debugger, ATTDebug.

I am also waiting for the next release of OTTD, so we have a stable version for which I can release the debugger, as I constantly have to make changes to keep up with the trunk code in some areas.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 4:39 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
If you release the debugger long enough before the stable than it can perhaps be included in the openttd code. That is, if it's generic enough to be useful also for other AI writers.


Top
 Profile  
 
PostPosted: Sun Sep 12, 2010 5:08 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 34
I am fairly certain that we will need to have a specific build for ATTDebug (patch), because it uses all of the Squirrel libraries, modifies OTTD in many ways to allow running a script while the game is paused (see screenshot PAUSED-DEBUG mode), removes the delay for DoCommands etc, etc.

I am sure all of he AI developers will benefit from using ATTDebug, but I am not yet ready to release it. It is itself being debugged as I develop YATT and the strange ways of handling some issues in Squirrel and OTTD have already created obscure problems (my post about SetOrderFlags not working was a result of the way OTTD handles callbacks on some DoCommands, suspends scripts and the way Squirrel handles the DebugHook procedure.)

I will release the patch and the Squirrel scripts that go with it (ATTDebug is written in Squirrel using the DebugHook procedure) when I will have time to deal with the issues that such a release will most certainly bring to light.

I will not have time to work on YATT next week, so perhaps we will be a little closer to the next version of OTTD by then.

_________________
Attila
"Artificial intelligence is no match for natural stupidity."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000-2013 phpBB Group

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2013.
Hosted by Zernebok Hosting.