Not signed in (Sign In)
    • CommentAuthorthebigch
    • CommentTimeFeb 28th 2007
     
    Hi all, I'm working to develop a baserule using the following information:

    If item is Weapon or Armor, is level greater than x, and has bid/buyout for less than y; then buy/buyout + reason

    Here's what I have so far, but it does not appear to be working. I took an example from the wiki page and modified it to what I thought would work.


    local level, class
    if (level > 60 and class =="Armor" or class == "Weapon" and buyPrice < 40000) then
    action="buy"
    reason="testing"
    end

    I'm still new at this, so any criticism or help is appreciated. Thanks
    •  
      CommentAuthordinesh
    • CommentTimeFeb 28th 2007
     
    you need to add some extra parenthesis - as written, lua will evaluate the "ands" first, then the or. you want something like this:

    if (level > 60 and (class =="Armor" or class == "Weapon") and buyPrice < 40000) then
    • CommentAuthorMynthea
    • CommentTimeFeb 28th 2007
     
    And it would be helpful to actually get the level and class information from somewhere. Like:

    local _,_, quality, level, _, class, _,_, equip = GetItemInfo(itemID)

    Right now it seems as though you are comparing two empty variables...
    • CommentAuthorthebigch
    • CommentTimeFeb 28th 2007
     
    Thanks for the help. I should have known better about the parenthesis.
    I've modified it, but am still not getting the expected (or any) results.

    Just as a very basic test, I tried the following:

    local _,_, quality, level, _, class, _,_, equip = GetItemInfo(itemID)
    if (level > 60) then
    then
    action="buy"
    reason="test"
    end

    Is there any sort of debug that would allow me to see what values the variables are holding at a specific time?

    Once again, thanks for the help.
    • CommentAuthorthebigch
    • CommentTimeFeb 28th 2007
     
    I'm making good progess now and getting better results. I believe I am running into a problem where 'level' is actually the itemLevel and not the required level. Is there a way I can differentiate between the two?

    Also, even though I list <40000, it appears =40000 still matches.

    Just FYI, my current baseRule:

    local _,_, quality, level, _, class, _,_, equip = GetItemInfo(itemID)

    if (level < 60) then
    action="ignore"

    elseif (level > 60 and (class =="Weapon" or class == "Armor") and (buyPrice < 40000 or bidPrice < 40000)) then
    action="buy"
    reason="test"
    end


    Thanks again, great program.
    •  
      CommentAuthordinesh
    • CommentTimeFeb 28th 2007
     
    heh, good catch Mynthea.

    thebigch: you can add basic debugging by adding a line such as:

    DEFAULT_CHAT_FRAME:AddMessage("level is: "..tostring(level))

    fair warning, if you do this and don't limit it somehow, you will get a lot of chat frame spam as BTM is evaluating items. I use the "tostring" function experience has taught me that a lot of my code problems are related to variables being set to nil, and if you don't do that you will get a nil concatenation error.
    •  
      CommentAuthordinesh
    • CommentTimeFeb 28th 2007
     
    read http://www.wowwiki.com/API_GetItemInfo

    the "use level" is the field between the item level and the class.
    •  
      CommentAuthordinesh
    • CommentTimeFeb 28th 2007
     
    as for the 40000 issue, it's probably just due to rounding we do in our display of GSC amounts.
    • CommentAuthorthebigch
    • CommentTimeFeb 28th 2007
     
    Thanks for all the help. I've already learned quite a bit.
    • CommentAuthorChardonnay
    • CommentTimeFeb 28th 2007 edited
     
    You should also check whether the item actually has a buyout. If there isn't one then it will be set to zero by btm.

    if (... your other conditions ...) then
    if buyPrice ~= 0 and buyPrice < 40000 then
    action = "buy"
    reason = "testing (buy)"
    elseif bidPrice < 40000 then
    action = "bid"
    reason = "testing (bid)"
    end
    end


    My own baserule is a more complicated version of this and adds a "buy if we'd have bidded and buyout is close enough to bid" condition:

    -- minimum profit for bidding
    local bidMinProfitRel = 0.15
    local bidMinProfitAbs = 5000

    -- minimum profit for buying
    local buyMinProfitRel = 0.30
    local buyMinProfitAbs = 10000

    -- if buyout is close enough to low enough bid, just buy it anyway
    local buyMaxBidNear = 0.025

    basePrice = 0

    -- ...
    -- calculate basePrice; also sets up a base reason such as "Disenchant" that may be appended to below
    -- (if basePrice remains zero after this, then don't buy the item for any reason)
    -- ...

    -- account for AH cut
    local resaleValue = basePrice * 0.95

    if buyPrice ~= 0 and buyPrice <= resaleValue * (1 - buyMinProfitRel) and buyPrice <= resaleValue - buyMinProfitAbs then
    action = "buy"
    reason = reason .. " (buy)"
    elseif bidPrice ~= 0 and bidPrice <= resaleValue * (1 - bidMinProfitRel) and bidPrice <= resaleValue - bidMinProfitAbs then
    if buyPrice ~= 0 and bidPrice >= buyPrice * (1 - buyMaxBidNear) then
    action = "buy"
    reason = reason .. " (buy near bid)"
    else
    action = "bid"
    reason = reason .. " (bid)"
    end
    end
    • CommentAuthorOnyx
    • CommentTimeMar 12th 2007 edited
     
    Hi,

    I'm still trying to get a more in depth understanding of BottomScanner and baserules, so don't shoot me if I go wrong here.

    It seems to me there's really not *that* much to play around with:

    basePrice = 0

    -- ...
    -- calculate basePrice; also sets up a base reason such as "Disenchant" that may be appended to below
    -- (if basePrice remains zero after this, then don't buy the item for any reason)
    -- ...

    -- account for AH cut
    local resaleValue = basePrice * 0.95

    The basePrice you calculate here will always have to be related to some kind of reference price. Be it the constPrice that was used in the past (I really like the Norganna baserule that uses it on the Baserule wiki) or, lacking accurate constPrice data, the auctPrice (and for the adventurers the auctioneer HSP).

    I think auctPrice is a good value to use once your database has a reasonable number of items in it and the prices are more or less stable. It is however just about the only value you can use, and then modify it a bit for AH cut and so to get it as close as possible to a really real value for the item. This 'real' value can then be compared (in a number of ways, the buy-near-bid being clever :)) to the bidPrice/buyPrice to determine whether or not a profit can be made, that makes sense.

    What still escapes me is how to cleverly recalculate that price and how to find the different reasons for buying/bidding based upon different outcomes. I'm a disenchanter so I'd LOVE to get my hands on a 2nd reference price, being the de-value, but I haven't seen any examples on how to do this and I'm curious how people can decide they want to buy an item for disenchant without this information.

    A fixed rule that just buys all green items higher than a certain level and below a certain price will work, but only as long as prices don't shift. Something more dynamic is needed to REALLY make this work. Maybe this is something to wait for with the new Enchantrix.

    Onyx.
    • CommentAuthorChardonnay
    • CommentTimeMar 12th 2007 edited
     
    I posted my disenchant baserule here a while ago:

    http://norganna.org/discuss/discussion/3306/btm-baserules-examples/#Item_7

    Enchantrix is in a state of flux so I calculate disenchant results myself using a set of probability tables.

    For valuation I use a combination of snapshot and historical data from Auctioneer, a table of preset "baseline" prices, and a per-reagent price adjustment.
    • CommentAuthorChardonnay
    • CommentTimeMar 12th 2007 edited
     
    Actually my valuation code has changed a bit since I posted that. Below's my current getReagentValue function. It ignores my baseline prices (because I kept forgetting to update them :) and instead calculates a value based on historical data, adjusting the value downwards if the snapshot shows a downturn in price.

    -- calculate value of a stack of reagents based on
    -- auctioneer data and price tables above
    local getReagentValue = function(itemID, itemCount)
    local base = baselinePrices[itemID]
    local adjust = priceAdjustment[itemID] or 1

    if not base then return nil end

    local median, snapshot, snapshotCount = nil, nil, nil
    local _, link = GetItemInfo(itemID)
    if link then
    local key = Auctioneer.ItemDB.CreateItemKeyFromLink(link)
    if key then
    median = Auctioneer.Statistic.GetItemHistoricalMedianBuyout(key)
    snapshot, snapshotCount = Auctioneer.Statistic.GetItemSnapshotMedianBuyout(key)
    end
    end

    median = median or base
    snapshot = snapshot or base
    snapshotCount = snapshotCount or 1

    local snapshotWeight = 0
    if snapshotCount >= 5 and snapshot < median then
    snapshotWeight = math.log10(snapshotCount) / math.log10(50)
    end
    snapshotWeight = math.min(math.max(snapshotWeight, 0), 1)
    local medianWeight = 1 - snapshotWeight

    local combined = median * medianWeight + snapshot * snapshotWeight
    return combined * adjust * itemCount
    end
    • CommentAuthorOnyx
    • CommentTimeMar 12th 2007
     
    WOW. I'll have to chew on that for a while now :bigsmile:

    Thanks,

    Onyx.
    •  
      CommentAuthorNemelis
    • CommentTimeMar 17th 2007
     
    Ehhh. Chardonay I know I'm repeating myself, but could you post your baserule on the wiki in the baserule-scratch. After reading this I really think having your baserule there could be an inspiration for a lot of stuff that people are (at least at what I'm) thinking on.
    • CommentAuthorJelly
    • CommentTimeMar 29th 2007
     
    I've been trying to work out a similar thing: at the moment I'm only looking for items that will produce BC-type mats when disenchanted. According to WoWWiki items of level 66 or higher de into these therefore, based on the earlier posts in this thread, I've got as far as:

    local _,_, quality, level, _, class, _,_, equip = GetItemInfo(itemID)
    if (level > 66 and class =="Armor" or class == "Weapon") then
    if buyPrice ~= 0 and buyPrice < 100000 then
    action = "buy"
    reason = "de (buy)"
    elseif bidPrice < 100000 then
    action = "bid"
    reason = "de (bid)"
    end
    end

    and it runs (unlike the attempts I had trying to work in ItemMinLevel) but is coming back with results of items less than level 66 (yes, definitely item level and not use/equip/quality or anything else).
    Can anyone spot what's wrong, coz I'm still not very good at this.
    Many Thanks
    • CommentAuthorChardonnay
    • CommentTimeMar 29th 2007
     
    Your bug is here I think:
    if (level > 66 and class =="Armor" or class == "Weapon") then
    "and" has higher precedence (http://en.wikipedia.org/wiki/Order_of_operations, http://www.lua.org/pil/3.5.html) than "or", making that line equivalent to:
    if ((level > 66 and class =="Armor") or class == "Weapon") then
    so you'll get armor with the levels you want, but weapons of any level. You can add another pair of parentheses to force the correct ordering:
    if (level > 66 and (class =="Armor" or class == "Weapon")) then
    • CommentAuthorChardonnay
    • CommentTimeMar 29th 2007 edited
     
    Posted By: NemelisEhhh. Chardonay I know I'm repeating myself, but could you post your baserule on the wiki in the baserule-scratch. After reading this I really think having your baserule there could be an inspiration for a lot of stuff that people are (at least at what I'm) thinking on.


    I pasted in my anti-scammer rule a few days ago; I think the full-blown disenchanting rule is probably a little bulky... :)

    What might be better is a list of Auctioneer functions that are useful in baserules, like the GetItemHistoricalMedianBuyout and GetItemSnapshotMedianBuyout used above.
    • CommentAuthorBonafide
    • CommentTimeMar 31st 2007 edited
     
    I'm am getting a similar problem and I am, too, a very unexperienced coder. Part of my baserule is as follows:

    local _,_, quality, level, _, class, _,_, equip = GetItemInfo(itemID)
    if (quality == 2 and (level > 56 and level < 81) and class == "Armor") then
    if buyPrice ~= 0 and buyPrice < 45000 then
    action = "buy"
    reason = "BO armor"
    elseif bidPrice < 44000 then
    action = "bid"
    reason = "BID armor”
    end
    end

    The problem I am having is that although, in my eyes, I have clearly defined the item-levels (more than level 56 but less then 81) still items of lower levels come up. Anyone have an idea?
    • CommentAuthorMynthea
    • CommentTimeMar 31st 2007
     
    Bonafide, could it be that the lower level items are coming up from the basic routines and not your own baserule?

    Your baserule doesn't cut out the resale basic routine by setting the basePrice to zero. And of course the DE and vendor basic routines can currently only be diverted by setting the profit control variables to very high.

    So if your btm popup gives anything other than those "BO armor" or "BID armor" as reason then they are results from the basic routines. Other than that possibility, I can't find fault in your baserule. Like you say, it should only popup items whose item level is between 56 and 81.

    m.
    •  
      CommentAuthordinesh
    • CommentTimeMar 31st 2007
     
    how much lower? remember, you are looking at item level, not use level.
    • CommentAuthorBonafide
    • CommentTimeApr 1st 2007
     
    @ Dinesh: more than 20 iLevels lower.
    @ Mynthea: that might be the case indeed. Thank you, I will try to raise the DE profit control to an absurd amount of copper ;)
    • CommentAuthorrowaasr13
    • CommentTimeApr 2nd 2007
     
    Bonafide, you can easily confirm that by checking reason for those "extra" items. if it is not "BO armor" or "BID armor" defined in your rule, then you see items picked up by default rules.
    • CommentAuthorBonafide
    • CommentTimeApr 9th 2007
     
    Aye, I found that out too. It seemed I indeed forgot to disable the basic routine ;)
    Thanks again for the help!
World of Warcraft™ and Blizzard Entertainment™ are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries.