AITile::LevelTiles

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

Post Reply
deepblue2k8
Engineer
Engineer
Posts: 44
Joined: 06 Sep 2008 12:41
Location: Hamburg, Germany

AITile::LevelTiles

Post by deepblue2k8 »

Hello everybody,

I have a question regarding the AITiles.LevelTiles function.

In the NOAI documenten it states that it returns:

"True if and only if the area was completely leveled. "


But I discovered some weird behavouir, when testing my AI. It seems that the function returns still true even if only some of the tiles got leveled, because in this example the Coal Mine is in the way.

I attached an image which illustrates the behaviour.

The two signs labeled "LS" and "LE" (the "LE" belongs to the sloped tile blow the sign itself) mark the first and last tile, which were given to the function as parameters.

In the debug log after "Building station 1!" you see the output of the AIError.GetLastErrorString() function and the the line after that the return value of the AITiles.LevelTiles function ("ret true").
The station was built after AITile.LevelTiles returned true.

Thanks
BlueAI, 6th Jan 1950#1.png
BlueAI, 6th Jan 1950#1.png (43.34 KiB) Viewed 487 times
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AITile::LevelTiles

Post by Yexo »

The problem here is the documentation. It should have read:

Returns true if some part of the area was levelled.

Edit: fixed in r17049.
deepblue2k8
Engineer
Engineer
Posts: 44
Joined: 06 Sep 2008 12:41
Location: Hamburg, Germany

Re: AITile::LevelTiles

Post by deepblue2k8 »

Ok thanks, that makes the function a bit less useful, but it is the same behaviour as the level tool in the GUI.

So I will have to invent my own then :D
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: AITile::LevelTiles

Post by Michiel »

That's what I did, too. Looks better as well, seeing it dig away at a mountain, tile by tile :)
deepblue2k8
Engineer
Engineer
Posts: 44
Joined: 06 Sep 2008 12:41
Location: Hamburg, Germany

Re: AITile::LevelTiles

Post by deepblue2k8 »

hehe, thats right. And I think I write my function so that it trys to do as little terraforming as possible first and if that fails it will go crazy and doesnt care anymore ;)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests