Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Jul 21, 2018 11:44 am

All times are UTC




Post new topic  Reply to topic  [ 251 posts ]  Go to page Previous 19 10 11 12 13 Next
Author Message
PostPosted: Fri Jan 11, 2013 10:32 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 21, 2005 9:26 am
Posts: 963
Location: Birmingham, England
I have just tried the NUTS trainset and was disappointed (but not surprised) that this AI couldn't handle it. I'll give this a try.

The PASS/MAIL wagons in NUTS are tricky for me to handle as I usually have 1 mail wagon on a passenger train and it's awkward to get one built easily.


Top
   
PostPosted: Sat Jan 12, 2013 5:33 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Fri Jan 19, 2007 7:26 pm
Posts: 326
It also builds the logic train in my game, after which it can't attach wagons. (I guess, first time playing with NUTS).


Top
   
PostPosted: Sun Jan 13, 2013 12:07 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
The logic train should immediately get blacklisted because it's not compatibile with any wagon. The AI usually builds one at the start of the game, but never anymore as it gets blacklisted.

Are you sure that you are using v7-beta4? It's not on Bananas yet, it's only available in the first post. A savegame or simply some instructions to reproduce would be useful.


Top
   
PostPosted: Sun Jan 13, 2013 8:31 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Fri Jan 19, 2007 7:26 pm
Posts: 326
Sorry I wasn't more complete :) It's on Hard Game Pack 0.7 (https://www.tt-forums.net/viewtopic.php?f=33&t=49359) with 'latest' SimpleAI as of Bananas. That seems to be v6.


Attachments:
Nedtown Transport, 28 Aug 1957.sav [112.98 KiB]
Downloaded 106 times
Top
   
PostPosted: Sun Jan 13, 2013 2:28 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
The current Bananas version doesn't support NUTS, which also means that it will try to use the logic train as well. Try the beta version for NUTS compatibility :)


Top
   
PostPosted: Sat Jan 19, 2013 3:05 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
After the longest beta phase of SimpleAI so far, I think version 7 is ready for release. It's available in the first post and on Bananas.

Because Bananas doesn't support having Road Pathfinder v3 as a dependency, the AI now uses Road Pathfinder v4 and AyStar v6.


Top
   
PostPosted: Sun Feb 03, 2013 7:13 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Triple posting to inform you that there is a new version out. It (hopefully) contains a bugfix for the problem described in this thread.


Top
   
PostPosted: Mon Feb 04, 2013 9:11 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 03, 2002 10:36 am
Posts: 13174
Location: The Netherlands
Brumi I'm using v7 of your AI and I noticed a peculiar thing when assessing available vehicles. I made an early start in 1800 and with eGRVTS 2.0 it is possible to buy road vehicles right from that date. Your AI seems to think differently though:
Attachment:
Nederlandsch Vervoersbedrijf, 23 Dec 1837.png [424.87 KiB]
Downloaded 7 times

Also, eGRVTS 2.0 is fully supporting FIRS.

_________________
Image
Dutch Trainset for OpenTTD | Dutch Trainset Topic | Combined Roadset v0.10


Top
   
PostPosted: Mon Feb 04, 2013 10:18 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
That's because all road vehicles are articulated at that date. The AI doesn't use articulated vehicles because it uses terminus style stations (being a remake of the old AI after all :wink: )


Top
   
PostPosted: Wed Jul 17, 2013 4:09 pm 
Offline
Tycoon
Tycoon

Joined: Wed Aug 26, 2009 6:33 am
Posts: 2493
Location: Poland
I know that it is intentional, but it quite sad to see 300+ tonnes of cargo that slowly disappears from station and AI refusing to use more than 5 trucks.

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


Top
   
PostPosted: Thu Jul 18, 2013 7:58 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 21, 2005 9:26 am
Posts: 963
Location: Birmingham, England
You can change a setting to allow the AI to use more trucks. I generally have 25 road vehicles per route.


Top
   
PostPosted: Sat Jul 20, 2013 11:49 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Hi brumi,

i got a div by zero in valuator with v8


Attachments:
sv8.png [26.33 KiB]
Downloaded 4 times
Top
   
PostPosted: Sat Jul 20, 2013 2:33 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Oops...
Thanks for the report, I will look into it.

EDIT:
Okay, this error is weird. The line on which the division by zero happened:
Code:
local runningcost_limit = 6000 / Banker.GetInflationRate() * 100;

So Banker.GetInflationRate must have returned zero.

Banker::GetInflationRate is:
Code:
function Banker::GetInflationRate()
{
   return (100 * AICompany.GetMaxLoanAmount() / AIGameSettings.GetValue("difficulty.max_loan"));
}

I still wonder how this could possibly return zero... Did you change the maximum loan beforehand? Was inflation on in your game? And if yes, what year was it?


Top
   
PostPosted: Sat Jul 20, 2013 5:38 pm 
Offline
Engineer
Engineer

Joined: Tue Feb 23, 2010 3:44 pm
Posts: 103
Hi Brumi,

the numbers in your formula can get very big, maybe they are too high and overflow. Just a guess, but I thought I should write it.

Quote:
return (100 * AICompany.GetMaxLoanAmount() / AIGameSettings.GetValue("difficulty.max_loan"));



Asuming the max. size of a variable in squirrel is not bigger than 2 ³² (2.147.483.648).
Then the first part of your calculation (100 * AICompany.GetMaxLoanAmount()) can get too big, and overflows before doing the divide calculation.
I loaded a game with over 110 years of playtime and the loan amount was 14.000.000 there. It needed ca.21.500.000 to overflow, so you have to play long but maybe it's possible to reach this.

Fix would be easy :-)

Quote:
return (AICompany.GetMaxLoanAmount() / (AIGameSettings.GetValue("difficulty.max_loan")/100));


Last edited by Steffl on Sat Jul 20, 2013 5:53 pm, edited 2 times in total.

Top
   
PostPosted: Sat Jul 20, 2013 5:42 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
I have look at it too, year was like 2080 or so (the game was running alone as a test bed). inflation on, maximum loan wasn't change.

I think it overflow, i will check it later as i'm using this one too ;)


Top
   
PostPosted: Sun Jul 21, 2013 3:50 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Thank you for the ideas, now there is a new version available with the proposed fix by Steffl :)


Top
   
PostPosted: Mon Jan 12, 2015 10:32 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1494
Location: The sunny side of Alps
Brumi - another problem with the version 9 is selection of railway locomotive when inflation is at its highest (4% interest).
In railbuilder.nut lines 1286 and 1287 look like this:
Code:
local runningcost_limit = 6000 / Banker.GetInflationRate() * 100;
   local runningcost = AIEngine.GetRunningCost(engine).tofloat();

But that means that once inflation_rate reaches 6000% (which is quite soon),
the whole runningcost_limit becomes zero. So rather than dividing 6000 by inflation_rate,
let's turn the second line (= runningcost) into its non-inflated state, so it is immune to inflation.
Code:
local runningcost_limit = 6000;
   local runningcost = AIEngine.GetRunningCost(engine).tofloat() / Banker.GetInflationRate() * 100;

This way your complex formulas for choosing the optimal engine work as intended even in most inflated scenarios. :-)

Anyhow - I only got to this now because when version 5 was out I made my slightly modified version of it, named StupidAI
and I was happy with it till now - sometimes there are AI loading issues regarding "null".
So I decided to make "StupidAI-9" and with it also to rectify the engine choice issue.
S/Z :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 Jan 13, 2015 9:52 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
I think the real problem is because of the use of integer.
One way you overflow, the overway, when the value goes below 1, the integer roundup gave you 0 (that of course use in / will cause problem)

To ease calcs and prevent this GetInflationRate should be set as (it will return value of 1.00 for basecost, 1.1 when inflation reach 10%...):
Code:
return (AICompany.GetMaxLoanAmount() / AIGameSettings.GetValue("difficulty.max_loan").tofloat());


This will fix as well:
Code:
local runningcost_limit = 6000 * Banker.GetInflationRate();
   local runningcost = AIEngine.GetRunningCost(engine); // don't think it's even need to typecast it to float now that GetInflationRate return itself a float

or
Code:
local runningcost_limit = 6000;
   local runningcost = AIEngine.GetRunningCost(engine) / Banker.GetInflationRate();

Will gave equal result.

It mean a lot of code review to handle the change, and some tointeger() typecast might be need.


Top
   
PostPosted: Tue Jan 13, 2015 11:46 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 881
Yes, using integers is definitely the problem here. Surely I didn't know how Squirrel handled integers and floats when this piece of code was written :)
The most simple solution is to make GetInflationRate() return a float, like krinn advised.


Top
   
PostPosted: Fri Jan 16, 2015 9:49 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1494
Location: The sunny side of Alps
Well I don't care. I got it fixed. :]

_________________
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 19 10 11 12 13 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


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.