Can you outsmart the AIs? AI test scenarios

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Can you outsmart the AIs? AI test scenarios

Post by GeekToo »

Last night I talked on IRC with some AI-developer colleagues about the fact that I use a couple of simple scenarios to test Convoy. And that, to my surprise, even for some very simple scenarios, our AIs fail miserably.

I like AIs to be smart, in fact I like that even more than their ability to make lots of money. That's why I sometimes try to create a simple scenario and see how the AI reacts, to prove that humans still are smarter.

Here's an example, if someone else has some test scenarios, please do post them here. I think we all can learn from it to make our AIs (even) smarter

Here's another example, created by Rubidium some time ago: http://www.tt-forums.net/viewtopic.php?p=703535#p703535
Attachments
Unnamed, 15th Sep 1951.png
Unnamed, 15th Sep 1951.png (64.19 KiB) Viewed 6330 times
towntest2.scn
(13.35 KiB) Downloaded 189 times
Last edited by GeekToo on 21 Mar 2009 12:24, edited 1 time in total.
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13235
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: Can you outsmart the AIs? AI test scenarios

Post by Hyronymus »

Just out of interest for the AI's that allow airplanes: what if airplanes are not allowed? How does that affect profitability? I'm under the impression that (earl) airplanes are difficult for the AI to manage.
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Can you outsmart the AIs? AI test scenarios

Post by GeekToo »

It would be hard to make a profit in that situation, but the smart thing to do would be to not start building, instead of just starting to build all kinds of stations, and making a loss.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: Can you outsmart the AIs? AI test scenarios

Post by Zutty »

Good one GeekToo. I'm very interested in this sort of thing.

It takes a while but PathZilla is eventually able to turn a profit amongst all the competition. By itself PathZilla does much better, but Convoy really squeezes it.

Its quite remarkable how Convoy is able to assert dominance so early with only five vechiles and two stations. Well done :bow:

At the moment I'm still fixing stupid bugs (it took me all morning to make it work with your scenario - turned out to be a freaking typo!) but in general I like to try to test my AI in sub-optimal situations like this.

I'll see if I can come up with some interesting scenarios.
Attachments
geektoo-testscn1.png
geektoo-testscn1.png (70.28 KiB) Viewed 6219 times
PathZilla - A networking AI - Now with tram support.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Can you outsmart the AIs? AI test scenarios

Post by Morloth »

Hyronymus wrote:Just out of interest for the AI's that allow airplanes: what if airplanes are not allowed? How does that affect profitability? I'm under the impression that (earl) airplanes are difficult for the AI to manage.
With airplanes NoCAB, Convoy and AdmiralAI at on par for the first 3 years after which NoCAB dominates (typical 512x512 map). But without it Convoy dominates for the first 10 years as its city handling code is way better than NoCABs at the moment; For each pair of city I allow only 1 connection (an airport or bus station), while Convoy builds several and gets more leverage and money for doing that and since passengers are the most profitable cargo to transport it's quite a challenge to do better for the initial years (without aircrafts that is). Perhaps trains can change that, but we'll have to see once that's implemented.

I don't see how early airplanes are difficult the manage, they require less work than road vehicles in my experience :).
defaultluser
Engineer
Engineer
Posts: 34
Joined: 01 Mar 2009 19:56

Re: Can you outsmart the AIs? AI test scenarios

Post by defaultluser »

Well, you've all seen some of my scenarios. Some things I've seen:

PAX can't compete without a $300k start loan. Otherwise, it blows too much money on infrastructure building an airport and several transfer stations. It usually goes-under.

None of the AIs have been able to compete in desert climate on Hard settings, even if I give them 300k start money. NoCAB makes the foolish error of trying to cart diamonds using aircraft, and Admiral AI wastes money on multiple lines, and is forced to settle for road vehicles. All the AIs can't seem to deal with the higher cost of everything here. Here is a game I played recently on these settings, where ALL AIs in the game (PAX, Admiral, NoCAB and Fanioz) went under at least once.

The save game is before the AIs failed, in 1961. You can see that NoCAB is on the way to failure, making a pittance off those two diamond planes, and Fanioz is doing the best. Eventually, ALL AIs went bankrupt.
Attachments
Pladingham Transport, 27th Apr 1961.sav
(111.89 KiB) Downloaded 171 times
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Can you outsmart the AIs? AI test scenarios

Post by Morloth »

