Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sun Dec 16, 2018 12:20 am

All times are UTC




Post new topic  Reply to topic  [ 30 posts ]  Go to page 1 2 Next
Author Message
 Post subject: MedievalAI (v3)
PostPosted: Sun Jun 29, 2008 11:03 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Version 3 Released


---------------ORIGINAL POST---------------------

...doesn't work yet.

I am releasing what I have done of my AI so far for the purpose of helping fix a problem that I find a bit strange, but hopefully will be easy to fix.

In my .nut file at line 19, if the second parameter of BuildRoads is the variable declared in line 17 (or 15 for that matter) then it will freeze. If that line (19) is commented out then it works as it should, aside from not building roads.

Any help is appreciated.


Attachments:
medievalai.tar [67 KiB]
Downloaded 463 times

_________________
Witty Signature!
Image


Last edited by Sir Bob on Tue Jan 27, 2009 12:06 am, edited 4 times in total.
Top
   
 Post subject: Re: MedievalAI
PostPosted: Sun Jun 29, 2008 11:44 am 
Offline
Engineer
Engineer
User avatar

Joined: Sun Dec 25, 2005 11:01 pm
Posts: 45
Location: Australia
There's an issue with your pathfinder somewhere so that should give you a place to start.

You can add the line "AIController.Sleep(1);" to the start of the while loop (line 190ish) so that OpenTTD doesn't lock up completely which should help for testing :wink:

_________________
This is my sig


Top
   
 Post subject: Re: MedievalAI
PostPosted: Sun Jun 29, 2008 11:56 am 
Offline
Engineer
Engineer
User avatar

Joined: Mon Jun 21, 2004 3:25 pm
Posts: 87
Looks like an infinite loop in your pathfinder somewhere as the bus stop building works for me.

Edit: Weird, if I crash the pathfinder with an extra statement it builds both bus stops, but only builds one of its allowed to run.


Top
   
 Post subject: Re: MedievalAI
PostPosted: Sun Jun 29, 2008 12:03 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
In the while loop within your pathfinder you have the following code:
Code:
if(AITile.IsBuildable(i) && !closedList.HasItem(i) || AIRoad.IsRoadTile(i) ) {

This is:
1) Not what you want (If the tile is a road tile and in your closed list it'll still be searched).
2) A non-drive through road station is NOT a road tile and NOT buildable, so you'll never reach your goal tile. Because you have no code to check for a maximum route distance, your pathfinder will search the whole map for your goal tile, and that'll take a while :).

Please debug yourself next time, that can be as easy as adding
Code:
         AIController.Sleep(1);
         AISign.BuildSign(currNode.location, ""+nextPos);

As the first lines in your while loop. You'd have spotted easily that the pathfinder found all tiles around the goal station but not the station itself.


Top
   
 Post subject: Re: MedievalAI
PostPosted: Sun Jun 29, 2008 1:24 pm 
Offline
Engineer
Engineer

Joined: Sat Dec 22, 2007 1:04 am
Posts: 52
Yexo wrote:
In the while loop within your pathfinder you have the following code:
Code:
if(AITile.IsBuildable(i) && !closedList.HasItem(i) || AIRoad.IsRoadTile(i) ) {

This is:
1) Not what you want (If the tile is a road tile and in your closed list it'll still be searched).
2) A non-drive through road station is NOT a road tile and NOT buildable, so you'll never reach your goal tile. Because you have no code to check for a maximum route distance, your pathfinder will search the whole map for your goal tile, and that'll take a while :).

Please debug yourself next time, that can be as easy as adding
Code:
         AIController.Sleep(1);
         AISign.BuildSign(currNode.location, ""+nextPos);

As the first lines in your while loop. You'd have spotted easily that the pathfinder found all tiles around the goal station but not the station itself.


Another IsRoadTile on a station casualty I see. :) That got me as well, how I do it is walk the roads using IsRoadTile, but when I check the adjacent tiles for tiles to add to the open list, just check for IsRoadStationTile.

Or, If you know the tile of the location you are trying to go to or from, just check to see if you are trying to add that tile. No need to care about if a station is on it or not. You know it is since you built one there.

MarkS.


Top
   
 Post subject: Re: MedievalAI
PostPosted: Mon Jun 30, 2008 1:27 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
OK thanks for the help guys, problem solved :) (if you're wondering, I just changed the start and end tiles to the tile outside the bus stop, I know this may not be the ideal solution, but I'm improving it bit by bit :)))

Stay tuned for a working release soon (hopefully).

(BTW, I do generally debug myself, this one just confused me a bit because that code had been working previously)

_________________
Witty Signature!
Image


Top
   
 Post subject: Re: MedievalAI
PostPosted: Thu Aug 14, 2008 7:25 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
OK, there is now a working version of MedievalAI in the first post (for tournament inclusion please :))). I'm not expecting it to really challenge to any of the others yet, just want to see where it's at :).

_________________
Witty Signature!
Image


Top
   
 Post subject: Re: MedievalAI (v1.0)
PostPosted: Fri Aug 15, 2008 10:56 am 
Offline
Director
Director
User avatar

Joined: Tue Jan 22, 2008 4:33 pm
Posts: 565
Nice work Sir Bob.

It looks like your using your own pathfinder, and I notice there is something in there to detect the current build-on-slopes setting. This is something that I really need to implement, but at the moment I'm using AIRoad.CanBuildConnectedRoadPartsHere(), which is a total cop-out! I couldn't get my own slope detectory thing working very well, so I just switched it off.

Do you have any tips? :)

_________________
PathZilla - A networking AI - Now with tram support.


Top
   
 Post subject: Re: MedievalAI (v1.0)
PostPosted: Fri Aug 15, 2008 11:21 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Do you mean with detecting build-on-slopes? For that I used:

Code:
   if(AIGameSettings.IsValid("construction.build_on_slopes") && 
          AIGameSettings.GetValue("construction.build_on_slopes")) {
      AILog.Info("Can Build on Slopes");
      gameSettings.buildSlopes = true;
   }


If you ment with slope detection, I did something similar to you but not as neat :P. I check for which direction I'm coming from then what the next slope is. I actually had forgotten about my slopes a bit so this isn't implemented, but after checking for that I'm going to limit the directions it can turn in so as to avoid any problems with foundations and such. In fact you've just inspired me to fix up mine a bit!

EDIT: Forgot I had a new version.


Attachments:
medievalai.tar [103.5 KiB]
Downloaded 134 times

_________________
Witty Signature!
Image
Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Fri Jan 23, 2009 3:35 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Hey All!

Thought I should get a new version of MedievalAI out. (Available here and in-game content downloader)

At the moment the only major bug I know of is that you can only have one instance of it at a time, and I have no idea why. (Any idea why this might be devs?)

Sir Bob


Attachments:
File comment: MedievalAI v2
medievalai.tar [182 KiB]
Downloaded 90 times

_________________
Witty Signature!
Image
Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Fri Jan 23, 2009 8:45 am 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Sir Bob wrote:
At the moment the only major bug I know of is that you can only have one instance of it at a time, and I have no idea why. (Any idea why this might be devs?)

Yes, it's because of this code in your start function:
Code:
   if (!AICompany.SetName("MedievalAI #1")) 
   {
      for(local i = 0; ; i++)
      {
      
      }
   }


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Fri Jan 23, 2009 11:52 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Thanks Yexo, forgot to finish that function. :oops:

New Version 2.


Attachments:
File comment: New Version.
medievalai.tar [180.5 KiB]
Downloaded 97 times

_________________
Witty Signature!
Image
Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Fri Jan 23, 2009 12:31 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Regarding the content server, you may want to stick to the tags the other AI writers agreed on (i.e. singular: "bus", "truck" instead of "buses", "trucks"). ;)

It doesn't have a real purpose (afaik) right now, but I can imagine a filter option for that list to display only Items containing those keywords.. in fact I'm just gonna suggest this in the content service thread.

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Fri Jan 23, 2009 11:25 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Done. :wink:

_________________
Witty Signature!
Image


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Sat Jan 24, 2009 11:42 am 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
In a game with different AIs I just started, MedievalAI built two stations that don't fit together (A truck station near a forest, and a bus station in a town), and only outputs some cryptic messages in the AI Debug window...
Attachment:
Unnamed, 1951-02-04.png [183.52 KiB]
Downloaded 92 times



edit: I restarted it, and this time he built a faulty bus line again, but then a working truck line. This is the output of when he made the faulty bus line (only one bus stop)
Attachment:
Unnamed, 1951-03-18.png [185.4 KiB]
Downloaded 76 times


edit: after some time it again outputs stuff like in the first screenshot. Unfortunately I didn't see what it wrote before starting to write this "aT:C ..." stuff

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Sat Jan 24, 2009 12:18 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Thanks Roujin, I'm trying to fix that at the moment :)

_________________
Witty Signature!
Image


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Sat Jan 24, 2009 1:58 pm 
Offline
Director
Director
User avatar

Joined: Tue Jan 22, 2008 4:33 pm
Posts: 565
Hi Sir Bob,

Nice AI, though I note it seems not to be compatible with articulated road vehicles (using eGRVTS)...

Attachment:
mdvl-arvbug.png [221.75 KiB]
Downloaded 67 times


You can use AIEngine.IsArticulated() or build DTRSs to prevent this.

I also got a rather odd problem where the AI seemed to enter a very intensive, possibly infinte loop. The whiole game became very laggy and I saw this in the debug window...

Attachment:
mdvl-1965-bug.png [289.84 KiB]
Downloaded 65 times

Attachment:
File comment: Saved in r15235 using MedievalAI v2 w/ av8
mdvl-1965.sav [93.5 KiB]
Downloaded 85 times


It looks to me like its trying to connect that bus stop to the road but can;t because either A) the slopes are wrong or B) those buses are in the way.

Hope this helps :)

_________________
PathZilla - A networking AI - Now with tram support.


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Sat Jan 24, 2009 2:05 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Thanks for the feedback Zutty.

I've managed to fix the looping bug in my local version and I'm going to go back and double check my slope detection.

I'll use those checks to make sure I don't build aRV's just yet.

Looks like we'll need a new release soon 8)

Sir Bob

_________________
Witty Signature!
Image


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Sat Jan 24, 2009 3:47 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Mon May 31, 2004 9:21 am
Posts: 1303
Code:
dbg: [ai] [1] [S] Your script made an error: division by zero
dbg: [ai] [1] [S] CALLSTACK
dbg: [ai] [1] [S] *FUNCTION [CheckForVehiclesNeeded()] MedievalAI.2.tar/medievalai.2/Vehicles.nut line [152]
dbg: [ai] [1] [S] *FUNCTION [Start()] MedievalAI.2.tar/medievalai.2/main.nut line [102]


Just so you know :)

_________________
The only thing necessary for the triumph of evil is for good men to do nothing.


Top
   
 Post subject: Re: MedievalAI (v2.0)
PostPosted: Sat Jan 24, 2009 10:52 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Sat Oct 07, 2006 9:08 am
Posts: 214
Location: Melbourne, Australia
Got that one too :wink:

_________________
Witty Signature!
Image


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 30 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

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