Page 1 of 2

RoadAI

Posted: 01 Sep 2011 19:52
by 11Runner
I would like to present my first AI, RoadAI.

This AI will build a rapidly expanding road network. It is currently in
early development so please tell me if you find any bugs so that I can
improve it. The AI works best in the temperate or subarctic regions.

This AI uses Superlib v13. Save and Load is currently unsupported.

You may need to extend your vehicle limit from 500 since the AI builds vehicles
very quickly!

Re: RoadAI

Posted: 01 Sep 2011 21:24
by Zuu
Nice to see someone doing something different than the typical point to point connection concept.

I'm also happy to see that you've built ontop of the SuperLib library and thus has been able to do this much on just 696 lines of code. I do have to say however, that the code is a bit more compact than my taste of writing code. But it is your AI and your decision how you like to write your code. :-)

Re: RoadAI

Posted: 01 Sep 2011 22:10
by Zuu
Hello again,

Your AI can sometimes build a huge amount of stations.
Unnamed, 11th Jul 1981.png
(190.07 KiB) Downloaded 2 times
RoadAI_test.sav
Used "Last nightly" => trunk version r22864
(213.81 KiB) Downloaded 516 times
(Edit: this game started in 1950, so some overcrowdyness is to be expected after 30 years of gameplay, but not to this extent)

Re: RoadAI

Posted: 02 Sep 2011 00:24
by Level Crossing
Zuu wrote:Hello again,

Your AI can sometimes build a huge amount of stations.
Unnamed, 11th Jul 1981.png
RoadAI_test.sav
(Edit: this game started in 1950, so some overcrowdyness is to be expected after 30 years of gameplay, but not to this extent)
Didn't Paxlink have the same issue? I remember having a game with an old version of Paxlink where the entire city was plastered with bus stations.

How did you solve that?

Re: RoadAI

Posted: 02 Sep 2011 04:34
by 11Runner
Here is the next release for RoadAI. I only made a couple of fixes
Zuu wrote:Hello again,

Your AI can sometimes build a huge amount of stations.

(Edit: this game started in 1950, so some overcrowdyness is to be expected after 30 years of gameplay, but not to this extent)
I tried to address this issue by preventing the RoadAI from adding more than one network per town.

I also added another AI Setting which controls the maximum number of road networks the AI may make.

Thank you for all of your suggestions!

Re: RoadAI

Posted: 04 Sep 2011 13:13
by Brumi
I gave your AI a try, here are my remarks:

I think the AI could have placed the bus station better here:
screenshot1.png
screenshot1.png (298.03 KiB) Viewed 2015 times
Road construction often fails for some reason, maybe the AI ran out of money while building the road and didn't increase its loan?
screenshot2.png
(150.3 KiB) Downloaded 2 times
In my test, the AI has only settled in three towns by the year 1964. I have town density set to low, and every seventh town is a city.

Re: RoadAI

Posted: 04 Sep 2011 14:45
by Zuu
Brumi: Do you happen to have the save game with the town in screenshot 1?

Re: RoadAI

Posted: 04 Sep 2011 17:24
by Brumi
Sorry, I don't have it. SuperLib related issue?

Re: RoadAI

Posted: 04 Sep 2011 21:12
by Zuu
I would recommend using SuperLib.Road.BuildStopInTown(town, road_veh_type, accept_cargo = -1, produce_cargo = -1) over using Road.BuildBusStopNextToRoad as the later does not allow specifying cargo that the bus stop should accept. I think however, that future versions of the library should probably allow passing the accept_cargo and produce_cargo params to Build*NextToRoad as well as the higher-level functions that takes a town or industry rather than a tile as argument for where the road station should be placed.

I'm not sure exactly what the choose rule is if you have both accept_cargo == -1 and produce_cargo == -1 which is the case when you use Build*InTown. IIRC it is distance from center, but I dont exactly remember. (it could actually be preferring as far as way from center as possible as that is the behaviour for airports without cargo requirement specified)

It is also worth to mention that RoadAI use min_loops == 25, while CluelessPlus (Road.BuildStopInTown) have it at 50. This setting decide how many steps the algorithm will walk around in the town before settling with the best solution so far.

Re: RoadAI

Posted: 13 Oct 2011 23:22
by 11Runner
Here is the next (and possibly final) release of RoadAI.
This is a picture of the improvement:
Capture.PNG
Breakdown of AI Improvement
Green is RoadAI v3
Yellow is RoadAI v2
(72.66 KiB) Downloaded 2 times
This is a very rough list of the new features:

1. Greatly improved speed (which actually changes much of the behavior of the AI in many areas :D )

2. Now can mass upgrade vehicles

3. More dynamic vehicle orders (as in vehicles may go to a larger variety of towns in the network)

3. Other various fixes (including a some recommended on this thread)

I am planning on creating a new AI with the majority of this AI's code simply because I feel limited by the name of the AI and I would like to add air, and possibly train support :wink: .

Re: RoadAI

Posted: 14 Oct 2011 11:11
by Lord Aro
there's no problem with changing the name of the AI... i think... as long as you keep the shortname the same (?) (you might want someone to check that)

Re: RoadAI

Posted: 14 Oct 2011 11:42
by FooBar
Though you cannot change the name of a BaNaNaS entry.

If you consider this AI "done", I'd keep it as it is. Just get a new (short)name for your new AI. It's not that we're particularly short on shortnames.

Re: RoadAI

Posted: 14 Oct 2011 17:57
by 11Runner
OK I see what you mean. If it becomes and issue I hope there is an admin that I can talk to to help me change it. Keep in mind that this AI will still accept bug fixes if you find any bugs that may go into my new AI!

Re: RoadAI

Posted: 15 Oct 2011 12:54
by Brumi
I've tried the new version, a problem which I reported earlier still exists, the AI sometimes cannot finish road construction for some reason, probably it is out of money. It would be good if the AI took some loan in this case, or the AI could simply take the maximum loan while constructing a road, then pay it back after construction.

Re: RoadAI

Posted: 15 Oct 2011 17:16
by Hephi
You could try putting something like this?

Code: Select all

if(!buildRoadCommand())
{ 
if(AIError.GetLastErrorString()=="ERR_NOT_ENOUGH_CASH")
{ 
AICompany.SetLoanAmount(AICompany.GetLoanAmount() + AICompany.GetLoanInterval());
buildRoadCommand()
}
}

Re: RoadAI

Posted: 20 Sep 2016 08:02
by Kogut
crash

Re: RoadAI

Posted: 08 Oct 2016 03:06
by 11Runner
RoadAI-4
Kogut wrote:crash
* Should be resolved
* Updated to SuperLib v39
* Updated to GPL v3

Re: RoadAI

Posted: 17 Aug 2018 15:47
by xarick
crash with wrong number of parameters

Re: RoadAI

Posted: 30 Sep 2018 12:16
by xarick
Crash after loading savegame.

Re: RoadAI

Posted: 03 Oct 2018 04:18
by 11Runner
xarick wrote:crash with wrong number of parameters
yea that crash was pretty stupid, and old!

Here is the fixed version, for both of the issues you sent, xarick