NoAI Branch - An AI Framework

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

wilco_moerman
Engineer
Engineer
Posts: 70
Joined: 05 Jun 2008 15:51

Re: NoAI Branch - An AI Framework

Post by wilco_moerman »

TrueLight wrote: Nightlies run every night at 1800 CEST ... and the commits are made after that ;) So check back in ... 10 minutes :p
hmmm, I still get the same error with r13474. Pressing the "reload AI" button still crashes the game :(
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NoAI Branch - An AI Framework

Post by Yexo »

wilco_moerman wrote:
TrueLight wrote: Nightlies run every night at 1800 CEST ... and the commits are made after that ;) So check back in ... 10 minutes :p
hmmm, I still get the same error with r13474. Pressing the "reload AI" button still crashes the game :(
Can you post your ai? That'll help debugging the problem.

Are you using windows/linux?
User avatar
glx
OpenTTD Developer
OpenTTD Developer
Posts: 622
Joined: 02 Dec 2005 15:43
Location: Drancy(93) - France
Contact:

Re: NoAI Branch - An AI Framework

Post by glx »

And we need the exact message if there's any.
wilco_moerman
Engineer
Engineer
Posts: 70
Joined: 05 Jun 2008 15:51

Re: NoAI Branch - An AI Framework

Post by wilco_moerman »

Yexo wrote: Can you post your ai? That'll help debugging the problem.
I'm in the TJIP competition, so that is a problem. But I can recreate the problem without giving away any juicy bits :D
If I try to start Convoy (posted earlier in this topic) or wrightai the same happens. So it would seem that it is not specific for my AI.
Are you using windows/linux?
windows 2000
Last edited by wilco_moerman on 11 Jun 2008 16:53, edited 1 time in total.
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
wilco_moerman
Engineer
Engineer
Posts: 70
Joined: 05 Jun 2008 15:51

Re: NoAI Branch - An AI Framework

Post by wilco_moerman »

glx wrote:And we need the exact message if there's any.
I only get a screen saying "Runtime Error!" and "abnormal program termination"



edit:
my error is similar to this post from earlier in this topic, only for the latest binaries I don't get this error, only the runtime error + abnormal termination.
kuifware wrote:(..)

Bug report: I noticed that in the latest SVN revision (r13197-noai) you can crash OpenTTD by starting an AI, issuing the restart command in the in-game console and starting an AI again:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Assertion failed!

Program: C:\Games\OpenTTDNoAI\openttd.exe
File: /compile_farm/openttd/noai/compile.../ai_threads.cpp
Line: 370

Expression: thr == NULL

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

(Press Retry to debug the application - JIT must be enabled)
---------------------------
Abort Retry Ignore
---------------------------
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post by reylas »

I am having slope problems and was wondering if anyone would look at what I have and see if they can explain it. I was trying to build a bus station and connecting road but was not getting the bus station oriented in the correct direction. Basically, I look for a build-able tile next to a road tile then level it if need be then build a station. This tile happens to have two neighbor road tiles, but cannot build a road. If you look at the screenshot at the tile with a sign with a minus after it, that is the tile I am trying to build on. The first number of the sign represents a slope, while the second represents the height.

So I figured, no problem, just check the slope and height to check for a road on my level. But when I tried, I never could get it to work. So I wrote a little function to build signs to help me out. What I found was that the slopes and heights do not really match what the graphics were showing.

For instance. To the SE of the - tile, it shows a slope of 2, height of 5. So it thinks the height is the same as my station (-) tile. But the tile to the south of my tile shows a slope of 4 and a height of 5 as well. But the foundation clearly shows it sloping to the west. But the next tile shows a slope of 0 and a height of 5. So two tiles with a slope of 2 and 4 slope to a tile that is level with a height the same as it is. If you look at the two houses to the SW of my tile (-), they show slopes, but non matching heights. Plus the road to the south of my tile clearly shows a graphic for a sloping road. But the road ends up with the same height on both ends of the slope, but the tile to the SW of my (-) tile shows the same height, but is sloped?

Does that make any sense? Or am I looking at it wrong. I am trying to figure out how to not build if the road tile cannot be connected to, but with the slopes not matching and the heights the same, I cannot figure it out.

Sorry to be so winded.

MarkS
Attachments
Unnamed, 24th Jan 1934.png
Screenshot showing bad slopes.
(545.17 KiB) Downloaded 58 times
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post by reylas »

Here is the same town without signs. That way you can compare the spot I want to build with the road to it's SE. They should be the same, but they are not. But drive down the little hill, and you are at the same level as the spot I want to build.

MarkS
Attachments
Mendingtown Transport, 3rd Feb 1934.png
(560.55 KiB) Downloaded 35 times
User avatar
YukonRob
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 31 Jul 2007 00:58
Location: North of 63

Re: NoAI Branch - An AI Framework

Post by YukonRob »

I think you are being confused by the foundations. It looks like the slope/height are returning the original ground values before foundations are built, try removing the road, buildings etc. in the photo and then compare the heights to the terrain.
HTH,
Rob
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: NoAI Branch - An AI Framework

Post by Roujin »

Don't know if that helps you, but afaik the height is the height of the northern corner of the tile.

So to get proper information of a tile "A", i'd get the tileheight of A, A+(0,1), A+(1,0) and A+(1,1).
* @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
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: NoAI Branch - An AI Framework

Post by GeekToo »

Update of Convoy:

Recent developments ( especially the different behaviour of IsBuildable ) did make the pathfinding of the previous Convoys pretty useless ( as is: not able to find a route ). I tried integrating the BinHeap of the library, as it was better coded than my version ( that is, being a much more pure Container class), but unfortunately, the performance was a lot worse than in my previous Convoy version. Main reason: the Exists function, which does compare a complete node. Suggestion to the devs: add an id to the Insert parameter list.
So for now, I still use my own BinHeap.

Lots of things have improved since the previous version, and I realise lots of things still have to be done.
Attachments
Convoy.tar
(40 KiB) Downloaded 111 times
User avatar
Ralph
Engineer
Engineer
Posts: 87
Joined: 21 Jun 2004 15:25

Re: NoAI Branch - An AI Framework

Post by Ralph »

reylas wrote:I am having slope problems and was wondering if anyone would look at what I have and see if they can explain it. I was trying to build a bus station and connecting road but was not getting the bus station oriented in the correct direction. Basically, I look for a build-able tile next to a road tile then level it if need be then build a station. This tile happens to have two neighbor road tiles, but cannot build a road. If you look at the screenshot at the tile with a sign with a minus after it, that is the tile I am trying to build on. The first number of the sign represents a slope, while the second represents the height.

So I figured, no problem, just check the slope and height to check for a road on my level. But when I tried, I never could get it to work. So I wrote a little function to build signs to help me out. What I found was that the slopes and heights do not really match what the graphics were showing.

For instance. To the SE of the - tile, it shows a slope of 2, height of 5. So it thinks the height is the same as my station (-) tile. But the tile to the south of my tile shows a slope of 4 and a height of 5 as well. But the foundation clearly shows it sloping to the west. But the next tile shows a slope of 0 and a height of 5. So two tiles with a slope of 2 and 4 slope to a tile that is level with a height the same as it is. If you look at the two houses to the SW of my tile (-), they show slopes, but non matching heights. Plus the road to the south of my tile clearly shows a graphic for a sloping road. But the road ends up with the same height on both ends of the slope, but the tile to the SW of my (-) tile shows the same height, but is sloped?

Does that make any sense? Or am I looking at it wrong. I am trying to figure out how to not build if the road tile cannot be connected to, but with the slopes not matching and the heights the same, I cannot figure it out.

Sorry to be so winded.

MarkS
As far as I can tell from the screenshot both the tile you want to build the stop on and the road are flat, and both the same height, so slopes shouldn't be an issue.

Make sure you build the road from the tile you want the bus stop on, to the road, then build the bus stop.
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post by reylas »

[quote="Ralph]
As far as I can tell from the screenshot both the tile you want to build the stop on and the road are flat, and both the same height, so slopes shouldn't be an issue.

Make sure you build the road from the tile you want the bus stop on, to the road, then build the bus stop.[/quote]


That is the problem.. It codes like it should work, but it looks like it wont. And it does not. I cannot build a road there.

MarkS.
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post by reylas »

Roujin wrote:Don't know if that helps you, but afaik the height is the height of the northern corner of the tile.

So to get proper information of a tile "A", i'd get the tileheight of A, A+(0,1), A+(1,0) and A+(1,1).
Ok, that helps A LOT, that is good information to know. But, it still does not make sense. Another example. If you look at the tile directly below the tile I want to build, it has a sign of 4,5. Meaning Slope_E, height of 5. But the tile to the SW of that, (turn in the road) has a slope of 0 meaning flat, but a height of 5. The wiki states that Slope_E would mean that the east point of the tile would be the highest spot on that tile. But it is the *same* height as the one with the turn in the road. So in order for the road to have been built, should the tile not have a slope of 12? 12 would mean N and E which would match the road incline.

Plus the tile I want to connect to (2,5) has a slope of 2 or Slope_S. meaning it slopes up to the southern point, which means it's Southern tip is higher than its western tip. So how could that road be there if that is the case?

Or am I not understanding the numbers?

Sorry to be a bother, I really am enjoying making AI's

Marks
User avatar
Ralph
Engineer
Engineer
Posts: 87
Joined: 21 Jun 2004 15:25

Re: NoAI Branch - An AI Framework

Post by Ralph »

reylas wrote:[
Try your Building operation then check for an error with AILog.Info(AIError.GetLastErrorString())

maybe something there.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: NoAI Branch - An AI Framework

Post by Zutty »

As Roujin pointed out, the height of a tile is measured at the north corner. If your AI is trying to connect to the road to the SE then it SHOULD fail as the road on that tile is raised on foundations. You can get the selection routine to discount this tile if you consider two things. A) The direction of the road on that tile, and B) The direction of the slope on that tile. When considering whether or not a road can connect to any adjacent road, the slopes are more important than the tile height.

Since the slope has just one corner raised then the road on it could go in either direction. If the road was facing towards the proposed bus station tile then that site WOULD be valid, but because the road is facing in the other direction then the bus station faces the foundation and can't connect to the road.

In general terms...
- A road on a slope can face either N-S or E-W. Because of the way tiles fit together this is all we need to know.
- If the road on a slope is moving parallel to the proposed station tile then discount it.
- If the road on a slope is moving towards/away from the proposed station tile then consider it
- - On a slope with two corners raised the road can only go in the direction of the slope on the tile, so test that (easier!).
- - On a slope with one corner raised the road can go either way so we must test the road itself (need to query adjacent road tiles).

I hope that makes sense.
PathZilla - A networking AI - Now with tram support.
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post by reylas »

Zutty wrote:As Roujin pointed out, the height of a tile is measured at the north corner. If your AI is trying to connect to the road to the SE then it SHOULD fail as the road on that tile is raised on foundations. You can get the selection routine to discount this tile if you consider two things. A) The direction of the road on that tile, and B) The direction of the slope on that tile. When considering whether or not a road can connect to any adjacent road, the slopes are more important than the tile height.

Since the slope has just one corner raised then the road on it could go in either direction. If the road was facing towards the proposed bus station tile then that site WOULD be valid, but because the road is facing in the other direction then the bus station faces the foundation and can't connect to the road.

In general terms...
- A road on a slope can face either N-S or E-W. Because of the way tiles fit together this is all we need to know.
- If the road on a slope is moving parallel to the proposed station tile then discount it.
- If the road on a slope is moving towards/away from the proposed station tile then consider it
- - On a slope with two corners raised the road can only go in the direction of the slope on the tile, so test that (easier!).
- - On a slope with one corner raised the road can go either way so we must test the road itself (need to query adjacent road tiles).

I hope that makes sense.
I understand what you are saying, I just can't see how my situation matches it. Either the height of the two tiles or the slope of the road tile does not jive. Talking about only two tiles there, (0,5 -) and the (2,5) to the southeast of it, They both have the same height, and their shared border is level (only slope is a two which is south on the road tile).

A. There seems to be a foundation there that does not make sense.
B. If the slope is to the South, meaning the southern point is higher, then how can the road be there anyway?
C. Since my tile is perfectly level, and the tile I want to connect to is the same height with only a slope on the southern point, how come I cannot build there? The road seems to me should not be there.

Also, if you look to the north east, you will see a slope of 27. Is that possible?

