MedievalAI (v3)
Moderator: OpenTTD Developers
MedievalAI (v3)
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.
---------------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 615 times
Last edited by Sir Bob on 27 Jan 2009 00:06, edited 4 times in total.
Witty Signature!

Re: MedievalAI
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
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

This is my sig
Re: MedievalAI
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.
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.
Re: MedievalAI
In the while loop within your pathfinder you have the following code:
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
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.
Code: Select all
if(AITile.IsBuildable(i) && !closedList.HasItem(i) || AIRoad.IsRoadTile(i) ) {
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: Select all
AIController.Sleep(1);
AISign.BuildSign(currNode.location, ""+nextPos);
Re: MedievalAI
Another IsRoadTile on a station casualty I see.Yexo wrote:In the while loop within your pathfinder you have the following code:This is:Code: Select all
if(AITile.IsBuildable(i) && !closedList.HasItem(i) || AIRoad.IsRoadTile(i) ) {
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 addingAs 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.Code: Select all
AIController.Sleep(1); AISign.BuildSign(currNode.location, ""+nextPos);

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.
Re: MedievalAI
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)


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!

Re: MedievalAI
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!

Re: MedievalAI (v1.0)
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?
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.
Re: MedievalAI (v1.0)
Do you mean with detecting build-on-slopes? For that I used:
If you ment with slope detection, I did something similar to you but not as neat
. 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.
Code: Select all
if(AIGameSettings.IsValid("construction.build_on_slopes") &&
AIGameSettings.GetValue("construction.build_on_slopes")) {
AILog.Info("Can Build on Slopes");
gameSettings.buildSlopes = true;
}

EDIT: Forgot I had a new version.
- Attachments
-
- medievalai.tar
- (103.5 KiB) Downloaded 269 times
Witty Signature!

Re: MedievalAI (v2.0)
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
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
-
- medievalai.tar
- MedievalAI v2
- (182 KiB) Downloaded 235 times
Witty Signature!

Re: MedievalAI (v2.0)
Yes, it's because of this code in your start function: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?)
Code: Select all
if (!AICompany.SetName("MedievalAI #1"))
{
for(local i = 0; ; i++)
{
}
}
Re: MedievalAI (v2.0)
Thanks Yexo, forgot to finish that function.
New Version 2.

New Version 2.
- Attachments
-
- medievalai.tar
- New Version.
- (180.5 KiB) Downloaded 236 times
Witty Signature!

Re: MedievalAI (v2.0)
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.

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.
Re: MedievalAI (v2.0)
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...
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) 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
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) 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
Re: MedievalAI (v2.0)
Hi Sir Bob,
Nice AI, though I note it seems not to be compatible with articulated road vehicles (using eGRVTS)...
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...
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
Nice AI, though I note it seems not to be compatible with articulated road vehicles (using eGRVTS)...
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...
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.
Re: MedievalAI (v2.0)
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
Sir Bob
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

Sir Bob
Witty Signature!

Re: MedievalAI (v2.0)
Code: Select all
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]

The only thing necessary for the triumph of evil is for good men to do nothing.
Who is online
Users browsing this forum: No registered users and 7 guests