Skip to content

Commit f8812b7

Browse files
vaisestLocalIdentity
authored andcommitted
trader tool: use result - klog10(price) estimation for value sorting
1 parent cc7e43b commit f8812b7

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/Classes/TradeQuery.lua

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ on trade site to work on other leagues and realms)]]
358358
[[Weighted Sum searches will always sort using descending weighted sum
359359
Additional post filtering options can be done these include:
360360
Highest Stat Value - Sort from highest to lowest Stat Value change of equipping item
361-
Highest Stat Value / Price - Sorts from highest to lowest Stat Value per currency
361+
Highest Stat Value / Price - Sorts from highest to lowest by estimated Stat Value per currency
362362
Lowest Price - Sorts from lowest to highest price of retrieved items
363363
Highest Weight - Displays the order retrieved from trade]]
364364
-- avoid calling selfunc to avoid updating controls before they are
@@ -858,6 +858,7 @@ function TradeQueryClass:SortFetchResults(row_idx, mode)
858858
return newTbl
859859
elseif mode == self.sortModes.StatValue then
860860
for result_index = 1, #self.resultTbl[row_idx] do
861+
ConPrintf("%.3f", getResultWeight(result_index))
861862
t_insert(newTbl, { outputAttr = getResultWeight(result_index), index = result_index })
862863
end
863864
table.sort(newTbl, function(a,b) return a.outputAttr > b.outputAttr end)
@@ -867,7 +868,20 @@ function TradeQueryClass:SortFetchResults(row_idx, mode)
867868
return nil, "MissingConversionRates"
868869
end
869870
for result_index = 1, #self.resultTbl[row_idx] do
870-
t_insert(newTbl, { outputAttr = getResultWeight(result_index) / priceTable[result_index], index = result_index })
871+
-- generally, because we are filtering our results to only the top
872+
-- contenders, we will end up with a small spread of result weights.
873+
-- this is however not true for prices as *decent* items might start
874+
-- at a couple of div while perfect items are worth hundreds of
875+
-- divs. I think the best option here is weight - k * log10(price)
876+
-- to prioritise good items while only slightly punishing high
877+
-- prices. another option would be weight / log10(price), but it
878+
-- still seems to overrate very cheap items that are bad
879+
880+
-- scaling factor for price
881+
local k = 0.03
882+
t_insert(newTbl,
883+
{ outputAttr = getResultWeight(result_index) - k * math.log(priceTable[result_index], 10), index =
884+
result_index })
871885
end
872886
table.sort(newTbl, function(a,b) return a.outputAttr > b.outputAttr end)
873887
elseif mode == self.sortModes.Price then

0 commit comments

Comments
 (0)