Page 3 of 4

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

Posted: 18 Feb 2023 20:33
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);
        }
}

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

Posted: 20 Feb 2023 09:33
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!

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

Posted: 10 Mar 2023 13:20
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!

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

Posted: 10 Mar 2023 20:24
by xarick
I notice that you're building wood bridges for maglev trains. Is that how you intend it to be?

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

Posted: 11 Mar 2023 09:29
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.

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

Posted: 18 Mar 2023 10:11
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.

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

Posted: 18 Mar 2023 12:59
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!

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

Posted: 24 Mar 2023 08:37
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!

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

Posted: 25 Mar 2023 13:10
by xarick
Is it limited to 1000 routes? I kinda wish to know what it would be able to do without the limit.

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

Posted: 25 Mar 2023 14:03
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; }

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

Posted: 25 Mar 2023 19:50
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.

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

Posted: 26 Mar 2023 20:34
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 6486 times

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

Posted: 26 Mar 2023 20:58
by Jaume
Thank you so much!

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

Posted: 04 Apr 2023 16:10
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.

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

Posted: 05 Apr 2023 15:02
by xarick
Hello. Bad news: Too long to save after route 881 :(

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

Posted: 06 Apr 2023 15:54
by xarick
Another crash report. SetAirportThisName does not exist.

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

Posted: 06 Apr 2023 16:42
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.

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

Posted: 16 May 2023 13:19
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).

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

Posted: 23 May 2023 13:35
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..

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

Posted: 24 May 2023 13:46
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.