NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.1.3

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

Post Reply
wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.6

Post by wozzar »

In the debug window It is building connections between towns .but it isn't setting up depots or routes.
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.6

Post by GeekToo »

But when it is setting up connections, according to Morloths previous posting, it should have set the company name. On what hardware are you running this? It does look like you're using a real slow computer, and are just too impatient to wait for the first route to complete.
Because at first you reported a huge slowdown at startup, and now it freezes when pathfinding. The PC that I use to run OTTD on is rather old, but I tried to start NoCab on several occasions, and besides a noticable lag on startup, NoCab did not cause major problems for me. In fact, besides some minor bugs, it is the best allround AI after Admiral.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.6

Post by Rubidium »

Well, loading https://secure.openttd.org/bugs/task/26 ... /crash.sav takes several minutes on my computer due to NoCab initialising. Don't have that problem with the other AIs.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.6

Post by Morloth »

wozzar wrote:In the debug window It is building connections between towns .but it isn't setting up depots or routes.
This is expected behaviour. NoCAB first simulates building several connections and picks the best subset to build after this. It takes over a month before NoCAB will start building a connection.
Rubidium wrote:Well, loading https://secure.openttd.org/bugs/task/26 ... /crash.sav takes several minutes on my computer due to NoCab initialising. Don't have that problem with the other AIs.
Yes, I'm aware of this problem and in the current SVN version the time this takes is reduced but it doesn't scale well (yet) for larger maps. I'm currently working on this and I will post a new version which will solve this issue.
GeekToo wrote:But when it is setting up connections, according to Morloths previous posting, it should have set the company name. On what hardware are you running this? It does look like you're using a real slow computer, and are just too impatient to wait for the first route to complete.
Because at first you reported a huge slowdown at startup, and now it freezes when pathfinding. The PC that I use to run OTTD on is rather old, but I tried to start NoCab on several occasions, and besides a noticable lag on startup, NoCab did not cause major problems for me. In fact, besides some minor bugs, it is the best allround AI after Admiral.
Could you elaborate a little on the minor bugs you noticed ;)? Also I must congratulate you on Convoy, from my point of view it has been improved considerable since the last time I tested it! (about 2 months ago, but still! :) ).

Thanks for your feedback and look forward to the next release which will solve the lag at the beginning of the game!
- Bram
wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.6

Post by wozzar »

It does create a company name nocab.

Here are my specs.

Operating System: Windows XP Home Edition (5.1, Build 2600) Service Pack 3 (2600.xpsp.080413-2111)
Language: English (Regional Setting: English)
System Manufacturer: Gigabyte Technology Co., Ltd.
System Model: P35-DS3
BIOS: Award Modular BIOS v6.00PG
Processor: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz (4 CPUs)
Memory: 3582MB RAM
Page File: 187MB used, 9231MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 9.0c (4.09.0000.0904)
DX Setup Parameters: Not found
DxDiag Version: 5.03.2600.5512 32bit Unicode

Card name: NVIDIA GeForce 8800 GTS 512
Manufacturer: NVIDIA
Chip type: GeForce 8800 GTS 512
DAC type: Integrated RAMDAC
Device Key: Enum\PCI\VEN_10DE&DEV_0600&SUBSYS_82681043&REV_A2
Display Memory: 512.0 MB
wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.6

Post by wozzar »

I ran the game for four years but the AI didn't build anything.
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.6

Post by GeekToo »

Maybe I've got a lead why Wozzar has got problems:

NoCab has problems loading a savegame. When you save a game, and then reload it, an error is reported:
wrong number of parameters (without source, or line number). Then it is declared bankrupt immediately, and thus indeed builds nothing.

Maybe caused by the load function:
function Load(); (nocab)

function Load(version, data); (other AIs)

SO Wozzar, when you start a new game, does NoCab have the same problems, or only after loading a savegame?


@Morloth, I'll try to reproduce the other issues I mentioned, I don't have a savegame for that at the moment.
I believe it had to do something with a crash when removing an industry, I'm not sure though.
Attachments
Unnamed, 6th Mar 1950.png
Unnamed, 6th Mar 1950.png (96.25 KiB) Viewed 5259 times
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.7

Post by Morloth »

Ok, new version is out!

List of changes:
* Optimizations to the road pathfinder. It got bogged down later in a game when there is loads of traffic due to VEHICLE_IN_THE_WAY errors.
* Implemented a replan option if the parlement fails to execute some actions.
* Fixed a bug where the wrong connections were demolished if an industry closed.
* Speedup the initialization phase so it doesn't block the game as long as it used to.
* Altered the load function so it doesn't break NoCAB anymore (not implemented yet!).
* Speedup the advisors so they don't have to rescan the map on every iteration.
wozzar wrote:I ran the game for four years but the AI didn't build anything.
With the current implementation it will take NoCAB about 8 months on a 1024x1024 map to start building anything. The time before that is dedicated to checking all possible connections and selecting the best subset. After this phase NoCAB will build connection on smaller intervals. Also, the startup time of NoCAB is greatly reduced, it now only takes a couple of seconds on a 1024x1024 map.
GeekToo wrote:Maybe I've got a lead why Wozzar has got problems:

