Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Jul 18, 2018 10:36 pm

All times are UTC




Post new topic  Reply to topic  [ 251 posts ]  Go to page Previous 17 8 9 10 1113 Next
Author Message
PostPosted: Sat Sep 18, 2010 8:23 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4535
Location: /home/sweden
I have not used Groups, but for vehicles (and stations) the uniqueness limitation is not for each company, but for all vehicles. So if company A has a vehicle "abc", then company B can't also have an "abc" named vehicle.

I would recommend looking into the OpenTTD source code for this. Running OpenTTD in a debugger with clever placed break points might also be useful.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Mon Sep 20, 2010 6:28 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Well, I didn't think of it being a bug in the OpenTTD code, only my poor knowledge about Squirrel strings or something related. As far as I know other AIs do not have this problem. I'll try to find out what the cause is.


Top
   
PostPosted: Mon Sep 20, 2010 9:50 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4535
Location: /home/sweden
Brumi wrote:
Well, I didn't think of it being a bug in the OpenTTD code, only my poor knowledge about Squirrel strings or something related. As far as I know other AIs do not have this problem. I'll try to find out what the cause is.


I didn't recommend the OpenTTD source code because I though it was a bug, but rather because it will give you the answer of exactly which conditions that a name has to fulfil. I can only extrapolate on the information I know from vehicle names and station names. The source code will give you The answer.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sat Oct 02, 2010 1:11 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Version 5 is available on Bananas! :D
There were no bug reports for the latest beta, so I decided to upload the latest version to Bananas (and the first post as well). I've also fixed the bug concerning the group names. The problem was that the maximum length of group names is 30, but non-English characters count twice, so calling slice(0, 30) is not always enough.
Now that the functionality of the old AI is basically done, I hope SimpleAI will be good enough for players who preferred the old AI :)
Thank you for your feedback! :D


Top
   
PostPosted: Sun Oct 03, 2010 5:59 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4535
Location: /home/sweden
What is the definition of non-english characters?

Everything not in ASCII? (7 bit or the extended 8 bit characterset?)

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sun Oct 03, 2010 6:09 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Most probably it is the right definition :)
In my tests, characters like á, é, ő, all Cyrillic letters, etc. counted as two characters.


Top
   
PostPosted: Mon Oct 04, 2010 2:32 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Mon Jun 14, 2004 11:27 pm
Posts: 579
Location: Berlin, Germany
A character can even be longer, e.g. for Chinese. UTF-8 characters can be up to 6 bytes long. (Code points actually, of which one or more form the actual character. So a character could be even longer, but OpenTTD only really knows about code points IIRC.)

-- Michael Lutz


Top
   
PostPosted: Mon Oct 04, 2010 9:00 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1494
Location: The sunny side of Alps
Thank you Brumi for another installment of your Simple-yet-beautiful-AI. :mrgreen:

_________________
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.

Keep 'em rollin'!


Top
   
PostPosted: Tue Nov 09, 2010 10:22 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Tue Apr 17, 2007 2:28 pm
Posts: 236
SimpleAI goes bankrupt for no reason. This is the last autosave before it happens.


Attachments:
autosave5.sav [155.4 KiB]
Downloaded 83 times
Top
   
PostPosted: Wed Nov 10, 2010 10:08 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Curious... It looks like I don't know something about the bankruptcy process. SimpleAI gets the warning at the start of October 2012, and then goes bankrupt by April 2013. I took a screenshot of its finances on the last day before it went bankrupt:
Attachment:
Unnamed, 31st Mar 2013.png
Unnamed, 31st Mar 2013.png [ 10.36 KiB | Viewed 3229 times ]

The company is doing well, but it seems that the loan payments at the start of the month make it go into negative for a while, just before the bankruptcy check. I should make it a bit tighter with its budget. Where do I find the precise algorithm for bankruptcy?

Thank you Samu for the report, now I'm one step closer to resolving a long-standing problem. :D


Top
   
PostPosted: Thu Nov 11, 2010 12:02 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
I think it's three strikes and you're out: even if you have millions in the bank or in available loans, if you're in the red three times in a row when it checks (first day of each quarter?) you're dead. It also makes you pay maintenance before it checks, so if you're good at spending all your money, it's quite likely to happen. In your case, I think it was negative in October, Januari and then April.

What I've done with ChooChoo is to leave some money unloaned (enough for 3 months of maintenance), do your building/buying/etc., then when you run out of money, max out the loan so you can pay maintenance while keeping a positive bank balance, and wait until you have enough to resume - after stashing some away again by paying back some of your loan first, so you can't accidentally spend it!

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Thu Nov 11, 2010 11:01 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 21, 2005 9:26 am
Posts: 963
Location: Birmingham, England
Brumi,

I'm trying to make a change or two to your scripts...purely for personal use...

I've converted road stations into drive through stations, but sometimes the road building phase misses the station/depot block bu half a tile. This leaves vehicles looping around in their block unable to drive the route. There's also some road and a depot left standing if the AI decides to scrap the station.
I can provide screenshots if required.

At the moment, I can't quite fathom out the roadbuilding part of the script. It seems that it starts and ends at the wrong places, possibly because it thinks the rear of the station is actually the front (or maybe not). Occasionally too it adds a half section of road past the drive through.

Just wondering if you (or anyone) can point me in the right direction?


Actually, just discovered there's a line of code that checks that a road connection exists from the tile infront of each station... and it behaves differently for drive throughs anyway. So, I've modified it to check that a road connection exists from the station tile of source and destination...and it appears to work. The AI can now also buy articulated vehicles...

Maybe this code can be incorporated in a later version...if wanted.

Great little AI that does just what I want.


Top
   
PostPosted: Thu Nov 11, 2010 1:38 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
The problem was this, wasn't it?
Attachment:
Unnamed, 17th Jan 1950.png
Unnamed, 17th Jan 1950.png [ 21.84 KiB | Viewed 3174 times ]

You're right, AIRoad::GetRoadStationFrontTile isn't good here, as it may return the other end of the station as the front tile. So I wrote my own cBuilder::GetRoadStationFrontTile, and it is called by the AI instead of the one in AIRoad. It's not the nicest solution, as it searches for a depot pointing in the right direction next to the station. Also I commented out two lines which excluded the use of articulated vehicles. So here's the modified builder.nut, it should work, but I haven't tested it thoroughly.
Attachment:
builder.nut [35.32 KiB]
Downloaded 94 times


And about the bankruptcy: the monthly loan payment is the amount of the loan times the given percentage in the difficulty settings? It should be quite easy to increase the minimum cash on hand by this value.


Top
   
PostPosted: Thu Nov 11, 2010 2:14 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 21, 2005 9:26 am
Posts: 963
Location: Birmingham, England
Brumi,

Thanks for that. I'll give it a try. I'm able to understand a bit of code but I'm sometimes not sure if a command is a default one or a custom built one.

Thanks.


Top
   
PostPosted: Thu Nov 11, 2010 3:18 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Brumi wrote:
And about the bankruptcy: the monthly loan payment is the amount of the loan times the given percentage in the difficulty settings? It should be quite easy to increase the minimum cash on hand by this value.


I think so, yes.
Keep in mind the station maintenance as well. I don't think you can find the value anywhere in game, but it seems to be hardcoded so I've just declared a constant for it.

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Fri Nov 12, 2010 8:14 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 21, 2005 9:26 am
Posts: 963
Location: Birmingham, England
Brumi,

That amended builder.nut works fine...except for one crash. Line 1009, a problem with DIR_NE not existing. The AI was trying to remove an unwanted station/depot. Unfortunately I don't have any more details but I'll try to get info on it.

Discovered a serious drawback of drive throughs though. Stations built later often stack up, causing a truck driving (say) south into a truck stop having to exit south and getting entangled in another truck stop from another company. This can lead to horrible traffic snarl-ups or vehicles driving miles to find a turn-round point. Nothing that can be done to avoid this but that's a hazard of drive throughs rather than your code.

Thanks for your assistance.


Top
   
PostPosted: Fri Nov 12, 2010 8:43 am 
Offline
Tycoon
Tycoon

Joined: Wed Aug 26, 2009 6:33 am
Posts: 2493
Location: Poland
3iff wrote:
Discovered a serious drawback of drive throughs though. Stations built later often stack up, causing a truck driving (say) south into a truck stop having to exit south and getting entangled in another truck stop from another company. This can lead to horrible traffic snarl-ups or vehicles driving miles to find a turn-round point. Nothing that can be done to avoid this but that's a hazard of drive throughs rather than your code.

It can be avoided by building place to reverse.

_________________
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD


Top
   
PostPosted: Fri Nov 12, 2010 5:30 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
3iff wrote:
That amended builder.nut works fine...except for one crash. Line 1009, a problem with DIR_NE not existing.

DIR_NE not existing? That is a constant defined in the cBuilder class, along with DIR_NW, DIR_SE and DIR_SW. I wonder what was the problem there...
And certainly, to use drive-through stations properly a station pattern like in AIAI would be good. But that would need quite a lot of modification in the existing code (although not impossible), at least you would have to change things at least in BuildRoadStation, CanBuildRoadStation and DeleteRoadStation.


Top
   
PostPosted: Mon Nov 15, 2010 12:54 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 21, 2005 9:26 am
Posts: 963
Location: Birmingham, England
Brumi wrote:
DIR_NE not existing? That is a constant defined in the cBuilder class, along with DIR_NW, DIR_SE and DIR_SW. I wonder what was the problem there...


I thought that odd too. I suspect it was trying to find a station/depot (?) to delete and couldn't find it. Possibly some problem with the drive through being perceived as reversed (I'm guessing here).

As drive throughs are not at all working properly, especially with them chaining when multiple AIs build them, I've abandoned the idea and returned to the normal version of simpleAI.

I have had a couple of instances where a train station 'disappears' after being taken over by me but I have no data. I suddenly find a train has a void order. It may be an error on my part. If I find anything I'll pass on the details.


Top
   
PostPosted: Sat Nov 20, 2010 2:29 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1494
Location: The sunny side of Alps
Brumi - the algorithm for bankrupting a company is in a file named economy.cpp - for version r21266 of trunk - it is line 465:
Code:
/**
 * Check for bankruptcy of a company. Called every three months.
 * @param c Company to check.
 */
static void CompanyCheckBankrupt(Company *c)
.

Plus I've got another idea; if path-signals are selected for railway it would be beneficial for lorry drivers to build one on each end of single-rail station assembly such as this:
Attachment:
File comment: better
Whittown Transport, 10th Feb 1950.png
Whittown Transport, 10th Feb 1950.png [ 33.66 KiB | Viewed 3015 times ]

or going a bit further and placing two two-way path a few squares before and after each road crossing - the ultimate road traveler protection. :-)
Attachment:
File comment: the best
Abercombe Rivers Transport, 29th Jan 1950.png
Abercombe Rivers Transport, 29th Jan 1950.png [ 21.14 KiB | Viewed 3015 times ]

_________________
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.

Keep 'em rollin'!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 251 posts ]  Go to page Previous 17 8 9 10 1113 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.