I understand that it is a half road on that tile, but the road is in the slope, that would imply that the west point must be sloped as well correct?

MarkS.
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post by reylas »

Ok, one more question. So does that mean a road, house, or tree tile does not have to be level? So if a house is there, then the house may be level ( as shown by the foundations) but the underlying tile is still sloped?

If that is the case, then that changes A LOT. I could see that with houses, but would a road not have to level the tile underneath (or at least the section covered by a road?

MarkS.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoAI Branch - An AI Framework

Post by TrueBrain »

GeekToo wrote:Update of Convoy:

Recent developments ( especially the different behaviour of IsBuildable ) did make the pathfinding of the previous Convoys pretty useless ( as is: not able to find a route ). I tried integrating the BinHeap of the library, as it was better coded than my version ( that is, being a much more pure Container class), but unfortunately, the performance was a lot worse than in my previous Convoy version. Main reason: the Exists function, which does compare a complete node. Suggestion to the devs: add an id to the Insert parameter list.
So for now, I still use my own BinHeap.

Lots of things have improved since the previous version, and I realise lots of things still have to be done.

Nice job :) I will run it on the tournament server soon :)

About the Binary Heap: the Exist() function is identical to yours ... so why don't you just insert the index? Via the index you can find back your node by your own... I mean, easy as pie ;) Adding something like an other 'id' field to the list, only makes it less of a Binary Heap, and makes it break/slow for other routines :) This is the most pure implementation you can get :) (as it doesn't assume anything about the outside world :) )

Also, if you need Exist() in the first please, a Binary Heap is not what you need :) Binary Heap is to sort, and find the lowest value :) If you want to avoid double entries, I suggest using AIList, or create an other kind of list :) Binary Heap is _not_ your friend (Exist() is always O(n)). If you use it for any AyStar alike routine, I suggest looking at the AyStar library ;) Hehe :)

Either way, please let me know how you estimated the 'performance' of your own routine against the one in SVN.
The only thing necessary for the triumph of evil is for good men to do nothing.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NoAI Branch - An AI Framework

Post by Yexo »

reylas wrote:Ok, one more question. So does that mean a road, house, or tree tile does not have to be level? So if a house is there, then the house may be level ( as shown by the foundations) but the underlying tile is still sloped?

If that is the case, then that changes A LOT. I could see that with houses, but would a road not have to level the tile underneath (or at least the section covered by a road?

MarkS.
That is indeed the case. Every occasion you see foundations, the underlying tile isn't flat. This is the same with houses and roads. So even if a road seems to be flat, the tile underneed need not also be flat.
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post by reylas »

Yexo wrote:
reylas wrote:Ok, one more question. So does that mean a road, house, or tree tile does not have to be level? So if a house is there, then the house may be level ( as shown by the foundations) but the underlying tile is still sloped?

If that is the case, then that changes A LOT. I could see that with houses, but would a road not have to level the tile underneath (or at least the section covered by a road?

MarkS.
That is indeed the case. Every occasion you see foundations, the underlying tile isn't flat. This is the same with houses and roads. So even if a road seems to be flat, the tile underneed need not also be flat.
Ok, so is there anyway to tell if a tile has a foundation on it? According to the slope of the tile, I should be able to build, but I cannot. In code the only way I can tell I cannot build is to build and then fail. That is tough since I really need to build to the north east but my program found the south east tile first. There has to be some way of seeing before hand that that tile is not connectable by slope. A pathfinder will need that.

MarkS
Locked

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests