adamqqqplay / dota2ai

Ranked Matchmaking AI: An improved Dota2 AI based on Valve's default AI. Has more than 3 million subscribers on Steam.
http://steamcommunity.com/sharedfiles/filedetails/?id=855965029
GNU General Public License v3.0
310 stars 85 forks source link

Power tread switching (7.33) #82

Open Stuball3D opened 1 year ago

Stuball3D commented 1 year ago

While playing a couple games, the Vengeful Spirit bot would continuously cycle through power treads.

I suspect (guess?) the cause is the new Universal attribute type. Within the "ItemUsuage-New.lua" (lines 277-313) behavior for tread switching and switching desire is defined. If treads are not on the primary attribute, a switch is initiated. Since these heroes apparently have no primary attribute, or returns an unrecognized attribute, an infinite loop is initiated.

I don't know too much about how all of this is coded - so I can't suggest a fix at the moment. (Default to strength maybe?) But I imagine 7.33 is going to break a lot of interactions.

local function GetWantedPowerTreadsAttribute()
        if mode == BOT_MODE_RETREAT and npcBot:WasRecentlyDamagedByAnyHero(3) then
            return ATTRIBUTE_STRENGTH
        elseif fun1:IsAttackingEnemies(npcBot) then
            local name = npcBot:GetUnitName()
            name = fun1:GetHeroShortName(name)
            if fun1:Contains({
                "obsidian_destroyer",
                "silencer",
                "huskar",
                "drow_ranger",
            }, name) then
                return npcBot:GetPrimaryAttribute()
            else
                return ATTRIBUTE_AGILITY
            end
        elseif mode == BOT_MODE_LANING then
            return npcBot:GetPrimaryAttribute()
        else
            return npcBot:GetPrimaryAttribute()
        end
    end

    local function UsePowerTreads(treads)
        if math.floor(DotaTime()) / 4 ~= 0 then
            return
        end
        if npcBot:IsInvisible() and npcBot:UsingItemBreaksInvisibility() then
            if npcBot:HasModifier("modifier_item_dustofappearance") then
                M.UseItemNoTarget(npcBot, treads)
                return true
            end
            return
        end
        if GetWantedPowerTreadsAttribute() ~= treads:GetPowerTreadsStat() then
            M.UseItemNoTarget(npcBot, treads)
            return true
        end
adamqqqplay commented 1 year ago

@Stuball3D Thanks for the feedback! I've seen this wrong behavior before, but didn't find the cause. We will fix it in the next version.