I actually looked into it and was quite surprised as well that NoCAB did this, but as it turns out. I believe the problem is with the AIEngine.GetCapaciy function, it only takes an engine ID as a parameter, but when you refit it with and other cargo this value changes. So for Coleman Count it reports it can hold 65 bags of diamonds, while in actuality it can only hold 18!

I'd like to post a request to Yexo to change the function from:

AIEngine.GetCapacity(EngineID) to AIEngine.GetCapacity(EngineID, CargoID)

That should solve the problem I think. For now I use the following piece of code to 'fix' it, but it will undoubtedly fail with a random NewGRF package...

Code: Select all

if (AIEngine.GetVehicleType(engineID) == AIVehicle.VT_AIR &&
    AICargo.HasCargoClass(AIEngine.GetCargoType(engineID), AICargo.CC_PASSENGERS) && 
    !AICargo.HasCargoClass(cargoID, AICargo.CC_PASSENGERS) &&
    !AICargo.HasCargoClass(cargoID, AICargo.CC_MAIL)) {
   if (AICargo.GetTownEffect(cargoID) == AICargo.TE_GOODS)
      transportedCargoPerVehiclePerMonth *= 0.6;
   else
      transportedCargoPerVehiclePerMonth *= 0.3;
}
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Can you outsmart the AIs? AI test scenarios

Post by fanioz »

defaultluser wrote:Well, you've all seen some of my scenarios. Some things I've seen:
....
....
Eventually, ALL AIs went bankrupt.
I can load the savegame, but when I push the resume button, suddenly FanAI (yellow) become Convoy. And NoCAB (green) become FanAI. Admiral dan PaxLink still got correct. I don't really know, whether that was because load/save unsupported yet, or any other reason. :cry:
Morloth wrote:I actually looked into it and was quite surprised as well that NoCAB did this, but as it turns out. I believe the problem is with the AIEngine.GetCapaciy function, it only takes an engine ID as a parameter, but when you refit it with and other cargo this value changes. So for Coleman Count it reports it can hold 65 bags of diamonds, while in actuality it can only hold 18!

I'd like to post a request to Yexo to change the function from:

AIEngine.GetCapacity(EngineID) to AIEngine.GetCapacity(EngineID, CargoID)

....
[/code]
Hi morloth, IMHO AIVehicle::GetRefitCapacity(vehicle_id, CargoID) would give the same result. That is the capacity of vehicle after refit to cargoID. But never try that yet :lol: (just waiting a comment from yexo) :lol:
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Can you outsmart the AIs? AI test scenarios

Post by Morloth »

fanioz wrote: Hi morloth, IMHO AIVehicle::GetRefitCapacity(vehicle_id, CargoID) would give the same result. That is the capacity of vehicle after refit to cargoID. But never try that yet :lol: (just waiting a comment from yexo) :lol:
That's true, but it requires you to build a vehicle first. And it's quite expensive to first build an airfield, aircraft, and only then being able to get the cargo capacity. Must be a better way without wasting money ;).
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Can you outsmart the AIs? AI test scenarios

Post by planetmaker »

Morloth wrote:That's true, but it requires you to build a vehicle first. And it's quite expensive to first build an airfield, aircraft, and only then being able to get the cargo capacity. Must be a better way without wasting money ;).
It is. But it would give the AIs access to something the human players don't have either. If I err, please tell me how I determine the refitted cargo capacity w/o actually building something :)
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Can you outsmart the AIs? AI test scenarios

Post by fanioz »

Morloth wrote: That's true, but it requires you to build a vehicle first. And it's quite expensive to first build an airfield, aircraft, and only then being able to get the cargo capacity.
You're right.. (in that case: aircraft can only build on hangar -> airport) but I really do something like that. I build depot, buy a road vehicle (wich is more cheap than aircraft), and if I can't give it an order to go to one of my station/depot then I sell it to prevent invalid order :D (mostly because George long_vehicle.grf 's)
Morloth wrote:Must be a better way without wasting money ;).
For this reason ..... I agree with you :lol:
planetmaker wrote: It is. But it would give the AIs access to something the human players don't have either. If I err, please tell me how I determine the refitted cargo capacity w/o actually building something :)
For this reason ..... I agree too with you :lol:

Back to topic. Is there any other scenario to test?
Edit: I'm asking because I can't pass that scenario :lol:
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
££asai0*saim
Engineer
Engineer
Posts: 11
Joined: 19 Mar 2009 02:43

Re: Can you outsmart the AIs? AI test scenarios

Post by ££asai0*saim »

Hi GeekToo,
I just downloaded the AI Convoy and dont know whether its applied to my game and if its working does it work after a while like 2-3 years? it should disable other kinds of transport right? please could you tell me whether it would work or if theres something else i have to do. i have the openttd version 0.7.0-RC1 thanks
defaultluser
Engineer
Engineer
Posts: 34
Joined: 01 Mar 2009 19:56

Re: Can you outsmart the AIs? AI test scenarios

Post by defaultluser »

££asai0*saim wrote:Hi GeekToo,
I just downloaded the AI Convoy and dont know whether its applied to my game and if its working does it work after a while like 2-3 years? it should disable other kinds of transport right? please could you tell me whether it would work or if theres something else i have to do. i have the openttd version 0.7.0-RC1 thanks
Convoy doesn't support save/loading of games, that's currently on the to-do list. I've also seen it stop building even without a save/load, which is really weird, because I didn't see a crash log.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: Can you outsmart the AIs? AI test scenarios

Post by Zutty »

I also like a function to get the capacity of individual cargos. I note that with andythenorth's HEQS set its not really feasible to use many of the refittable vehicles as the reported capacity from AIEngine is -1.
PathZilla - A networking AI - Now with tram support.
jui-feng
Engineer
Engineer
Posts: 35
Joined: 01 Feb 2009 15:20
Location: Germany

Re: Can you outsmart the AIs? AI test scenarios

Post by jui-feng »

I still had Pathzilla v5 with some changes (modified number of vehicles in a service) installed, so I tried this scenario with PathZilla (modified) and Admiral.

Admiral did nothing at all. I wonder what's the reason for that? Basically, it's only two towns right next to each other?

Pathzilla behaved nicely first. However it started jamming the roads in ~1963. A few years later, a new connection between the 2 cities emerged and the traffic jam problem was solved. Now a per-service hard limit for vehicles was reached (based on distance of cities, vehicle capacity and speed) and so the map is stuck at 75 vehicles. Some of them are busses and some are post trucks.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Can you outsmart the AIs? AI test scenarios

Post by fanioz »

Any body would try this ? :lol:
Attachments
town-industry.test.scn
(14.66 KiB) Downloaded 182 times
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
jui-feng
Engineer
Engineer
Posts: 35
Joined: 01 Feb 2009 15:20
Location: Germany

Re: Can you outsmart the AIs? AI test scenarios

Post by jui-feng »

Which GRFs are needed for your scenario, fanioz?

[update]nevermind, got it working.. :-) Admiral and PathZilla seem to take forever to find a route. Or maybe I accidentally hit the pause key? Now that I think of it, the CPU seemed quite idle... I will try again later.[/update]
Last edited by jui-feng on 26 Mar 2009 07:23, edited 1 time in total.
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Can you outsmart the AIs? AI test scenarios

Post by GeekToo »

Only the games original grfs, it worked for me without newgrfs.

It's a nice scenario indeed Fanioz, none of the AIs I've tried so far succeeded in making a profit. Then I tried myself, and though it took some time, I succeeded in making some money. So humans still rule!
defaultluser
Engineer
Engineer
Posts: 34
Joined: 01 Mar 2009 19:56

Re: Can you outsmart the AIs? AI test scenarios

Post by defaultluser »

GeekToo wrote:Only the games original grfs, it worked for me without newgrfs.

It's a nice scenario indeed Fanioz, none of the AIs I've tried so far succeeded in making a profit. Then I tried myself, and though it took some time, I succeeded in making some money. So humans still rule!

It's not hard for humans to make money in this scenario, because the cash and low costs mean you can afford a massive train line. In just three years I was making $1.3 million profit per year.

What really killed the AIs when I played was they were forced to use road vehicles, and they didn't space-out depots along their lines. Thus, road vehicles would turn around at the halfway point.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Can you outsmart the AIs? AI test scenarios

Post by fanioz »

First time I made this scenario is to test how Ai path finding work. In the hope that no one can servicing town or industry except human player. But I'm failed, because convoy does good job:). And NoCab does terraforming to build airport and build road on coast. Although it is unprofitable much.
Defaultuser, is it reasonable for ai to build depot along route? Imo, (and is implemented by fanai, which is build depot near source and destination) giving the vehicles an explicit goto depot order would prevent them search other depot. (Still needed to be proven:)) anyway thanks all for the feedback.
Hope to find an other test scenario. ;)
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 1 guest