Page 1 of 1
Inconsistency in the AIRoad class
Posted: 08 Aug 2008 11:44
by Maninthebox
The road class has a function called GetNeighbourRoadCount which does pretty much what you'd expect given it's name, but not entirely

I would expect such a function to return the same value as having a for loop going over all 4 neighbours and use IsRoadTile() on those and count the amount of trues. Unfortunately, it doesn't, as IsRoadTile counts drive through stations as road, whereas GetNeighbourRoadCount doesn't. Is this intentional? If not, could this get changed perhaps?
Re: Inconsistency in the AIRoad class
Posted: 12 Aug 2008 10:32
by Zutty
I'm not sure what the API function is
meant to do, but it might be best to re-evaluate your approach.
Are you a content entrant? If so I wont ask you to post any code but can you tell us what you are trying to achieve with GetNeighbourRoadCount()?
Perhaps you should have a special case for DTRSs. I know that might upset the elegance or simplicity of your current solution, but IMHO robustness is more important. The tricky thing with DTRSs is that they MIGHT not be facing the right way, so just using IsRoadTile() on a DTRS isn't enough to say whether or not you can plow a route through it.
Imagine a situation like this...

- dtrs-problem.PNG (8.8 KiB) Viewed 2332 times
In step 2 the town just randomly builds a bit of road that happens to conenct to the wrong side of a DTRS. Then in step 3 the pathfinder comes along, sees that IsRoadTile() for the DRTS returns true, and tries to make an invalid connection.
Re: Inconsistency in the AIRoad class
Posted: 12 Aug 2008 12:59
by Yexo
Zutty wrote:In step 2 the town just randomly builds a bit of road that happens to conenct to the wrong side of a DTRS. Then in step 3 the pathfinder comes along, sees that IsRoadTile() for the DRTS returns true, and tries to make an invalid connection.
The last thing is not true, since the pathfinder uses BuildRoad in testmode to see if the route can be build, so it will never find a route though the wrong side of a drive-through station.
Re: Inconsistency in the AIRoad class
Posted: 12 Aug 2008 13:21
by Zutty
Oh I didn't know that, but then that depends on whether or not he is using the library pathfinder.
Really I was just trying to demonstrate that simply using IsRoadTile() isn't enough. I'm sure everyone knows this already anyway!
Re: Inconsistency in the AIRoad class
Posted: 12 Aug 2008 14:43
by wilco_moerman
Something related to this. I noticed that if you build a tunnel with minimum length (entrance and exit are adjacent tiles) that AIRoad.AreRoadTilesConnected(tunnel_entrance, tunnel_exit) returns false.
I don't know if this is by design or if it is a bug?
Re: Inconsistency in the AIRoad class
Posted: 13 Aug 2008 09:08
by Maninthebox
I am a contestant in the TJIP challenge, so I can't say too much about what I'm doing or show code

But Zutty illustrates nicely the problem with having DTRS in neighbourcount: you'd like to have the DTRS in the neighbourcount if and only if the orientation allows you to drive through it from the tile you passed as a parameter to this function and not while approaching it from the side. This might just be my interpretation though as I'm not sure what the original intent was for this function.