Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Dec 24, 2014
2 parents 38ae4be + 20fa573 commit ff88f63
Show file tree
Hide file tree
Showing 17 changed files with 2,268 additions and 1,914 deletions.
15 changes: 14 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.2.5 [wip]
v6.3.1 [wip]
. (kfsone) Added "--ls-penalty" ("--lsp") for biasing "run" calculations
in favor of shorter supercruise times.
+ Stations, data: kfsone

v6.3.0 Dec 23 2014
. (OpenSS) Script for Windows users (see scripts/README.txt)!
. (kfsone) Added support for pad sizes at stations,
. (kfsone) Revamped output from "local", "buy", "sell" and "olddata".
- "--ages" is the default now (so the option is not needed),
- Added pad size display,
- Improved black market display,
- Changed '+' to '/' for consistency on station lines,
. (bgol) Fixed weirdness with rangeCache
. (bgol/kfsone) Fixed jump distances and performance of "nav" command
+ Stations, Data: kfsone

v6.2.4 Dec 21 2014
. (kfsone) Experimental "add-station" command in misc,
Expand Down
57 changes: 34 additions & 23 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ RUN sub-command:
--max-days-old 7 (data less than a week old)
-MD=2 (data less than 2 days old)

--ls-penalty N.NN
--lsp N.NN
DEFAULT: 0.5
Reduces the score of routes by this percentage for every 1000ls
you have to travel to stations, which helps prioritize routes
with a shorter supercruise time.
e.g.
--ls-penalty 2.5
--lsp=0 (disables this feature)

--unique
--uni
Only show routes which do not visit any station twice
Expand Down Expand Up @@ -547,7 +557,7 @@ LOCAL sub-command:
given a ship, it uses the max dry range of the ship. Use --full if you
want to restrict to systems with a full cargo hold.

trade.py local [-q | -v] [--ly N.NN] [--ages] system
trade.py local [-q | -v] [--ly N.NN] system

--ly N.NN
Constrains local systems to a maximum ly distance
Expand All @@ -556,8 +566,8 @@ LOCAL sub-command:
-v
Show stations + their distance from star

--ages
Show stations + the age of their price data
-vv (or -v -v or --detail --detail)
Include count of items at station

system
Name of the system or a station in the system,
Expand All @@ -571,26 +581,27 @@ LOCAL sub-command:
LHS 3333 5.54

> trade.py local mokosh --ly 6 -v
System Dist
+ Station Dist
------------------------------------------------
MOKOSH 0.00
+ Bethe Station 2500.0ls
+ Lubin Orbital
GRANTHAIMI 2.24
+ Parmitano Colony
LHS 3333 5.54

> trade.py local mokosh --ly 6 --ages
System Dist
+ Station Age/days
----------------------------------------------
MOKOSH 0.00
+ Bethe Station 1.75
+ Lubin Orbital 0.60
GRANTHAIMI 2.24
+ Parmitano Colony 5.03
LHS 3333 5.54
System Dist
/ Station Dist Age/days BMkt Pad
------------------------------------------------------------------
MOKOSH 0.00
/ Bethe Station 2500ls 8.27 N M
/ Lubin Orbital ? 0.85 Y L
GRANTHAIMI 2.24
/ Parmitano Colony ? 5.88 ? ?
LHS 3333 5.54

Mokosh/Bethe Station is 2500ls from its star, the data is 8 days old,
there is no black market, and the largest pad size is Medium

Lubin Orbital's distance is not known, the data is less than a day old,
it has a black market, and it has Large pads.

Parmitano Colony distance unknown, data nearly 6 days old, the
black market status is unknown as is the pad size.

Adding detail ('-vv' or '-v -v' or '--detail --detail') would add
a count of the number of items we have prices for at each station.


EXPORT sub-command:
Expand Down
24 changes: 12 additions & 12 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
from commands.exceptions import *
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
from tradedb import TradeDB

import math

######################################################################
Expand Down Expand Up @@ -62,6 +64,9 @@
def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

if cmdenv.ages and not cmdenv.quiet:
print("--ages is now enabled by default.")

item = tdb.lookupItem(cmdenv.item)
cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID)

Expand All @@ -83,20 +88,14 @@ def run(results, cmdenv, tdb):
'ss.station_id',
'ss.price',
'ss.units',
"JULIANDAY('NOW') - JULIANDAY(ss.modified)",
]
bindValues = [ ]

if cmdenv.quantity:
constraints.append("(units = -1 or units >= ?)")
bindValues.append(cmdenv.quantity)

if cmdenv.ages:
columns.append(
"julianday('now') - julianday(ss.modified)"
)
else:
columns.append('0')

nearSystem = cmdenv.nearSystem
if nearSystem:
maxLy = cmdenv.maxLyPer or tdb.maxSystemLinkLy
Expand Down Expand Up @@ -182,15 +181,16 @@ def render(results, cmdenv, tdb):
stnRowFmt.addColumn('Cost', '>', 10, 'n',
key=lambda row: row.price)
stnRowFmt.addColumn('Stock', '>', 10,
key=lambda row: '{:n}'.format(row.stock) if row.stock >= 0 else 'unknown')
key=lambda row: '{:n}'.format(row.stock) if row.stock >= 0 else '?')

if cmdenv.nearSystem:
stnRowFmt.addColumn('Dist', '>', 6, '.2f',
key=lambda row: row.dist)

if cmdenv.ages:
stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
key=lambda row: row.age)
stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
key=lambda row: row.age)
stnRowFmt.addColumn("Pad", '>', '3',
key=lambda row: TradeDB.padSizes[row.station.maxPadSize])

if not cmdenv.quiet:
heading, underline = stnRowFmt.heading()
Expand Down
55 changes: 32 additions & 23 deletions commands/local_cmd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
import math
from tradedb import TradeDB
from tradeexcept import TradeException

import itertools
import math

######################################################################
# Parser config
Expand All @@ -16,7 +18,7 @@
]
switches = [
ParseArgument('--ly',
help='Maximum light years to measure.',
help='Maximum light years from system.',
dest='maxLyPer',
metavar='N.NN',
type=float,
Expand Down Expand Up @@ -62,22 +64,22 @@ def run(results, cmdenv, tdb):
if distSq <= lySq and destSys is not srcSystem:
distances[destSys] = math.sqrt(distSq)

showStations = cmdenv.detail or cmdenv.ages
ages = {}
if cmdenv.ages:
showStations = cmdenv.detail
if showStations:
stationIDs = ",".join([
",".join(str(stn.ID) for stn in sys.stations)
for sys in distances.keys()
if sys.stations
])
stmt = """
SELECT si.station_id,
JULIANDAY('NOW') - JULIANDAY(MAX(si.modified))
JULIANDAY('NOW') - JULIANDAY(MIN(si.modified))
FROM StationItem AS si
WHERE si.station_id IN ({})
GROUP BY 1
""".format(stationIDs)
cmdenv.DEBUG0("Fetching ages: {}", stmt)
ages = {}
for ID, age in tdb.query(stmt):
ages[ID] = age

Expand All @@ -92,11 +94,14 @@ def run(results, cmdenv, tdb):
age = "{:7.2f}".format(ages[station.ID])
except:
age = "-"
if station.lsFromStar:
ls = '{}ls'.format(station.lsFromStar)
else:
ls = '?'
rr = ResultRow(
station=station,
dist=station.lsFromStar,
ls=ls,
age=age,
blackMarket=station.blackMarket,
)
row.stations.append(rr)
results.rows.append(row)
Expand All @@ -118,7 +123,7 @@ def render(results, cmdenv, tdb):
# Compare system names so we can tell
longestNamed = max(results.rows,
key=lambda row: len(row.system.name()))
longestNameLen = len(longestNamed.system.name())
longestNameLen = max(len(longestNamed.system.name()), 16)

sysRowFmt = RowFormat().append(
ColumnFormat("System", '<', longestNameLen,
Expand All @@ -128,26 +133,30 @@ def render(results, cmdenv, tdb):
key=lambda row: row.dist)
)

marketStates = { 'Y': 'Yes', 'N': 'No', '?': 'Unk' }
showStations = cmdenv.detail or cmdenv.ages
showStations = cmdenv.detail
if showStations:
stnRowFmt = RowFormat(prefix=' + ').append(
stnRowFmt = RowFormat(prefix=' / ').append(
ColumnFormat("Station", '<', 32,
key=lambda row: row.station.str())
)
if cmdenv.detail:
stnRowFmt.append(
).append(
ColumnFormat("Dist", '>', '10',
key=lambda row: '{}ls'.format(row.dist) if row.dist else '')
)
stnRowFmt.append(
ColumnFormat("BMkt", '>', '4',
key=lambda row: marketStates[row.blackMarket]
))
if cmdenv.ages:
stnRowFmt.append(
key=lambda row: row.ls)
).append(
ColumnFormat("Age/days", '>', 7,
key=lambda row: row.age)
).append(
ColumnFormat("BMkt", '>', '4',
key=lambda row: \
TradeDB.marketStates[row.station.blackMarket])
).append(
ColumnFormat("Pad", '>', '3',
key=lambda row: \
TradeDB.padSizes[row.station.maxPadSize])
)
if cmdenv.detail > 1:
stnRowFmt.append(
ColumnFormat("Itms", ">", 4,
key=lambda row: row.station.itemCount)
)

cmdenv.DEBUG0(
Expand Down
28 changes: 18 additions & 10 deletions commands/olddata_cmd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
import math
from tradedb import TradeDB
from tradeexcept import TradeException

import itertools
import math

######################################################################
# Parser config
Expand Down Expand Up @@ -156,19 +158,25 @@ def render(results, cmdenv, tdb):
longestNameLen = len(longestNamed.station.name())

rowFmt = RowFormat().append(
ColumnFormat("Station", '<', longestNameLen,
key=lambda row: row.station.name())
).append(
ColumnFormat("Age/days", '>', '8', '.2f',
key=lambda row: row.age)
).append(
ColumnFormat("Ls/Star", '>', '10',
key=lambda row: row.ls)
)
ColumnFormat("Station", '<', longestNameLen,
key=lambda row: row.station.name())
)

if cmdenv.nearSystem:
rowFmt.addColumn('Dist', '>', 6, '.2f',
key=lambda row: math.sqrt(row.dist2))

rowFmt.append(
ColumnFormat("Age/days", '>', '8', '.2f',
key=lambda row: row.age)
).append(
ColumnFormat("Ls/Star", '>', '10',
key=lambda row: row.ls)
).append(
ColumnFormat("Pad", '>', '3',
key=lambda row: \
TradeDB.padSizes[row.station.maxPadSize])
)

if not cmdenv.quiet:
heading, underline = rowFmt.heading()
Expand Down
8 changes: 7 additions & 1 deletion commands/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
type=float,
dest='maxAge',
),
ParseArgument('--ls-penalty', '--lsp',
help="Penalty per 1kls stations are from their stars.",
default=0.5,
type=float,
dest='lsPenalty'
),
ParseArgument('--unique',
help='Only visit each station once.',
action='store_true',
Expand Down Expand Up @@ -507,7 +513,7 @@ def run(results, cmdenv, tdb):

# seed the route table with starting places
routes = [
Route(stations=[src], hops=[], jumps=[], startCr=startCr, gainCr=0)
Route(stations=[src], hops=[], jumps=[], startCr=startCr, gainCr=0, score=0)
for src in cmdenv.origins
if src not in avoidPlaces and src.system not in avoidPlaces
]
Expand Down
Loading

0 comments on commit ff88f63

Please sign in to comment.