TimZaman / dotaservice

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

how to cast skill? #39

Open sijiaxu opened 5 years ago

sijiaxu commented 5 years ago

I look the dotaclient code, it seems right now it can only use three types of actions: move, attack and do nothing. I want to cast the q,w,e,r skills in NeverMore, so is there a way to do that?

TimZaman commented 5 years ago

I dont know! :) I also dont know how i get the info whether or not they can actually skill something..

On Tue, Jan 15, 2019, 00:13 sijia xu <notifications@github.com wrote:

I look the dotaclient code, it seems right now it can only use three types of actions: move, attack and do nothing. I want to cast the q,w,e,r skills in NeverMore, so is there a way to do that?

— 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/39, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRNX2GRaMQ2QWbND_0JLyZ8GVTKy-ks5vDY2kgaJpZM4aAcOZ .

sijiaxu commented 5 years ago

Oh, sad info.. but is there some ways in lua script to cast the skill, the skills of NeverMore is quite simple, no direction needed, just press q,w,e,r button.. for dataservice, can we add some custom action proto definition which refers to the lua script logic.

Nostrademous commented 5 years ago

I will implement this today if I have time in my code branch.

Nostrademous commented 5 years ago

In my code I currently return the following at level 1 with no abilities selected:

npc_dota_hero_nevermore abilities that can be leveled ['nevermore_shadowraze1', 'nevermore_shadowraze2', 'nevermore_shadowraze3', 'nevermore_necromastery', 'nevermore_dark_lord']

That was printed by this: https://github.com/Nostrademous/dotaclient/blob/3201220925d790d9006977c295ff4757d947e3fa/agent.py#L525

I need to next implement the action selection, but this begs a question since certain actions are "atomic" and thus don't prevent other actions from being taken at the same time.

How do we want to model that?

sijiaxu commented 5 years ago

I think it needs hard code some rules, like if I cast q skill of NeverMore, then in the following 1 second cannot execute other actions. but how do you plan to transfer this action info to Lua sides?

another problem, it also needs to check whether the skill is ready to cast right now, like check the mana, cooldown and casting distance. I look at the message Ability, maybe can get something from that.

Nostrademous commented 5 years ago

I think it needs hard code some rules, like if I cast q skill of NeverMore, then in the following 1 second cannot execute other actions. but how do you plan to transfer this action info to Lua sides?

another problem, it also needs to check whether the skill is ready to cast right now, like check the mana, cooldown and casting distance. I look at the message Ability, maybe can get something from that.

That part is easy and learnable with delays as well as hard-coded cast points if we want to be more modeled vs model-free.

Honestly, hard coding "don't do anything for next 1 second" is bad, as there will be times where it is better to cancel a cast then die trying to execute it.

All the info you ask for: 'mana, cd, distance, fully castable' I can get already

TimZaman commented 5 years ago

Dota as a game doesnt support multiple actions per tick though afaik. Leveling would be one action

On Tue, Jan 15, 2019, 18:59 sijia xu <notifications@github.com wrote:

I think it needs hard code some rules, like if I cast q skill of NeverMore, then in the following 1 second cannot execute other actions. but how do you plan to transfer this action info to Lua sides?

another problem, it also needs to check whether the skill is ready to cast right now, like check the mana, cooldown and casting distance. I look at the message Ability, maybe can get something from that.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TimZaman/dotaservice/issues/39#issuecomment-454633708, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRJeEqyEbvRXCUch-L8LD3AOIG6mlks5vDpWQgaJpZM4aAcOZ .

Nostrademous commented 5 years ago

It does via a queue trick I believe... hm... maybe not.

Perhaps we should implement a way for sending a "queue" of "atomic" actions and they get executed 1 per frame ?

Nostrademous commented 5 years ago

All of these can be done while doing other things. I agree, not "at the same time", but sequentially 1 per frame.

int ActionImmediate_PurchaseItem ( sItemName )
Command a bot to purchase the specified item. Item names can be found here.

ActionImmediate_SellItem( hItem )
Command a bot to sell the specified item

ActionImmediate_DisassembleItem( hItem )
Command a bot to disassemble the specified item

ActionImmediate_SetItemCombineLock( hItem, bLocked )
Command a bot to lock or unlock combining of the specified item

ActionImmediate_SwapItems( index1, index2 )
Command a bot to swap the items in index1 and index2 in their inventory. Indices are zero based with 0-5 corresponding to inventory, 6-8 are backpack and 9-15 are stash

ActionImmediate_Courier( hCourier, nAction )
Command the courier specified by hCourier to perform one of the courier Actions.

ActionImmediate_Buyback()
Tell a hero to buy back from death.

ActionImmediate_Glyph()
Tell a hero to use Glyph.

ActionImmediate_LevelAbility ( sAbilityName )
Command a bot to level an ability or a talent. Ability and talent names can be found here

ActionImmediate_Chat( sMessage, bAllChat )
Have a bot say something in team chat, bAllChat true to say to all chat instead

ActionImmediate_Ping( fXCoord, fYCoord, bNormalPing )
Command a bot to ping the specified coordinates with bNormalPing setting the ping type
TimZaman commented 5 years ago

Nostradaemous, do you know if theres a protobuf for leveling and buying items and such? Im pretty sure there must be one

On Tue, Jan 15, 2019, 19:15 Nostrademous <notifications@github.com wrote:

All of these can be done while doing other things. I agree, not "at the same time", but sequentially 1 per frame.

int ActionImmediate_PurchaseItem ( sItemName )

Command a bot to purchase the specified item. Item names can be found here. ActionImmediate_SellItem( hItem )

Command a bot to sell the specified item ActionImmediate_DisassembleItem( hItem )

Command a bot to disassemble the specified item ActionImmediate_SetItemCombineLock( hItem, bLocked )

Command a bot to lock or unlock combining of the specified item ActionImmediate_SwapItems( index1, index2 )

Command a bot to swap the items in index1 and index2 in their inventory. Indices are zero based with 0-5 corresponding to inventory, 6-8 are backpack and 9-15 are stash ActionImmediate_Courier( hCourier, nAction )

Command the courier specified by hCourier to perform one of the courier Actions. ActionImmediate_Buyback()

Tell a hero to buy back from death. ActionImmediate_Glyph()

Tell a hero to use Glyph. ActionImmediate_LevelAbility ( sAbilityName )

Command a bot to level an ability or a talent. Ability and talent names can be found here ActionImmediate_Chat( sMessage, bAllChat )

Have a bot say something in team chat, bAllChat true to say to all chat instead ActionImmediate_Ping( fXCoord, fYCoord, bNormalPing )

Command a bot to ping the specified coordinates with bNormalPing setting the ping type

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TimZaman/dotaservice/issues/39#issuecomment-454636466, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRDG-YxsjZB-QbDSk7ZtdLXttJYxOks5vDplegaJpZM4aAcOZ .

Nostrademous commented 5 years ago

You mean like: https://github.com/Nostrademous/dotaservice/blob/526df38ff4b69c62d61f9e011c470de1adff73f5/dotaservice/protos/dota_gcmessages_common_bot_script.proto#L332

https://github.com/Nostrademous/dotaservice/blob/526df38ff4b69c62d61f9e011c470de1adff73f5/dotaservice/protos/dota_gcmessages_common_bot_script.proto#L349

If not, I'm not sure what you mean....

TimZaman commented 5 years ago

Are those official?

On Tue, Jan 15, 2019, 19:21 Nostrademous <notifications@github.com wrote:

You mean like:

https://github.com/Nostrademous/dotaservice/blob/526df38ff4b69c62d61f9e011c470de1adff73f5/dotaservice/protos/dota_gcmessages_common_bot_script.proto#L332

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TimZaman/dotaservice/issues/39#issuecomment-454637398, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRH3Hm4nmbWRT8G8nKCywihUfhrEFks5vDprDgaJpZM4aAcOZ .

sijiaxu commented 5 years ago

I have a question, after we fill the protobuf message of skills/leveling/buy items, it also need to hard code the corresponding Lua execution code, is that right?

Nostrademous commented 5 years ago

I'm not sure I understand what you are asking or trying to do.

I would think that if our agent decides it wants to level an ability it would just send a message to the Lua side of our bot to do so.

https://github.com/Nostrademous/dotaservice/blob/526df38ff4b69c62d61f9e011c470de1adff73f5/dotaservice/lua/bot_generic.lua#L12

Nostrademous commented 5 years ago

I have a question, after we fill the protobuf message of skills/leveling/buy items, it also need to hard code the corresponding Lua execution code, is that right?

Yes, per my above message. Also, I swear, I think for "atomic" action you can just execute them one after the other in the same frame and the will all get done.

Nostrademous commented 5 years ago

@TimZaman do you mind if we mod the "lua" code to use the old command processor I wrote to work with the file throughput method?

https://github.com/pydota2/pydota2_archive/blob/master/pydota2/bot_code/bots/actions/cmd_processor.lua

We could then easily add all the previous functions I implemented (with some minor tweaks for debug print) https://github.com/pydota2/pydota2_archive/tree/master/pydota2/bot_code/bots/actions

TimZaman commented 5 years ago

What would that look like? The constraints I feel we have are:

WDYT?

On Tue, Jan 15, 2019 at 7:46 PM Nostrademous notifications@github.com wrote:

@TimZaman https://github.com/TimZaman do you mind if we mod the "lua" code to use the old command processor I wrote to work with the file throughput method?

https://github.com/pydota2/pydota2_archive/blob/master/pydota2/bot_code/bots/actions/cmd_processor.lua

We could then easily add all the previous functions I implemented (with some minor tweaks for debug print)

https://github.com/pydota2/pydota2_archive/tree/master/pydota2/bot_code/bots/actions

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TimZaman/dotaservice/issues/39#issuecomment-454641714, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRAv-gFV0WqIYuvzstt4gXvb2e04zks5vDqCmgaJpZM4aAcOZ .

Nostrademous commented 5 years ago

Everything should be conform protobuf: if its not in the proto, we can't do it WDYT?

I would like one exception to be made for a custom protobuf class called "CustomAction" or something. This is to enable people that are writing ML-agents using DotaService to have the flexibility of implementing their own "non-primitive" actions.

What I mean is this: Currently we are supporting actions like DOTA_UNIT_ORDER_MOVE_TO_POSITION and DOTA_UNIT_ORDER_ATTACK_TARGET but what if someone wanted to "script" a whole mode like "lane_farming" which they hard-coded scripted in lua as a function that does appropriate movements, attacks, ability usage, etc. where the ML-agent only controls switching between "modes" rather than making each and every individual primitive action.

TimZaman commented 5 years ago

Hmmmmmmm... Im slightly hesitant. What would that look like?

On Wed, Jan 16, 2019, 09:14 Nostrademous <notifications@github.com wrote:

Everything should be conform protobuf: if its not in the proto, we can't do it WDYT?

I would like one exception to be made for a custom protobuf class called "CustomAction" or something. This is to enable people that are writing ML-agents using DotaService to have the flexibility of implementing their own "non-primitive" actions.

What I mean is this: Currently we are supporting actions like DOTA_UNIT_ORDER_MOVE_TO_POSITION and DOTA_UNIT_ORDER_ATTACK_TARGET but what if someone wanted to "script" a whole mode like "lane_farming" which they hard-coded scripted in lua as a function that does appropriate movements, attacks, ability usage, etc. where the ML-agent only controls switching between "modes" rather than making each and every individual primitive action.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TimZaman/dotaservice/issues/39#issuecomment-454861842, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRMP4qnh1QsOuL1iHfZstnXm_lI_sks5vD13kgaJpZM4aAcOZ .

Nostrademous commented 5 years ago

Haven't given it too much deep thought. On the surface probably simply:

        message CustomAction {
                        repeated int32 units = 1;
            required string action_name = 2;
        }

Then in the action processor the person could add a stub for "elseif action == 'DOTA_UNIT_ORDER_CUSTOM'" and map the action_name to the predefined lua behavior for supplied units.