NoCab has problems loading a savegame. When you save a game, and then reload it, an error is reported:
wrong number of parameters (without source, or line number). Then it is declared bankrupt immediately, and thus indeed builds nothing.

Maybe caused by the load function:
function Load(); (nocab)

function Load(version, data); (other AIs)
Ah yes, thanks for pointing that out. I noticed the same thing with Rubidium's save game, it's fixed now :).
GeekToo wrote:@Morloth, I'll try to reproduce the other issues I mentioned, I don't have a savegame for that at the moment.
I believe it had to do something with a crash when removing an industry, I'm not sure though.
Yes, there was a issue where NoCAB would demolish the wrong connections after an industry closed down, e.g. if it closed down any power plant all Coal mine -> Power plant connection were demolished! Oeps... :X

Anyway, this version should fix most issues and its performance is better than ever 8). Hope this solves all your problems Wozzar!
- Bram
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.7

Post by GeekToo »

Most issues, but not all, I'm afraid .. :mrgreen:
Attachments
Unnamed, 4th Dec 1958.png
Unnamed, 4th Dec 1958.png (4.05 KiB) Viewed 5170 times
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.7

Post by Morloth »

GeekToo wrote:Most issues, but not all, I'm afraid .. :mrgreen:
Arg! :(

Could you specify what the number is after ConnectionsAdvisor.nut? I think it is the most important information for me.

Thanks! :)

Edit:
Never mind I think I found the problem :). New version is online!
wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.8

Post by wozzar »

Yay i got it to work. How ever i was using the 2048 map. When i used the 1024 size it worked. So why doesn't it work on the larger map.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.8

Post by Zutty »

Ouch! A 2048^2 map is 4x larger than a 1024, so it should take at least 4x longer, but in practice it may be part of NoCab's planning code that runs in exponential time, making it take much longer.

When I first wrote my AI, a 1024 map took about 4 months to pre-process, but a 2048 took well over 10 years! This was because I was looping over every line of tiles from one side of the map to the other n^2 times (IIRC). This meant that a 64x2048 map would run much much faster than a 2048x64 map!
PathZilla - A networking AI - Now with tram support.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.8

Post by Morloth »

wozzar wrote:Yay i got it to work. How ever i was using the 2048 map. When i used the 1024 size it worked. So why doesn't it work on the larger map.
Like Zutty also pointed out, because NoCAB preprocesses the map by evaluating all possible connections (well, there is some limit here based on the distance between industries / towns) it will take a long time. With a 2048 x 2048 map it is reasonable to assume there will be 4 times more industries and towns compared to a 1024 x 1024 map. But because we're interested in all connections between those industries and towns expect the number of connections to grow exponentially, e.g., say we have a map with: a town (T), factory (G), and a farm (F);

With this setup we can construct 3 connections:
F -> G (livestock)
F -> G (grain)
G -> T (goods)

However, if we double these we get 13 connections:
[original]
F1 -> G1 (livestock)
F1 -> G1 (grain)
G1 -> T1 (goods)
[duplicate]
F2 -> G2 (livestock)
F2 -> G2 (grain)
G2 -> T2 (goods)
[extra connections]
F1 -> G2 x2
F2 -> G1 x2
G1 -> T2
G2 -> T1
T1 -> T2

Go to 4 times this setup and the number of connections grows to 54.

Not all setups grow exponential, for example the number of coal mine -> power plant connections c will grow at a rate of c^2. So for connections where the end node doesn't produce anything the function doesn't grow that fast as shown. However if the end node is an open end, problems begin to arise.

For example the Farm(F) -> Factory(G) -> Town(T) example will grow at a rate of:
F -> G : 2*G*F
G -> T: T * G
T -> T: (T - 1)!

2 * G * F + T * G + (T - 1)!

Especially the town <-> town connections are problematic, the rest of the function grows polynomial in the number of industries, but the number of towns makes this function exponential. Note that we only store a connection from T1 <-> T2 in only one way. In this example we only considered 1 cargo type for towns, multiply the function by the number of cargoes to get the real value. But all in all respect a runtime of O(n!), which - in combination with an exponential larger map - will create problems :).

Hope this answers your question.
- Bram

