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 v25 (Old Stable), v34 (Stable) and v39 (Stable Candidate)

Post by Jaume »

Last version v39 is because in some versions of OpenTTD last fix doesn't works.

This is my solution (for now) to the problem of one or two parameters in AIGroup.CreateGroup():

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 and optional).
         * @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);
}

local ottd_v = AIController.GetVersion();
local ottd_major = (ottd_v & 0xF0000000) >> 28;
local ottd_minor = (ottd_v & 0x0F000000) >> 24;

if (ottd_major > 0 && ottd_minor > 12) {
        // Since OpenTTD 1.13 AIGroup.CreateGroup requires two parameters.
        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);
        }
}
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v34 (Stable) and v40 (Testing)

Post by Jaume »

This new version removes the MyAIGroup.CreateGroup() function added in v38, fix some bugs and add code for close unprofitable routes (experimental).

v40:
Removed MyAIGroup.CreateGroup() function because crashes were produced (in my case) because my libraries were broken.
Adding closeing unprofitable road and rail routes (experimental, disabled by default).
Fixed using trains when local buses are allowed but no vehicles are available.
Setting the group name with the new name of the station, if they were renamed.

Sorry for last broken versions!
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v40 (Stable) and v41 (Testing)

Post by Jaume »

Hi all! New release launched!

Basically, now road routes can has more vehicles, because road stations are bigger (two road stations in every head),

v41:
Bigger road stations.
Safer removing road depot when removing a road station, if the depot is not at same direction than station has then they don't be removed.

Enjoy it!
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: SuperSimpleAI v25 (Old Stable), v40 (Stable) and v41 (Testing)

Post by xarick »

I notice that you're building wood bridges for maglev trains. Is that how you intend it to be?
Formerly known as Samu
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v40 (Stable) and v41 (Testing)

Post by Jaume »

This is because your AI has not much money. But don't worry, when your AI have more money then the bridge will be replaced by other one with more maximum speed.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SuperSimpleAI v25 (Old Stable), v40 (Stable) and v41 (Testing)

Post by SirkoZ »

I have finally tested your AI and I have to say it's quite impressive, while also being simple. It adapts well to situations in game.
User avatar
uzurpator
Transport Empire Moderator
Transport Empire Moderator
Posts: 2178
Joined: 10 Jan 2003 12:21
Location: Katowice, Poland

Re: SuperSimpleAI v25 (Old Stable), v40 (Stable) and v41 (Testing)

Post by uzurpator »

I've grown to like to throw AIs at each other. I find myself in a corner of the map, get some income going and then fast forward and see how our silicon friends are doing.

I think that SSAI is the most pleasant to play with. It is quite efficient and does not litter the map too much with random assortment of track. Great job!
All art and vehicle stats I authored for TT and derivatives are as of now PUBLIC DOMAIN! Use as you see fit
Just say NO to the TT fan-art sprite licensing madness. Public domain your art as well.
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v42 (Testing)

Post by Jaume »

Hi all!

Another version released, with some bugfixes (included the oldest documented bug).

v42:
Fixed error building passinglanes over my tracks.
Don't build airports if no suitable planes are available.
Fixed changing the name of stations and airports when company's name is too long.
Fixed building passenger rail routes when they are disallowed by AI settings.
Prevent to use cars with non-zero cost and less than 5 passenger of capacity.
Fixed (un)recovery rail route after load game, because the engine was blacklisted or was waiting for money for long time.
Don't use elictrified rails at starting stages (it's too expensive!).
Wait for money before demolish a tunnel, bridge, station or depot, with this less rail/road trash are produced in negative bank balance situations.

Enjoy it!
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v42 (Testing)

Post by xarick »

Is it limited to 1000 routes? I kinda wish to know what it would be able to do without the limit.
Attachments
Unnamed, 1984-12-29.png
(458.23 KiB) Not downloaded yet
Formerly known as Samu
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v42 (Testing)

Post by Jaume »

Yes, it's limited to 1000 routes since... it was SimpleAI.

Try to use this unlimited version... I never goes to 1000 routes, I don't usually use airplanes.

Try to load and save game, this limit was introduced because too much time to load/save games...

EDIT: This is the piece of code that limits the number of routes. It's from SimpleAI:

Code: Select all

if (routes.len() < 1000 && this.HasWaitingTimePassed()) { // Do not build more than 1000 routes, it may crash on loading.
EDIT2: Please, tell me how many routes do you have when crashes at load game... It's a good information that I don't have... :-)

EDIT3: With version 43 you can modify this limit. Untar your SuperSimpleAI and edit settings.nut file. Then, you can change this value for one greater:

Code: Select all

static function MaxRoutes()             { return 1000; }
Attachments
SuperSimpleAI_unlimited-42-.tar
Unlimited version of SuperSimpleAI-v42
(540 KiB) Downloaded 49 times
Last edited by Jaume on 25 Mar 2023 19:54, edited 1 time in total.
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v43 (Testing)

Post by Jaume »

New version 43!

Because I found two critical bugs that can cause crashes when loading game.

v43:
Fixed crash loading game, if engine was blacklisted.
Fixed crash if try to replace after loading game.
Cache for compatibility between engines and wagons.
Faster and cheaper road building.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v43 (Testing)

Post by xarick »

Here's the result. I only tested once though. 2624 routes.

EDIT: By the way, when I tried to load the savegame, it failed to load the other instance of SuperSimpleAI which was based on v42, limited to 1000 routes. But not the one with 2600 routes. Very strange.
Unnamed, 1989-12-01.png
Unnamed, 1989-12-01.png (21.18 KiB) Viewed 5437 times
Attachments
Unnamed, 1990-04-22.png
(233.65 KiB) Not downloaded yet
autosave14.sav
(16.12 MiB) Downloaded 52 times
Last edited by xarick on 26 Mar 2023 21:00, edited 1 time in total.
Formerly known as Samu
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v43 (Testing)

Post by Jaume »

Thank you so much!
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v44 (Testing)

Post by Jaume »

An important bug was introduced in v43. This causes data corruption in the table of routes, when saving games. This new version fixes it, and set the limits of routes to 2400. Manager.CheckRoutes() is a bit faster.

v44:
Fixed corruption of saved data. This bug was introduced in v43.
Changed the limit of maximum routes to 2400.
Added some cache to manager.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v44 (Testing)

Post by xarick »

Hello. Bad news: Too long to save after route 881 :(
Attachments
Unnamed, 1981-10-22.png
(278.61 KiB) Not downloaded yet
autosave7.sav
(10.15 MiB) Downloaded 53 times
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v44 (Testing)

Post by xarick »

Another crash report. SetAirportThisName does not exist.
Attachments
Unnamed, 2000-08-14.png
(430.33 KiB) Not downloaded yet
Unnamed, 2000-08-14.sav
(12.46 MiB) Downloaded 51 times
Formerly known as Samu
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v45 (Testing)

Post by Jaume »

Thank you xarick for your tests. And sorry for my errors...

This new version fixes the crash reported, and I think the "Too long to save" error too.

v45:
Fixed error with replacing trains, introduced in v44.
Fixed railtype error when restarting unfinished rail route.
Fixed crash with missing SetAirportThisName function, lost in v42.
Some changes in Load and Save functions.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v45 (Testing)

Post by 3iff »

V45. Just an observation. If this is intended behaviour then that's fine.

AI building a rail service, every 6-7 days it buys/sells an engine (maybe checking it can do so).
However, I disabled AI from building trains during this process (while it was pathfinding). The script complained that it couldn't build the engine and then seemed to stop doing anything.
I alternatively set train limits to 0. Again it complained (with a line about too many engines - or something similar).

Anyway, the problem is whether the AI should be checking engine availability every few days. If that is how it's supposed to go then fine.

There is also the issue with making a vehicle class (trains or RVs) unavailable during the AI process of trying to build that type of service. (Does that make sense??)
Currently it seems to just stop (perhaps waiting for that vehicle class to become available).
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v45 (Testing)

Post by 3iff »

Another issue (sorry).

The AI was building an air service, dropped the first airport but then couldn't build the second one, so ripped out the first (at a high cost).
A few days later it tried again and failed. In a year, one AI burned through £1m with nothing to show for it.

I had to disable building aircraft before that company went broke...thought you should know..
Jaume
Engineer
Engineer
Posts: 54
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI v25 (Old Stable), v41 (Stable) and v45 (Testing)

Post by Jaume »

Thank you for your reports 3iff! This information is very valuable, I try to fix these issues in future versions. Thank you so much! :bow:

And, of course, thank you for your SimpleAI mod! SSAI also have this mod.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests