You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Position and TilePosition objects are implicitly converted to each other. This means that this is possible:
BWAPI::Position a(100,100);
BWAPI::TilePosition b = a;
This sometimes causes accidental problems because the .getDistance function returns other distances when comparing Positions and the same converted TilePositions. Also, converting to a TilePosition causes accuracy loss.
Another related issue is that when converting BWAPI::Position::Invalid to a TilePosition it does not become equal to BWAPI::TilePosition::Invalid.
To solve this I would like to suggest using explicit type conversion instead of implicit, which would mean the above would need to be written as:
BWAPI::Position a(100,100);
BWAPI::TilePosition b = (BWAPI::TilePosition)a;
The thing I suggest changing is that currently, Positions are converted automatically to TilePositions. (As illustrated in the example.) This is not correct behavior considering converting between them causes loss of accuracy.
The only thing that would need changing in the BWAPI source code is:
TilePosition(const BWAPI::Position&);
to
explicit TilePosition(const BWAPI::Position&);
(and any implicitely converted Position will now generate a warning or error)
From blued...@gmail.com on September 16, 2010 10:06:50
Currently, Position and TilePosition objects are implicitly converted to each other. This means that this is possible:
BWAPI::Position a(100,100);
BWAPI::TilePosition b = a;
This sometimes causes accidental problems because the .getDistance function returns other distances when comparing Positions and the same converted TilePositions. Also, converting to a TilePosition causes accuracy loss.
Another related issue is that when converting BWAPI::Position::Invalid to a TilePosition it does not become equal to BWAPI::TilePosition::Invalid.
To solve this I would like to suggest using explicit type conversion instead of implicit, which would mean the above would need to be written as:
BWAPI::Position a(100,100);
BWAPI::TilePosition b = (BWAPI::TilePosition)a;
Original issue: http://code.google.com/p/bwapi/issues/detail?id=238
The text was updated successfully, but these errors were encountered: