New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AI builds impossible/broken tiles #6951
Comments
It turns out the issue is that the AI selects railtype 0x20 or 0x21 (decimal 32 and 33) even though they don't exist. The cause is that a HasBit test is done with 32 bit wide integers, where it should be 64 bit wide, so a test for values >= 32 truncates. This means that a company with railtypes 0 and 1 (normal and elrail) available also appears to have railtypes 32 and 33 available. Those have higher ID, so the AI might assume they are automatically better. Lines 188 to 191 in 50efaa2
The HasRailtypeAvail function is used for all relevant tests, it appears, and changing the HasBit call to explicitly use an |
The presence of this bug seems to be compiler-dependent, which you might expect. It's not present on a Linux system with g++ 8.2.1, only confirmed on Windows with Visual C++ 2015 Update 3. |
Some compilers (like VC++ 2015) will otherwise narrow it in some contexts where it should not be.
Some compilers (like VC++ 2015) will otherwise narrow it in some contexts where it should not be.
While testing another issue, I had an AI build this:
AI used in RailwAI v7 on master rev 50efaa2. Not tested with other AI scripts yet.
Does not happen in 1.8.0.
It seems the AI somehow builds two impossible tiles, and after building those it can't continue building the intended route. Using the switch company cheat, it is possible to demolish these tiles. (It's very cheap or free to do so.) The impossible tiles cause Hall of Mirrors effects when zooming, moving GUI over them, etc.
The text was updated successfully, but these errors were encountered: