Page 1 of 1

AITile::LevelTiles

Posted: 02 Aug 2009 20:07
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 488 times

Re: AITile::LevelTiles

Posted: 02 Aug 2009 20:51
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.

Re: AITile::LevelTiles

Posted: 02 Aug 2009 21:41
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

Re: AITile::LevelTiles

Posted: 03 Aug 2009 14:15
by Michiel
That's what I did, too. Looks better as well, seeing it dig away at a mountain, tile by tile :)

Re: AITile::LevelTiles

Posted: 04 Aug 2009 08:29
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 ;)