Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Nov 19, 2018 12:35 pm

All times are UTC




Post new topic  Reply to topic  [ 256 posts ]  Go to page Previous 18 9 10 11 12 13 Next
Author Message
PostPosted: Sun Nov 21, 2010 12:05 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 887
SirkoZ wrote:
Brumi - the algorithm for bankrupting a company is in a file named economy.cpp - for version r21266 of trunk - it is line 465:

Thanks for that, I'll have a look when I have more time.

SirkoZ wrote:
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:

That's a good idea, I'm also annoyed by the fact that SimpleAI often tends to crush road vehicles, despite that there is quite a high penalty for level crossings in the pathfinder.
Placing signals in front of the stations is very easy, it can be done by adding this after line 51 in railbuilder.nut into cBuilder::BuildSingleRailStation:
Code:
if (AIController.GetSetting("signaltype") == 2) {
   success = success && AIRail.BuildSignal(stafront, depfront, AIRail.SIGNALTYPE_PBS);
}

The problem here is that level crossings on the line will be red in roughly 50% of the time, which may cause huge jams. Anyway, here is a modified version of railbuilder.nut, see whether it causes problems or not.
Attachment:
railbuilder.nut [32.26 KiB]
Downloaded 137 times

The second version is not so easy, most likely I would have to modify something in cBuilder::BuildRail. But then I would have to keep sure that those extra signals are only built on single railway lines.
This feature will most likely be there in the next version, maybe as a fourth option to the signal types if this causes jams.


Top
   
PostPosted: Tue Jun 14, 2011 11:14 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 887
Huge bump! :D
Just to inform you that I'm still working on SimpleAI, there is a release candidate available exclusively here on the forums for version 6. It's in the first post.

There are no big features introduced, the most important piece of work was that I commented the code properly. I hope it will be better for me and others who read the code :)
I did my comments in Doxygen style, but I cannot make Doxygen generate documentation for Squirrel. Is that possible?
There is also a new readme available :)

And from the players' point of view, SimpleAI is now able to refit train wagons (I don't know why I hadn't implemented this before). There is a new setting to use path signals at single rail stations as well (SirkoZ's idea). I also fixed the problem that Samu reported, now the AI takes station maintenance costs into consideration as well, it will survive in the savegame in this post. I also fixed a bug I found recently in my tests, some old vehicles didn't get replaced at all.
I also added a setting to use NewGRF rail stations, and it is configurable with a setting. It is currently off by default (old AI behaviour), and the setting may be a little bit hard to find, do you think it should be on instead by default?

After adding refitting support for train wagons, I was surprised to see that SimpleAI could do fairly well with the ECS vectors and FIRS, using the ECS & FIRS original vehicle set NewGRF 8) The UK trainset is still too hard...


Top
   
PostPosted: Tue Jun 14, 2011 11:27 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 25, 2009 4:42 pm
Posts: 2364
Location: Location, Location
With regards to the Newgrf stations parameter:
I would say you should look at the AI by saying, 'if the original ai was included now, would this be implemented?'
i would say yes :)

_________________
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra


Top
   
PostPosted: Wed Jun 15, 2011 8:40 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 your effort. Nice to see also that all needed for it to cope with all kinds of additional cargoes is just to give it the ability to refit the wagons. Sweet. 8)

_________________
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: Thu Jun 23, 2011 12:11 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 887
I've just uploaded version 6 to Bananas and the first post. The only change is that now building NewGRF rail stations is enabled by default.

I'm still unable to generate Doxygen documentation for SimpleAI, is that possible for Squirrel?


Top
   
PostPosted: Thu Jun 23, 2011 12:14 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Doxygen doesn't support the squirrel syntax, but with some hacks you can work around that a bit. I had a doxygen file + sed script that could create usable (although far from perfect) documentation, but I've lost those :(.


Top
   
PostPosted: Fri Jul 29, 2011 8:13 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
I'm a big fan of SimpleAI and I always enable it when playing myself and when playtesting my own AI.
With the UKRS train set I found Simple AI having problems attaching passenger carts to the HST engine,
it did not detect the failure when attaching and kept buying new passenger carts spending all it's money
on them and only deleting them after several years of negative profit.

I've had similar problems with engines that need a 'special' kind of wagon to be attached so I have my AI
run over all the wagons till it finds one that fits. (it does a bit more before and after as well though)

Code:
   //source is the 'best' wagon found earlier in the code
      if(source != null) moved = AIVehicle.MoveWagon(source,0,new_veh,0);
      if(!moved)
      {   
         AIVehicle.SellVehicle(source);
         new_wagon = null;
         foreach(wagon, _ in RoutePlanner.GetWagonList())
         {
            source = AIVehicle.BuildVehicle(depot, wagon);
            if(source != null) moved = AIVehicle.MoveWagon(source,0,new_veh,0);
            if(moved)
            {
               new_wagon = wagon;
               break;
            } else
            {
               AIVehicle.SellVehicle(source);   
            }
         }   
      }
//you still need to catch the possibility of not finding any good ones after this code but this should rarely happen


Attachments:
File comment: not attaching carts
simple.png [133.16 KiB]
Downloaded 1 time

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Top
   
PostPosted: Fri Jul 29, 2011 8:29 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9052
Location: Sol d
That seems to be a common problem which all train AIs need to solve somehow... maybe it's worth to implement this in form of a library or to add it to an existing one?

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Fri Aug 05, 2011 3:10 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 887
Sorry for the late reply, I was away 8)

In fact, I've already started tinkering with SimpleAI earlier this summer to create better support for NewGRF trainsets, namely UKRS and NARS. I've changed the engine selection algorithm and I also had to change those parts when train length is considered.
I've also had this problem with multiple unit engines, so thanks for the solution :)
My other current problem is the 3x Freightliner container rake in UKRS, as AIVehicle::GetLength() only returns a third of its real length.

I cannot promise anything, but NewGRF trainset support is on the way :)


Top
   
PostPosted: Fri Aug 12, 2011 5:08 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
And if you run the getLength() on the vehicle after attaching the wagon to the engine instead of just calling it on the wagon?

I use while (total_length < variable){this.AddWagon(veh); total_length = AIVehicle.GetLength(veh);}

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
PostPosted: Sat Aug 13, 2011 8:26 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 887
And what do you put into 'variable'? I think this would need selling the last wagon when the train gets too long. I'd rather avoid it, but if that's the only solution...


Top
   
PostPosted: Wed Jan 04, 2012 9:28 pm 
Offline
Engineer
Engineer

Joined: Tue Jan 03, 2012 4:47 pm
Posts: 3
Really nice AI. I like how there is nothing special about it, but i do have a suggestion, could you make it so that the AI knows when to stop building? In most of my games it builds itself to death and before long its in so much dept that it just dies. I could leave it in a map alone and it would lose.

I know you want to make this like the original AI, but just having the option would be nice, to make it more realistic and to make it more challenging. I wasint expecting it to be the most skilled AI, but its way too easy, and i don't want that to ruin it.


Top
   
PostPosted: Wed Jan 04, 2012 11:02 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 887
Although it's true that my goal is to imitate the old AI, but going bankrupt 'like the old AI' is a bit too much :D
I have tried to test it with different settings and under harder conditions, it doesn't really go bankrupt in my tests. So could you provide me a savegame in which SimpleAI goes bankrupt?

Anyway, a temporary solution to your problem could be that you increase the waiting time between constructing two routes, it's there among the settings. There is also the 'Slowdown effect' setting, which makes this waiting interval increase over time, so the AI will become slower after some years.


Top
   
PostPosted: Sun May 13, 2012 8:23 am 
Offline
Engineer
Engineer

Joined: Sun May 13, 2012 8:04 am
Posts: 5
Hey,

Dunno where to post bugreport so I place it here and hopefully it finds its addresse:

Code:
dbg: [script] [2] [S] Your script made an error: the index 'AI_ET_SUBSIDY_AWARDED' does not exist
dbg: [script] [2] [S]
dbg: [script] [2] [S] *FUNCTION [CheckEvents()] simpleai-6/manager.nut line [35]
dbg: [script] [2] [S] *FUNCTION [Start()] simpleai-6/main.nut line [121]
dbg: [script] [2] [S]
dbg: [script] [2] [S] [eventtype] 11
dbg: [script] [2] [S] [isloaded] false
dbg: [script] [2] [S] [loadedevent] ARRAY
dbg: [script] [2] [S] [event] INSTANCE
dbg: [script] [2] [S] [this] INSTANCE
dbg: [script] [2] [S] [this] INSTANCE
dbg: [script] The script died unexpectedly.


$ uname -a
Linux Khedron 3.2.0-2-amd64 #1 SMP Sun Apr 15 16:47:38 UTC 2012 x86_64 GNU/Linux

openttd 1.2.0


Top
   
PostPosted: Sun May 13, 2012 10:52 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 887
Thanks for the report :)
This one is strange, I'm not able to reproduce it in OpenTTD 1.2.0, it seems to be some API compatibility bug, a similar bug has been mentioned in the DictatorAI thread. I'm still not sure whether it's my fault or something is broken in the compatibility scripts, I'll have a look at it.

By chance, do you have a file named compat_1.0.nut in the ai directory of your OpenTTD installation? If not, that might be the case.

EDIT: It turns out that krinn was using a constant which is not defined in the 1.0 API, but AI_ET_SUBSIDY_AWARDED is definitely part of the 1.0 API. I'm really puzzled ?(


Top
   
PostPosted: Sun May 13, 2012 11:12 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4677
Location: home
It's called a 'bug in OpenTTD' :)
Please report it to flyspray.


Top
   
PostPosted: Sun May 13, 2012 1:45 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Wed Dec 20, 2006 1:31 pm
Posts: 978
Location: Aschaffenburg
annaiak wrote:
$ uname -a
Linux Khedron 3.2.0-2-amd64 #1 SMP Sun Apr 15 16:47:38 UTC 2012 x86_64 GNU/Linux

openttd 1.2.0
How did you install OpenTTD? Did you use the debian-provided package? Is "openttd-data" installed? Do you have the file
/usr/share/games/openttd/ai/compat_1.0.nut ?

_________________
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁


Top
   
PostPosted: Sun May 13, 2012 7:52 pm 
Offline
Engineer
Engineer

Joined: Sun May 13, 2012 8:04 am
Posts: 5
Who/what is flyspray? :-) (Sorry didn't report bug in ottd yet so I dunno.)

Yep from the deb package:
Code:
$ dpkg -l openttd*
||/ Name                                Version     
+++-===================================-=============
ii  openttd                             1.2.0-1     
ii  openttd-data                        1.2.0-1     
ii  openttd-opengfx                     0.4.4-1     
ii  openttd-openmsx                     0.3.1-2     
ii  openttd-opensfx                     0.2.3-3 


The file seems to be fine
Code:
$ ls -l /usr/share/games/openttd/ai/compat_1.0.nut
-rw-r--r-- 1 root root 5134 Apr 18 15:56 /usr/share/games/openttd/ai/compat_1.0.nut


Top
   
PostPosted: Sun May 13, 2012 9:38 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
what does it say if you try to list all compat_1.0.nut files on your system?
Code:
locate compat_1.0.nut


It might be the case that youhave an old compat_1.0.nut somewhere at your system from OpenTTD pre 1.2 which your 1.2 installation finds and uses instead of the installed one.


You could also upload the compat_1.0.nut file here and we can take a look at it to ensure that it is not broken. The compat_1.0.nut that I got in my 1.2.0 installation does not show the problem that you have.

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


Top
   
PostPosted: Sun May 13, 2012 10:25 pm 
Offline
Engineer
Engineer

Joined: Sun May 13, 2012 8:04 am
Posts: 5
That's it I guess!! :)
Not really sure how to verify, if the AI doesn't crash after deleting the file (the AI doesn't get to that event that often I guess). But I guess that the old file in my home is the cause of the issue.

Code:
$ locate compat_1.0.nut
~/.openttd/ai/compat_1.0.nut
~/.openttd/ai/compat_1.0.nut.bak
/usr/share/games/openttd/ai/compat_1.0.nut

$ ls -l ~/.openttd/ai/compat_1.0.nut*
-rw-r--r-- 1 roman roman 2651 Sep 12  2011 ~/.openttd/ai/compat_1.0.nut
-rwxr-xr-x 1 roman roman  646 Aug  1  2010 ~/.openttd/ai/compat_1.0.nut.bak

$ ls -l /usr/share/games/openttd/ai/compat_1.0.nut
-rw-r--r-- 1 root root 5134 Apr 18 15:56 /usr/share/games/openttd/ai/compat_1.0.nut

Sorry for causing all that fuzz :oops:


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 256 posts ]  Go to page Previous 18 9 10 11 12 13 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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.