SimpleAI v14 - trying to remake the old AI

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

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI alpha5 - trying to remake the old AI

Post by Brumi »

Zuu wrote:I check the age of the youngest vehicle of all the vehicles of a given connection and then don't build new buses if the youngest one is too young.
Thank you, that is really a good and simple idea, much better than adding extra variables. It's quite a shame I didn't think of it... :oops:
Eliandor wrote:Awesome, congrats on another release.
I think there's a flaw in the logging. It says "I got the subsidy: PASS from (null: 0x00000000) to (null: 0x00000000)". It's a subsidy obtained by the use of Double Rail. The routes themselves have been built perfectly fine.
Thank you :)
That is again something with the new subsidy system, now the endpoints of already taken subsidies are towns/industries, not stations. The AI expects stations there. Anyway, it has no impact on the game, so I think the best is to simply skip that part of the code if the AI is run on the nightly. I'll surely correct it when this new subsidy system gets into the stable release.
This one is a bit strange for me: a subsidy obtained by the use of double rail? That means that subsidies tend to be longer than in 0.7.2. Do you know the new maximum distance for subsidies?
Eliandor wrote:Suggestion: you only have two types of passing lanes in your library, right? One for North-South and one for East-West. You could try adding two more, for the same directions. If you're building passing lanes, check whether the station is more to the East of to the West, or to the North / the South (depending on the direction of the track), and flip the passing lane when applicable.
Mm complicated to explain. I'll add a screenshot of a situation where that would be a great thing to do in a second...
Do you mean... this?
passing lanes.png
(103.16 KiB) Downloaded 1 time
It should be quite easy to do.
Eliandor wrote:Oh and also: you could consider adding even more passing lanes: for diagonal tracks as well :P but that's not really a big thing.

Another suggestion: let the number of passing lanes be dependent on the manhattan distance. At the moment it always builds two, that falls short for some routes.
I'd rather not code diagonal passing lane sections yet, they would be quite complicated compared to their usefulness.
And for the number of passing lanes, you're right, but I think that will come after V1, now save/load and engine replacing are more important.

Thank you all for testing! :D

User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

Re: SimpleAI alpha5 - trying to remake the old AI

Post by 1009 »

Yes, that's the passing lane-type I meant. As for the subsidies: they sometimes cover the whole 256x256 map. I don't know about a maximum, but it's quite long. :P

User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: SimpleAI alpha5 - trying to remake the old AI

Post by Dustin »

Brumi wrote:My problem is that the effect of that new vehicle is seen much later, so I must prevent my AI from building a new vehicle on every loop. How do you do that in your AIs?
Since you asked... :D

Every route has it's own object. That object can be called to examine the route and to add and delete vehicles or even close a bad route. The route stores the last time it had a "checkup" and only performs them once a quarter.

This isn't literal code, since I don't want to dig it up. I call the checkup on each loop and each route controls weather it does one or not.

Code: Select all

function Checkup()
{
    if(Gamedate < lastcheckup + 90)
   {
      AILog.Info("No checkup needed yet.");
      return;
   }

  ...
  //Checkup code.
}

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI alpha5 - trying to remake the old AI

Post by SirkoZ »

Two little additions to v5 would be nice (for consistency with the old AI):
-> Building HQ at AI's first station/service route
-> obeying the signal_side setting - I usually have it set on "false" because I want my trains to drive on left like with TTO/TTD and with that the signals to appear on the right side = outer side of the track - this only applies to two way meeting points on two train railways (my road vehicles drive on the right side though). :-)

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI alpha5 - trying to remake the old AI

Post by petert »

SirkoZ wrote: -> Building HQ at AI's first station/service route
Or a setting saying where you want it.

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI alpha5 - trying to remake the old AI

Post by Brumi »

I've been busy for quite a few weeks, so I didn't have much time and energy to develop my AI.
You're right, if I want to be a bit more consistent with the old AI, I'll have to change the HQ building behaviour. I was thinking of that earlier, but at that stage it was much easier to do it that way. Changing it shouldn't be too hard, as the HQ building procedure is quite independent from the other parts of the code.
The other one - do you mean that I should try to build signals on the outer side of the rails?

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI alpha5 - trying to remake the old AI

Post by SirkoZ »

For my case - in "Options" I always have "drive on right" but under "Advanced Settings" I use "Do not show signals on the drive side" so I see them on the outer side of a two way railway (I use the left side for rail). So yes - it would look nice if all signals would be on the outer side (and also trains traveling on the left side). I hope I'm not complicating too much. :-)

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI beta1 - trying to remake the old AI

Post by Brumi »

I know I'm a bit late for Christmas, but let me place a present under the Christmas tree: SimpleAI beta1. :) It's there in the first post. I regret that I couldn't do this earlier, but I was quite busy... Anyway, I hope that my AI hasn't been totally forgotten.
The first Bananas release is nearing, so it is not alpha anymore, I'm mostly done with the features intended for V1. It just needs some polishing (and of course your bug reports :) ), and V1 will be ready.
The main development was preparing the AI for a long-term game, which means save/load support, and the ability to switch to newer engines. You can see the changelog in the first post. Save/load is not the best yet, it may leave some rubbish on the map (although it shouldn't in most of the cases). It will cause problems if the game is saved while electrifying rail lines, so there is some work to be done until V1.
Merry Christmas! :D (OK I'm late but I have to say this)

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: SimpleAI beta1 - trying to remake the old AI

Post by Zuu »

Don't worry that you didn't make it to Christmas. Fixing all those last things usually takes longer than you think.

I've tried beta1 and found that it decided to remove a livestock line. An inspection shows that the farm only produces 12 livestock units per month so that decision might be valid. It was able to remove everything except for one depot. This depot contains two remaining livestock wagons.

Edit: that was probably not a bug, just that I paused the game at that moment. The depot seams to be gone now after I've unpaused for a while.

Good work with your ai!
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI beta1 - trying to remake the old AI

Post by Brumi »

That's quite an interesting case, even if it was not a bug. The AI is supposed to remove unprofitable vehicles first and then remove the stations if there are no vehicles attending them. And if those trucks had arrived to the depot from another line, then the AI would have failed to remove the depot. So, it's a bit strange... :?
Anyway, thanks for testing! :)

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI beta1 - trying to remake the old AI

Post by SirkoZ »

And now I'm late to thank you for the new beta release, Brumi. :D

Anyhow - thank you - will test the new version soon and Merry Christmas and a Happy New Year!

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI beta1 - trying to remake the old AI

Post by SirkoZ »

I just had to try the new version out real quick so I ran a game from 1950 till 1993 (OpenTTD 0.7.5, only_decrease neutraliser, temperate, mountain, 200k USD) so far and I must say it is great.
Cheers:
-AI replaces exploded road vehicles with new ones, build more than 5 if production allows,
-AI remakes the second train on a two-train track if production picks up,
-though Autoreplaces but still - old engines with faster ones.

Shortcomings:
-When at the start AI doesn't have enough money it only builds one two waggon train on a two-track-5-waggon trail. It should add additional waggons at a later date when it can afford them.
-sometimes it's scared to build a long bridge, e.g. it wanted to connect some oil wells with a refinery and the last stretch of tracks would have to be on the bridge, but didn't build it 'cause it would have been some 20 or more squares long. Without tubular as an option, it would have to have been the good ol' 112-km/h suspension bridge... :-)

I think I've listed all things for now. :mrgreen:

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI beta1 - trying to remake the old AI

Post by Brumi »

Thanks for testing, it's good to see that the AI survives even under those conditions.
I have to add that currently the AI only works under 0.7.5 properly, as there seems to be a bug in 1.0.0-beta1 which has been fixed since then, you will see short trains running around in 1.0.0-beta1. See FS#3442 for details. If there is a SimpleAI user who uses 1.0.0-beta1, I can release my AI with a temporary fix, but later I would like to return to using AIVehicle::MoveWagonChain.

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI beta1 - trying to remake the old AI

Post by SirkoZ »

Yes indeed - I did test in 0.7.5 and I know of the FS#3442 and I thank you for reporting that one.
Even in 0.7.5 there are short trains running around sometimes when the AI doesn't have enough money to complete the whole train according to OldAI spec. (5-wag.). If wagons are added to such train at a later time it'll be nice.

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI beta2 - trying to remake the old AI

Post by Brumi »

Happy New Year! :D
I'm mostly done with the features intended for the first Bananas release, so beta2 is out, downloadable in the first post.
The AI is now able to attach wagons to short trains, and it will build longer bridges. There is an option to make the AI slower as the times progresses, imitating human behaviour.
What I may do before V1 is a general vehicle checkup to avoid some bugs (e. g. vehicles sitting in the depot forever), but mainly this is what I would like to upload to Bananas.
Happy testing!

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI beta2 - trying to remake the old AI

Post by SirkoZ »

Works mighty fine. However for some reason one of them (5 instances started in snowy/hilly/200k map) crashed when trying to replace a loco with a newer one in the depot...
Here's the screen-shot (nightly r18683):
Donningville Transport, 12th Jul 1985.png

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI beta3 - trying to remake the old AI

Post by Brumi »

Thank you for your report, it was a typo in my code. I fixed it in beta3, along with some minor optimizations, it's there in the first post. If there are no problems, this will be the version uploaded to Bananas. 8)

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI beta3 - trying to remake the old AI

Post by petert »

Brumi wrote:Thank you for your report, it was a typo in my code. I fixed it in beta3, along with some minor optimizations, it's there in the first post. If there are no problems, this will be the version uploaded to Bananas. 8)
Thanks for all the great work, Brumi. I have recommended your AI to many people so that they can use the old AI. :-)

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI beta3 - trying to remake the old AI

Post by SirkoZ »

Simply marvelous! :-)

I'll give beta 3 a spin/fast forward.

EDIT: So far - with re-loading the game from yesterday ('1994) - all is functioning properly. Again a little marvel of an AI. :mrgreen:

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: SimpleAI beta3 - trying to remake the old AI

Post by Brumi »

petert wrote:Thanks for all the great work, Brumi. I have recommended your AI to many people so that they can use the old AI.
Thanks for the PR management :)

There haven't been many bug reports recently, so I decided to upload my AI to Bananas (also available in the first post). 8)
Thank you all for testing!

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests