Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions conf/mod_ahbot.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@
# Set to 1 to restore that behaviour.
# Default 5
#
# AuctionHouseBot.BinItemShare
# Percentage of each cycle's candidate list reserved for items that have no
# row in "mod_auctionhousebot_priceOverride". The seller only ever works
# through the first AuctionHouseBot.ItemsPerCycle entries of that list, and
# the price override items alone number in the thousands, so without a
# reserved share those items are never reached and never listed.
# Set to 0 to append them after the price override items instead (they will
# then effectively never be listed).
# Default 25
#
# AuctionHouseBot.DivisibleStacks
# Sell items in stack sizes which depends on the maximum amount per stack.
# For example, an item with max stack size 20 will be sold in 5, 10 15 and 20 stacks, and not at random.
Expand Down Expand Up @@ -131,6 +141,7 @@ AuctionHouseBot.ItemsPerCycle = 200
AuctionHouseBot.ConsiderOnlyBotAuctions = 0
AuctionHouseBot.DuplicatesCount = 0
AuctionHouseBot.RestockBatchSize = 5
AuctionHouseBot.BinItemShare = 25
AuctionHouseBot.DivisibleStacks = 0
AuctionHouseBot.ElapsingTimeClass = 1
AuctionHouseBot.MaxItems = 15000
Expand Down
44 changes: 41 additions & 3 deletions src/AuctionHouseBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,18 @@ std::vector<uint32> AuctionHouseBot::GetItemsToSell(AHBConfig* config, ObjectGui

// Queue every stack an item is short of, keeping the copies adjacent so a
// sold out item is restocked as a batch instead of one stack per cycle.
// Blocks 1 and 2 (price override items) and blocks 3 and 4 (bin items) are
// collected separately so they can be woven together at the end. Concatenating
// them starved the bin items: a cycle only ever consumes the first
// ItemsPerCycle entries, and the override blocks alone are thousands long.
std::vector<uint32> priorityItems;
std::vector<uint32> binOnlyItems;

auto appendMissingStacks = [&](const std::vector<uint32>& items)
{
for (auto const& itemID : items)
{
allItemIDs.insert(allItemIDs.end(), missingStacks(itemID), itemID);
priorityItems.insert(priorityItems.end(), missingStacks(itemID), itemID);
}
};

Expand Down Expand Up @@ -1362,7 +1369,7 @@ std::vector<uint32> AuctionHouseBot::GetItemsToSell(AHBConfig* config, ObjectGui
itemsWithOverrides.push_back(itemID);
}
std::shuffle(itemsWithOverrides.begin(), itemsWithOverrides.end(), std::mt19937(std::random_device()()));
allItemIDs.insert(allItemIDs.end(), itemsWithOverrides.begin(), itemsWithOverrides.end());
priorityItems.insert(priorityItems.end(), itemsWithOverrides.begin(), itemsWithOverrides.end());

// 3. Items without overrides that are not in the auction house (randomized order)
addItems(greyItemsBin, true);
Expand All @@ -1375,7 +1382,7 @@ std::vector<uint32> AuctionHouseBot::GetItemsToSell(AHBConfig* config, ObjectGui

// Randomize the collected items
std::shuffle(tempItemIDs.begin(), tempItemIDs.end(), std::mt19937(std::random_device()()));
allItemIDs.insert(allItemIDs.end(), tempItemIDs.begin(), tempItemIDs.end());
binOnlyItems.insert(binOnlyItems.end(), tempItemIDs.begin(), tempItemIDs.end());

// 4. Random items without price overrides (randomized order)
tempItemIDs.clear();
Expand All @@ -1393,9 +1400,40 @@ std::vector<uint32> AuctionHouseBot::GetItemsToSell(AHBConfig* config, ObjectGui
allItemIDs.insert(allItemIDs.end(), tempItemIDs.begin(), tempItemIDs.end());
*/

// Weave the two sources together so that, over any stretch of the list,
// BinItemShare percent of the slots belong to items that have no price
// override. At 0 the bin items simply follow the priority ones, which is the
// old concatenation order.
uint32 share = std::min<uint32>(config->BinItemShare, 100);
size_t nextPriority = 0;
size_t nextBin = 0;
uint32 credit = 0;

allItemIDs.reserve(priorityItems.size() + binOnlyItems.size());

while (nextPriority < priorityItems.size() || nextBin < binOnlyItems.size())
{
credit += share;

if (credit >= 100 && nextBin < binOnlyItems.size())
{
credit -= 100;
allItemIDs.push_back(binOnlyItems[nextBin++]);
}
else if (nextPriority < priorityItems.size())
{
allItemIDs.push_back(priorityItems[nextPriority++]);
}
else if (nextBin < binOnlyItems.size())
{
allItemIDs.push_back(binOnlyItems[nextBin++]);
}
}

// Log the number of items to sell
if(config->TraceSeller)
{
LOG_INFO("module", "AHBot [{}]: {} price override and {} bin only candidates woven at {}%", _id, priorityItems.size(), binOnlyItems.size(), share);
LOG_INFO("module", "AHBot [{}]: restocking {} sold out and {} understocked price override items", _id, itemsWithOverridesNotListed.size(), itemsWithOverridesBelowTarget.size());
LOG_INFO("module", "AHBot [{}]: GetItemsToSell returning {} items", _id, allItemIDs.size());
}
Expand Down
3 changes: 3 additions & 0 deletions src/AuctionHouseBotConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ AHBConfig::AHBConfig(uint32 ahid, AHBConfig* conf)
Bind_Quest_Item = conf->Bind_Quest_Item;
DuplicatesCount = conf->DuplicatesCount;
RestockBatchSize = conf->RestockBatchSize;
BinItemShare = conf->BinItemShare;
ElapsingTimeClass = conf->ElapsingTimeClass;
DivisibleStacks = conf->DivisibleStacks;
DisablePermEnchant = conf->DisablePermEnchant;
Expand Down Expand Up @@ -532,6 +533,7 @@ void AHBConfig::Reset()
Bind_Quest_Item = false;
DuplicatesCount = 0;
RestockBatchSize = 5;
BinItemShare = 25;
ElapsingTimeClass = 1;
DivisibleStacks = false;

Expand Down Expand Up @@ -2049,6 +2051,7 @@ void AHBConfig::InitializeFromFile()
MarketResetThreshold = sConfigMgr->GetOption<uint32>("AuctionHouseBot.MarketResetThreshold" , 25);
DuplicatesCount = sConfigMgr->GetOption<uint32>("AuctionHouseBot.DuplicatesCount" , 0);
RestockBatchSize = sConfigMgr->GetOption<uint32>("AuctionHouseBot.RestockBatchSize" , 5);
BinItemShare = sConfigMgr->GetOption<uint32>("AuctionHouseBot.BinItemShare" , 25);
DivisibleStacks = sConfigMgr->GetOption<bool> ("AuctionHouseBot.DivisibleStacks" , false);
ElapsingTimeClass = sConfigMgr->GetOption<uint32>("AuctionHouseBot.ElapsingTimeClass" , 1);
ConsiderOnlyBotAuctions = sConfigMgr->GetOption<bool> ("AuctionHouseBot.ConsiderOnlyBotAuctions", false);
Expand Down
1 change: 1 addition & 0 deletions src/AuctionHouseBotConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class AHBConfig

uint32 DuplicatesCount;
uint32 RestockBatchSize;
uint32 BinItemShare;
uint32 ElapsingTimeClass;

bool DivisibleStacks;
Expand Down
Loading