Skip to content

Commit

Permalink
Added --pad support to getRoute
Browse files Browse the repository at this point in the history
This allows "nav --pad" to require a route with refuelling stops of a given pad size.
  • Loading branch information
kfsone committed Apr 30, 2015
1 parent 0dc6c96 commit b11e3c8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.19.0 Apr 28 2015
v6.19.0 May 01 2015
CACHE BUILD REQUIRED (trade.py buildcache -fi)
. (kfsone) "import" command (non-plugin behavior)
- Restored the default behavior of forcefully overwriting existing data
Expand All @@ -19,11 +19,15 @@ CACHE BUILD REQUIRED (trade.py buildcache -fi)
- Changed several command options from "--stock" to "--supply",
. (kfsone) "market" command:
- Only show the age of items once,
. (kfsone) "nav" command:
- Fixed --refuel-jumps
- Added --pad-size to limit which stations will be listed/refuelled at,
. (kfsone) Performance:
- Re-unified the StationBuying/StationSelling tables into StationItem,
- Added StationBuying and StationSelling views,
- Minor refactor of getTrades to reduce the pathalogical near O(n^2)
behavior it used to match buyers to sellers,
- Improved performance of nav command slightly,


v6.18.6 Apr 27 2015
Expand Down
9 changes: 9 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,15 @@ NAV sub-command:
jump on the route have a station. "--ref 2" would require that
you not make more than one stationless jump after another.

--pad-size ?SML
-p ?SML
Specify pad size required for a station to be listed or considered
for refuelling stops. Specify one or all pad sizes you are want,
DEFAULT: ?SML
e.g.
--pad-size=ML
-p ?SL (unknown, small or large)

from
Name of the starting system or a station in the system,

Expand Down
23 changes: 18 additions & 5 deletions tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,8 @@ def getRoute(self, origin, dest, maxJumpLy, avoiding=[], stationInterval=0):
List of systems being avoided
stationInterval:
If non-zero, require a station at least this many jumps,
tdenv.padSize:
Controls the pad size of stations for refuelling
Returns:
None
Expand Down Expand Up @@ -1025,6 +1027,15 @@ def getRoute(self, origin, dest, maxJumpLy, avoiding=[], stationInterval=0):
destID = dest.ID
sysByID = self.systemByID

maxPadSize = self.tdenv.padSize
if not maxPadSize:
checkStations = lambda system: bool(system.stations())
else:
checkStations = lambda system: any(
stn for stn in system.stations
if stn.checkPadSize(maxPadSize)
)

while openSet:
weight, curDist, curSysID, stnDist = heappop(openSet)
# If we reached 'goal' we've found the shortest path.
Expand All @@ -1039,17 +1050,19 @@ def getRoute(self, origin, dest, maxJumpLy, avoiding=[], stationInterval=0):
if curDist > distances[curSys][1]:
continue

system_iter = iter(systemsInRange(curSys, maxJumpLy))
if stationInterval:
if curSys.stations:
if checkStations(curSys):
stnDist = 0
else:
stnDist += 1
if stnDist >= stationInterval:
system_iter = iter(
v for v in system_iter if checkStations(v[0])
)

distFn = curSys.distanceTo
for nSys, nDist in systemsInRange(curSys, maxJumpLy):
if stationInterval and stnDist >= stationInterval:
if not nSys.stations:
continue
for nSys, nDist in system_iter:
newDist = curDist + nDist
if getDist(nSys, defaultDist)[1] <= newDist:
continue
Expand Down

0 comments on commit b11e3c8

Please sign in to comment.