TimZaman / dotaservice

DotaService is a service to play Dota 2 through gRPC
Other
110 stars 19 forks source link

Using Generic Hero Values #31

Open Nostrademous opened 5 years ago

Nostrademous commented 5 years ago

As we train the AI to do actions we should train on general data values rather than values trained to specific hero names/IDs. What I mean, rather than training an Antimage bot and then separately on say Earthshaker, we should rather train on a hero with certain characteristics like "base move speed", "turn rate", "attack range", etc.

The learned behavior for map navigation say for a hero with same base movement speed and turn rate should be the same irregardless of what hero it actually is.

Similarly, we can do this for units and abilities/items to generalize the learning process.

I have written a python file to auto-generate JSON files for heroes, units, and abilities from the Dota2 provided .txt files. I've pushed the script in the other repo to separate it from the dotaservice.

Link: https://github.com/pydota2/pydota2/blob/master/patching/generate_json_files.py

Here is what the python file pulls from the Dota2 resource files for Antimage:

    "1": {
        "Name": "npc_dota_hero_antimage",
        "Talents": {
            "Talent_1": "special_bonus_strength_10",
            "Talent_2": "special_bonus_attack_speed_20",
            "Talent_3": "special_bonus_unique_antimage_3",
            "Talent_4": "special_bonus_agility_15",
            "Talent_5": "special_bonus_unique_antimage_5",
            "Talent_6": "special_bonus_unique_antimage",
            "Talent_7": "special_bonus_unique_antimage_4",
            "Talent_8": "special_bonus_unique_antimage_2"
        },   
        "ArmorPhysical": -1,
        "AttackRate": 1.4, 
        "AttackRange": 150, 
        "ProjectileSpeed": 0,
        "AttributeBaseStrength": 23,
        "AttributeStrengthGain": 1.3, 
        "AttributeBaseIntelligence": 12,
        "AttributeIntelligenceGain": 1.8, 
        "AttributeBaseAgility": 22,
        "AttributeAgilityGain": 2.8, 
        "MovementSpeed": 310, 
        "MovementTurnRate": 0.5
    }, 

Reason for this design is to allow for much faster/easier response to new Dota2 patches coming down in the future. All you need to do is run the python script and it will auto generate the data which we can use in agent training.

TimZaman commented 5 years ago

Hmmm.. but all this information is already in the worldstate though? Although indeed talents are not. Can you get the levelable abilities?

On Fri, Jan 4, 2019 at 9:41 AM Nostrademous notifications@github.com wrote:

As we train the AI to do actions we should train on general data values rather than values trained to specific hero names/IDs. What I mean, rather than training an Antimage bot and then separately on say Earthshaker, we should rather train on a hero with certain characteristics like "base move speed", "turn rate", "attack range", etc.

The learned behavior for map navigation say for a hero with same base movement speed and turn rate should be the same irregardless of what hero it actually is.

Similarly, we can do this for units and abilities/items to generalize the learning process.

I have written a python file to auto-generate JSON files for heroes, units, and abilities from the Dota2 provided .txt files. I've pushed the script in the other repo to separate it from the dotaservice.

Link: https://github.com/pydota2/pydota2/blob/master/patching/generate_json_files.py

Here is what the python file pulls from the Dota2 resource files for Antimage:

"1": {
    "Name": "npc_dota_hero_antimage",
    "Talents": {
        "Talent_1": "special_bonus_strength_10",
        "Talent_2": "special_bonus_attack_speed_20",
        "Talent_3": "special_bonus_unique_antimage_3",
        "Talent_4": "special_bonus_agility_15",
        "Talent_5": "special_bonus_unique_antimage_5",
        "Talent_6": "special_bonus_unique_antimage",
        "Talent_7": "special_bonus_unique_antimage_4",
        "Talent_8": "special_bonus_unique_antimage_2"
    },
    "ArmorPhysical": -1,
    "AttackRate": 1.4,
    "AttackRange": 150,
    "ProjectileSpeed": 0,
    "AttributeBaseStrength": 23,
    "AttributeStrengthGain": 1.3,
    "AttributeBaseIntelligence": 12,
    "AttributeIntelligenceGain": 1.8,
    "AttributeBaseAgility": 22,
    "AttributeAgilityGain": 2.8,
    "MovementSpeed": 310,
    "MovementTurnRate": 0.5
},

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TimZaman/dotaservice/issues/31, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRFde3hl5ilJEFWF3EKODm_d_l5Vcks5u_5JWgaJpZM4ZqCRP .

TimZaman commented 5 years ago

Also notice btw i have moved my Agent to https://github.com/TimZaman/dotaclient

On Fri, Jan 4, 2019 at 9:46 AM Tim Zaman timbobel@gmail.com wrote:

Hmmm.. but all this information is already in the worldstate though? Although indeed talents are not. Can you get the levelable abilities?

On Fri, Jan 4, 2019 at 9:41 AM Nostrademous notifications@github.com wrote:

As we train the AI to do actions we should train on general data values rather than values trained to specific hero names/IDs. What I mean, rather than training an Antimage bot and then separately on say Earthshaker, we should rather train on a hero with certain characteristics like "base move speed", "turn rate", "attack range", etc.

The learned behavior for map navigation say for a hero with same base movement speed and turn rate should be the same irregardless of what hero it actually is.

Similarly, we can do this for units and abilities/items to generalize the learning process.

I have written a python file to auto-generate JSON files for heroes, units, and abilities from the Dota2 provided .txt files. I've pushed the script in the other repo to separate it from the dotaservice.

Link: https://github.com/pydota2/pydota2/blob/master/patching/generate_json_files.py

Here is what the python file pulls from the Dota2 resource files for Antimage:

"1": {
    "Name": "npc_dota_hero_antimage",
    "Talents": {
        "Talent_1": "special_bonus_strength_10",
        "Talent_2": "special_bonus_attack_speed_20",
        "Talent_3": "special_bonus_unique_antimage_3",
        "Talent_4": "special_bonus_agility_15",
        "Talent_5": "special_bonus_unique_antimage_5",
        "Talent_6": "special_bonus_unique_antimage",
        "Talent_7": "special_bonus_unique_antimage_4",
        "Talent_8": "special_bonus_unique_antimage_2"
    },
    "ArmorPhysical": -1,
    "AttackRate": 1.4,
    "AttackRange": 150,
    "ProjectileSpeed": 0,
    "AttributeBaseStrength": 23,
    "AttributeStrengthGain": 1.3,
    "AttributeBaseIntelligence": 12,
    "AttributeIntelligenceGain": 1.8,
    "AttributeBaseAgility": 22,
    "AttributeAgilityGain": 2.8,
    "MovementSpeed": 310,
    "MovementTurnRate": 0.5
},

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TimZaman/dotaservice/issues/31, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRFde3hl5ilJEFWF3EKODm_d_l5Vcks5u_5JWgaJpZM4ZqCRP .

Nostrademous commented 5 years ago

Hmmm.. but all this information is already in the worldstate though? Not all. Talents are not. Turn Rate is not. Per-Level-Gain for Str/Agi/Int is not.

More important, for abilities, the casting point, casting behavior and targeting values are not in the protobuf. Here is an example of what I dump:

    "5012": {
        "Name": "bane_enfeeble",
        "TargetMask": 2,
        "TargetTeam": 1,
        "Castpoint": [
            0.3   
        ],    
        "Cooldown": [
            12.0, 
            10.0, 
            8.0,  
            6.0   
        ],    
        "Manacost": [
            70.0, 
            90.0, 
            110.0,
            130.0 
        ]     
    },
    "5006": {
        "Name": "antimage_mana_void",
        "Ultimate": 1,
        "AOE": 1,
        "TargetMask": 2,
        "TargetTeam": 1,
        "DamageType": 2,
        "Castpoint": [
            0.3,  
            0.3,  
            0.3,  
            0.3   
        ],    
        "Cooldown": [
            70.0, 
            70.0, 
            70.0  
        ],    
        "Manacost": [
            125.0,
            200.0,
            275.0 
        ]     
    }, 

Although indeed talents are not. Can you get the levelable abilities?

I implemented code for that before based on world state https://github.com/pydota2/pydota2_archive/blob/master/pydota2/lib/world_data.py#L538

Nostrademous commented 5 years ago

To clarify some of the values: TargetMask:

                    if line.find("DOTA_ABILITY_BEHAVIOR_POINT") >= 0:
                        tgt_mask |= 1
                    if line.find("DOTA_ABILITY_BEHAVIOR_UNIT_TARGET") >= 0:
                        tgt_mask |= 2
                    if line.find("DOTA_ABILITY_BEHAVIOR_NO_TARGET") >= 0:
                        tgt_mask |= 4  

TargetTeam:

                    if line.find("DOTA_UNIT_TARGET_TEAM_ENEMY") >= 0:
                        tgt_team = 1 
                    elif line.find("DOTA_UNIT_TARGET_TEAM_FRIENDLY") >= 0:
                        tgt_team = 2 
                    elif line.find("DOTA_UNIT_TARGET_TEAM_BOTH") >= 0:
                        tgt_team = 3 
                    elif line.find("DOTA_UNIT_TARGET_TEAM_CUSTOM") >= 0:
                        tgt_team = 4 

DamageType:

                    if line.find("DAMAGE_TYPE_PURE") >= 0:
                        dmg_type = 3 
                    elif line.find("DAMAGE_TYPE_MAGICAL") >= 0:
                        dmg_type = 2 
                    elif line.find("DAMAGE_TYPE_PHYSICAL") >= 0:
                        dmg_type = 1