P.S. For those who want to know, the complete function is this, but I prefer O(n!) ;):
C * P + I * S + G(2 * F + S) + O * R + W * SM + (B - 1)! + (T - 1)! + T(R + SM + G)
C = Coal mine
P = Power plant
I = Iron mine
S = Steel factory
F = Farm
O = Oil well
R = Refinery
W = Woods
SM = Saw mill
B = Banks
T = Towns
F = Factory
Coal
Last edited by Morloth on 23 Feb 2009 11:52, edited 1 time in total.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.8

Post by Rubidium »

If this calculating takes so much time, then don't do it in the constructor but do it once started. Or only focus on a randomly chosen relatively small region of the map and start expanding the search later on (outside the constructor).

This makes your AI behave more user friendly and it starts earlier thus having less reports of the AI doing nothing.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.8

Post by Morloth »

Rubidium wrote:If this calculating takes so much time, then don't do it in the constructor but do it once started. Or only focus on a randomly chosen relatively small region of the map and start expanding the search later on (outside the constructor).

This makes your AI behave more user friendly and it starts earlier thus having less reports of the AI doing nothing.
The calculations are done outside the constructor. In the constructor only the data structures are created which now only take a couple of seconds even on a 2048x2048 map. The huge delay is now fixed - or at least much reduced. But I do agree that the process needs to speed up. It now takes about 5 to 6 months for the AI to start building on a 1024x1024 map which I find acceptable. Less acceptable is that it performs this initialization every X years which can be avoided by smarter updating the state of the world. This is not so much a problem on smaller maps (up to 512x512 or even 1024x1024), but when we try to play on 2048x2048 maps this process simply breaks down; It takes about 4 years to complete initialization and after that a number of industries have been opened / closed and after that it finally starts to build something....

But for the moment I will accept that NoCAB is unplayable on maps larger than 1024x1024. I want to focus more on the v2 release and get the upgrade manager going. I'll fix the performance on larger maps in a subsequent v2.1 release.

Thanks for your feedback! :)
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.9

Post by Morloth »

Version 1.9 is out!

This version fixes all delays caused by this AI, many apologies to everyone. I made some changes to the AI which causes it to be competitive on any map size and fixed some small bugs in the process:

Instead of trying to approximate all connections which can be constructed in the world we take a random subset. The reason why I take a random subset, is that connections in an array are stored like:

Town1 -> Town2
Town1 -> Town3
...
Town1 -> Town10423

So if we take the first X elements we get very bad performance. I've tried to work with a scheme which selected X connections for each cargo type, but if the producers of a certain type of cargo is very sparse it might end up searching the whole connection space anyways. So eventually I settled down to select random entries from the array and let the selection algorithms run iterative over the course of the game. Each time the algorithm is called it will run for 1500 ticks and store whatever connections it found and move on.

This scheme is complete for smaller maps (up to 512x512), but due to its randomness it will find good solutions for the larger maps. Occasionally it will add some questionable connections, but you can't always be lucky and these occurrences are very, very rare :).

Hope you enjoy it!
- Bram
elring
Engineer
Engineer
Posts: 4
Joined: 15 Apr 2004 10:17
Location: Czech Republic

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.9

Post by elring »

Hi, I tried new version and found little bug :)
Attachments
Crash
Crash
screenshot_cab.jpg (75.5 KiB) Viewed 4845 times
Aali
Traffic Manager
Traffic Manager
Posts: 144
Joined: 01 Oct 2008 00:04
Location: Sweden

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.9

Post by Aali »

Found a small problem :)

Left this AI running for 100 years and when I checked on it, it had 61 ships going around without orders in the middle of nowhere (no nearby docks, just a bouy)

The debug log didn't have any relevant information, the AI was still running and making a good profit.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.9

Post by Morloth »

elring wrote:Hi, I tried new version and found little bug :)
I don't like bugs :(. But thanks for bringing this to my attention! This is fixed in the new version, the problem occurred when an existing engine was removed from the game and not replaced with anything better. So it would check the game settings for the maximal amount of vehicle of type UNKNOWN could be build...
Aali wrote:Found a small problem :)

Left this AI running for 100 years and when I checked on it, it had 61 ships going around without orders in the middle of nowhere (no nearby docks, just a bouy)

The debug log didn't have any relevant information, the AI was still running and making a good profit.
Thanks for pointing this out. Yes, what I do now when an industry is removed is to destroy the entire connection including all vehicles and depots. But if the depots are removed the vehicles can't be sold. I've fixed this now by not removing the depots, but I need to find for a better solution for this.

Thanks for all your feedback, these bugs are fixed in version 1.10 in addition with:
* Fixed a bug where no vehicles were build if a connection started without any (money problems).
* Industry removal is a little faster.

Hope this solves your problems! :)

- Bram
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: NoCab - Trucks, Busses, Airplanes and Ships! v1.10

Post by Zutty »

Wow Bram you're a bug fixing demon! :D I don't know how you keep up so quickly.
PathZilla - A networking AI - Now with tram support.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests