mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
(svn r13942) -Codechange [YAPP]: Add a penalty for double slips to YAPF. (michi_cc)
This commit is contained in:
parent
8c7983727e
commit
ecc509195a
@ -1727,6 +1727,7 @@ const SettingDesc _patch_settings[] = {
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_look_ahead_signal_p2, SLE_INT, 28, SL_MAX_VERSION, 0, 0, 5, -1000000, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_pbs_cross_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_pbs_signal_back_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, 15 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_doubleslip_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_longer_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_longer_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_shorter_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 40 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
|
||||
|
@ -220,6 +220,7 @@ struct YAPFSettings {
|
||||
int32 rail_look_ahead_signal_p2; ///< constant in polynomial penalty function
|
||||
uint32 rail_pbs_cross_penalty; ///< penalty for crossing a reserved tile
|
||||
uint32 rail_pbs_signal_back_penalty; ///< penalty for passing a pbs signal from the backside
|
||||
uint32 rail_doubleslip_penalty; ///< penalty for passing a double slip switch
|
||||
|
||||
uint32 rail_longer_platform_penalty; ///< penalty for longer station platform than train
|
||||
uint32 rail_longer_platform_per_tile_penalty; ///< penalty for longer station platform than train (per tile)
|
||||
|
@ -105,6 +105,16 @@ public:
|
||||
return cost;
|
||||
}
|
||||
|
||||
FORCEINLINE int SwitchCost(TileIndex tile1, TileIndex tile2, DiagDirection exitdir)
|
||||
{
|
||||
if (IsTileType(tile1, MP_RAILWAY) && IsTileType(tile2, MP_RAILWAY)) {
|
||||
bool t1 = KillFirstBit(GetTrackBits(tile1) & DiagdirReachesTracks(ReverseDiagDir(exitdir))) != TRACK_BIT_NONE;
|
||||
bool t2 = KillFirstBit(GetTrackBits(tile2) & DiagdirReachesTracks(exitdir)) != TRACK_BIT_NONE;
|
||||
if (t1 && t2) return Yapf().PfGetSettings().rail_doubleslip_penalty;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Return one tile cost (base cost + level crossing penalty). */
|
||||
FORCEINLINE int OneTileCost(TileIndex& tile, Trackdir trackdir)
|
||||
{
|
||||
@ -305,6 +315,7 @@ public:
|
||||
for (;;) {
|
||||
/* Transition cost (cost of the move from previous tile) */
|
||||
transition_cost = Yapf().CurveCost(prev.td, cur.td);
|
||||
transition_cost += Yapf().SwitchCost(prev.tile, cur.tile, TrackdirToExitdir(prev.td));
|
||||
|
||||
/* First transition cost counts against segment entry cost, other transitions
|
||||
* inside segment will come to segment cost (and will be cached) */
|
||||
|
Loading…
Reference in New Issue
Block a user