Skip to content

Commit

Permalink
This code tried to access a variable I'd removed in a previous patch.…
Browse files Browse the repository at this point in the history
… You'll never guess what happened next.
  • Loading branch information
kfsone committed Jul 18, 2014
1 parent 4efeee7 commit d3ea873
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,14 @@ def parse_command_line():
def try_combinations(startCapacity, startCr, tradeList):
firstTrade = tradeList[0]
if maxUnits >= startCapacity and firstTrade.costCr * startCapacity <= startCr:
if not avoidItems or not firstTrade.item in avoidItems:
return [ [ [ firstTrade, startCapacity ] ], firstTrade.gainCr * startCapacity ]
return [ [ [ firstTrade, startCapacity ] ], firstTrade.gainCr * startCapacity ]
best, bestGainCr, bestCap = [], 0, startCapacity
tradeItems = len(tradeList)
for handicap in range(startCapacity):
for combo in itertools.combinations(tradeList, min(startCapacity, tradeItems)):
cargo, credits, capacity, gainCr = [], startCr, startCapacity, 0
myHandicap = handicap
for trade in combo:
if trade.item in avoidItems:
continue
itemCostCr = trade.costCr
maximum = min(min(capacity, maxUnits), credits // itemCostCr)
if maximum > 0:
Expand Down

0 comments on commit d3ea873

Please sign in to comment.