SuperSimpleAI v25 (Old Stable), v41 (Stable) and v47 (Testing)

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

Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v23 (stable) and v25 (testing)

Post by Jaume »

3iff wrote: 28 Sep 2021 09:33 I notice that routes sometimes run at a terrible loss (I'm playing with very low cash payments at the moment) but many road mail/passenger routes are running at a heavy loss with no attempt to close these routes. The same applies to trains.
Yes, this it's at my TODO list. In SimpleAI, all vehicles are sold if they LastYearProfit is less than 0. But this doesn't work with very large routes, since some trains spend more than one year to go from source station to destination station, and then back to source station.

Regards!
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SuperSimpleAI v23 (stable) and v25 (testing)

Post by 3iff »

That's fine. I was going to try and 'fix' it but couldn't work out where to start...

Even with my changes to SimpleAI, it's hard to get something that works for most situations.

Good Luck.
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (stable) and v26 (testing)

Post by Jaume »

Hi all!

New release, with two important features!

* Large passenger trains now can transport more mail: more than one mail car per train is possible.
* Double cargo trans (grain and livestock) and routes with double destination stations (one passing station and one end station).

Enjoy it!
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (stable) and v28 (testing)

Post by Jaume »

Hi all! Time for new release!

This release has basically bugfixes and better (more clear) code, but have a new passing-lanes code, with more flexible passinglanes. Another feature are more station allocation, now this AI build perpendicular (from rail line direction) stations. Also, pathfinder is more acurate, penalizes "mountain climbing" routes.

v28:
Fixed crash with double cargo, when destination is a town.
Fixed crash when terraforming at same place that this AI try to build a passinglane with tunnels or bridges.
Better station allocation.
More passing lane options.
Better economics at start of the game.
Better rail tunnel cost estimation.
Better pathfinder: Penalty for tile heights over max height or under min height (some functions come from SuperLib, write by Leif Linse).

Enjoy it!
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (stable) and v29 (testing)

Post by Jaume »

Hi!

Antother release, with some bugfixes and little features:

Fixed bottom to bottom stations bug.
More pathfinder: try to build cheaper at begining of the game, more direct routes if we have more income.
Replaced SimpleAI readme.txt by newer one about SuperSimpleAI (ufff).
Better passing lanes location.
Faster passing lane building.
Faster track building where building rail between stations and passing lanes.
Add more engines when freight_trains from Game Settings is greater than 1.

Pathfinder code is more clear and can be used by others SimpleAI based AIs.Another functions that can be used by other AIs are all myai*.nut classes, which extends some ai classes to add more functions to standard functions.

You can configure more than standard setting parameters by changing SELF_INFO_VERSION in version.nut file.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SuperSimpleAI v25 (stable) and v30 (testing)

Post by 3iff »

V28 and V30.

I'm getting a crash when reloading a game where the AI has partially built a rail track and wants/needs to remove it.

Wrong number of parameters
Main.nut Line 645 remove track (V30)
Main.nut Line 128 remove track

I've double checked all required library programs and I seem to have everything I should have...but I suspect that is where the problem lies anyway.

I've reverted to V26 and have no problems.
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (stable) and v31 (testing)

Post by Jaume »

Yes, it's a big bug.

Try v31, this bug is fixed:

v31:
Fixed crash when loading game and rail building was interrumped.
Fixed removing route after load game, if a vehicle was blacklisted or WaitForMoney timed out.
Max number of engines are increased to 5, and better power estimation.

Thank you.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SuperSimpleAI v25 (stable) and v31 (testing)

Post by 3iff »

Wow, I was sure it wasn't a bug but a file missing at my end! Glad I found it. My pleasure...I find lots of bugs.

I'll try v31 later today.
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (OldStable) and v32 (Stable)

Post by Jaume »

Hi all!

This new release is mostly a bugfix, and with some code rewrited: you can found some clases that extends AI classes (AIAirport, AIbridge, AICargo, AICompany, AIEngine, AIGameSettings, AIIndustry, AIList, AIRail, AIRoad, AITile, AITunnel), these classes doesn't depends of any other classes that themselves and AI* classes. These classes are defined into myailib folder, so you can use it for your AI. Maybe, in the future, these lib will be out of this AI tarball.

If you want to configure some undocumented parameters of this AI, you can edit version.nut file and change SELF_INFO_VERSION to 2 (or 3).

This release was tested with 4096x4096 map of Taiwan island with hard settings of construction, 1x and 5x of "freight_trains" game setting, with 2cc Tains in NML 3.0-alpha3, FIRS Industry Replacement Set 2.1.5, Industrial Station Renewal 1.0.2

Enjoy it!
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (OldStable) and v33 (Stable)

Post by Jaume »

Hi everybody!

This new release have two important bugfixes, and two minor changes:

Fixed failing search of passengers engines in cBuilder.ChooseTrainEngine() function with some sets.
Fixed malfunction in cBuilder.UpgradeRailBridges() and cBuilder.UpgradeRoadBridges() when other players creates their own groups.
Better engine blacklist management when loaded game has unfinished rail route.
More mail wagons in large passenger trains.

Enjoy it!
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (OldStable) and v35 (Stable)

Post by Jaume »

Time to new release!

There are the last changes in this new version. These changes are mostly bugfixes, but v35 builds new routes a bit faster than v34, and allows larger trains.

v35:
More options when building passinglanes under bridges.
Adjust the number of wagons in dual cargo routes, when cargo production are not equal.
Permit up to 24 tiles long freight trains.
Better power estimation of train engines and up to 8 engines per train.
Allow double platform stations at large passenger routes (experimental, disabled).
Increased pathfinder itinerations to 300.
Slowdown effect doesn't stop building when date is changed to the past.
Manager.CheckRoutes don't use more than 20% of time. So not slowdown effect because checking routes too often.
More tests before build road or rail stations.
xarick
Transport Coordinator
Transport Coordinator
Posts: 335
Joined: 26 Feb 2015 00:52

Re: SuperSimpleAI v25 (OldStable) and v35 (Stable)

Post by xarick »

GetAgressiveStyleAirports doesn't exist
Attachments
Unnamed, 1935-10-15.png
Unnamed, 1935-10-15.png (107.42 KiB) Viewed 7797 times
Unnamed, 1935-11-26.sav
(2.84 MiB) Downloaded 42 times
Formerly known as Samu
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (OldStable) and v36 (Stable)

Post by Jaume »

Wow... Something was not well tested... I'm sorry!

Fixed!

Thank you for your report!
xarick
Transport Coordinator
Transport Coordinator
Posts: 335
Joined: 26 Feb 2015 00:52

Re: SuperSimpleAI v25 (OldStable) and v36 (Stable)

Post by xarick »

another crash, on v36
Attachments
Unnamed, 1938-11-03.png
(386.47 KiB) Not downloaded yet
Formerly known as Samu
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v34 (Stable) and v37 (Stable Candidate)

Post by Jaume »

Thank you, fixed in v37.

Sorry!

Testing changes are difficult because I need too much time of dedicated computers playing games. I have 2 24x7 computers playing games with and without "NewGRF". Some tests are done in 256x256 maps, so they are fast. But most of tests are done in 4096x4096 maps (I love my big maps), and, of course, I play with this tests. Usually, I play only with trains and trucks, but without planes and buses (planes are a big CPU eaters).

Thank you for your help!
User avatar
piratescooby
Route Supervisor
Route Supervisor
Posts: 449
Joined: 21 Nov 2014 12:39
Location: The Granite City.

Re: SuperSimpleAI v25 (Old Stable), v34 (Stable) and v37 (Stable Candidate)

Post by piratescooby »

Unnamed, 2020-03-08.png
(794.14 KiB) Not downloaded yet
Crashed out again .
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v34 (Stable) and v37 (Stable Candidate)

Post by Jaume »

Wow!

What version of TTD are you using?

I think this function was changed, now requires two parameters:

Code: Select all

CreateGroup()
static GroupID AIGroup::CreateGroup 	( 	AIVehicle::VehicleType  	vehicle_type,
		GroupID  	parent_group_id 
	) 		
	static

Create a new group.

Parameters
    vehicle_type	The type of vehicle to create a group for.
    parent_group_id	The parent group id to create this group under, INVALID_GROUP for top-level.

Returns
    The GroupID of the new group, or an invalid GroupID when it failed. Check the return value using IsValidGroup(). In test-mode 0 is returned if it was successful; any other value indicates failure. 
In all versions of SuperSimpleAI they are called with only one parameter, like:

Code: Select all

jaume@shuttle-01:~/.openttd/content_download/ai/SuperSimpleAI-21$ grep CreateGroup *.nut 
aircraft.nut:                   group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
main.nut:               builder.group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);

Code: Select all

jaume@shuttle-01:~/.openttd/content_download/ai/SuperSimpleAI-38$ grep CreateGroup *.nut mylib/*.nut
airbuilder.nut:                 group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
main.nut:               builder.group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
I don't know when changed. I think this change may crash other AIs like SimpleAI?

Code: Select all

jaume@shuttle-01:~/.openttd/content_download/ai/SimpleAI-12$ grep CreateGroup *.nut 
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut:                    group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
This is now fixed in version 38.

And for AI Developers, you can create a class like this:

Code: Select all

/**
 * This file is part of SuperSimpleAI: An OpenTTD AI.
 *
 * Author: Jaume Sabater
 *
 * It's free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * any later version.
 *
 * You should have received a copy of the GNU General Public License
 * with it.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Define the MyAIGroup class which extends the AIGroup functions.
 */
class MyAIGroup /* extends AIGroup */
{
        /**
         * Create a new group.
         * @param vehicle_type The type of vehicle to create a group for.
         * @param parent_group_id The parent group id to create this group under,
         *         GROUP_INVALID for top-level (default).
         * @return The GroupID of the new greup, or an invalid GroupID when it failed.
         *         Check the return value using AIGroup.IsValidGroup(). In test-mode 0
         *         is returned if it was successful; any other value indicates failure.
         */
        static function CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID);
}

if ("GetParent" in AIGroup) {
        function MyAIGroup::CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID)
        {
                return AIGroup.CreateGroup(vehicle_type, parent_group_id);
        }
} else {
        function MyAIGroup::CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID)
        {
                return AIGroup.CreateGroup(vehicle_type);
        }
}
And then, use it in your code:

Code: Select all

jaume@shuttle-01:~/.openttd/content_download/ai/SuperSimpleAI-38$ grep CreateGroup *.nut 
airbuilder.nut:                 group = MyAIGroup.CreateGroup(AIVehicle.VT_AIR);
builder.nut:                    group = MyAIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut:                    group = MyAIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut:                    group = MyAIGroup.CreateGroup(AIVehicle.VT_AIR);
main.nut:               builder.group = MyAIGroup.CreateGroup(AIVehicle.VT_RAIL);
Thank you!
Last edited by Jaume on 18 Feb 2023 17:37, edited 1 time in total.
User avatar
piratescooby
Route Supervisor
Route Supervisor
Posts: 449
Joined: 21 Nov 2014 12:39
Location: The Granite City.

Re: SuperSimpleAI v25 (Old Stable), v34 (Stable) and v37 (Stable Candidate)

Post by piratescooby »

I'm running a game with version 13.0 quite a few newgrfs , just tried with no newgrfs still crashed
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v34 (Stable) and v38 (Stable Candidate)

Post by Jaume »

Try with v38 :-)
User avatar
piratescooby
Route Supervisor
Route Supervisor
Posts: 449
Joined: 21 Nov 2014 12:39
Location: The Granite City.

Re: SuperSimpleAI v25 (Old Stable), v34 (Stable) and v38 (Stable Candidate)

Post by piratescooby »

Thanks for the quick fix , running no problems so far .
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 4 guests