Dueling Grounds - not a fair fight

After the enemy goes invisible, my hero can’t ever find him/her again. I cut out everything except these lines of code, and nothing happens except he walks towards the enemy. Also, I have not lost but a few matches, but can’t seem to improve my score. I get a lot of Ties that seem linked to the fights not actually happening. Why can’t my hero (ogre side) find the human enemy reliably?

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    else:
        hero.shield()

I don’t see this problem. Naria’s hide will wear off after the invisibility, so heroes should be able to attack.

I get this a lot. It’s caused by you seeing the enemy, deciding to attack, then the enemy goes invisible and you’re still moving towards them. You can try a variety of strategies to prevent this:

#this is one combining wait and checking for invis. Not sure whether this will work in your particular situation
#so try experimenting with wait and checking for effect("hide"). It's worked for me.
if enemy:
     hero.wait(0.01)
     if not enemy.hasEffect("hide"):
         hero.attack(enemy)
     else:
         hero.shield()
else:
    hero.shield()

:lion: :lion: :lion:

1 Like

A solution to this issue could be something like. Adding a check to the attack() component:

checkIfHidden: ->
    if target.alpha=1
        # Do something here to find a new target.

I forgot how they did the “Invisible” part, but I think it was something like target.alpha or something. Anyway, the attack() method should “check” before performing the attacking.

1 Like

Thanks for the tips!! I didn’t realize you could check the enemy for invisibility. I was thinking you could only use .hasEffect(“hide”) when your hero cast the invisibility spell. Looking forward to adding this check in all my fights.

Just know @Deadpool198, I’m gunning for you!! :cowboy_hat_face: So don’t be too eager to give me all of your tricks.

:smile: heh. I’ll let you know when I can find you on the leaderboard. (jokinnggg…)
:lion: :lion: :lion:

I’m 15th in Harrowland without Boss star 4:
23rd in Zero Sum red side. I can’t find you on that one.
60th on Treasure Grove red side

I’m circling back to the other multiplayer levels to upgrade their code now that I understand the combat approach and simulations. I still need to finish Cloudrip Mtn and Kelvintaph Glacier. By that time I hope to have enough gems for Ritic, which I hear you don’t have. Ritic may be your end!!

Why do my Harrowland matches become messed up when I try to challenge someone on the ladder? I will do the AI challange, then try to do another fight with a medium level person, and then my weapons will degrade. I had a samurai sword, and the defensive infantry shield. After the AI match, my weapons changed to the rough edge and the basic round shield. Why does this happen? :thinking:

Did you debug your code?

if enemy: # I always check enemy and enemy.health > 0
     hero.wait(0.01) # how do you to test this line?
     if not enemy.hasEffect("hide"):
         hero.attack(enemy)
     else: # you mean if enemy.hasEffect("hide")?
         hero.shield() 
           # to see if this else is ever reached put
         console.log( 'hide')  # Do you have an output
                               # in the browser console? I'm not sure
else:
    hero.shield()  # why do you shield when there is no enemy?
                   # I think it's better to move to another place or stay still

@brooksy125 you freeze and lose against a simple invisibility cast.
Why do you use flags? They cannot compete with code.

What do you mean @xython? I change my code almost every time I fight. It’s my weapons/items that change.

Do you not see that xython is not responding to you, but to Deadpool198?

Yes, I saw. I apologize. Whoops

@xython I realized that I lose against a simple invisibility cast. That’s why I started this post. My current code does not have flags, not sure why you are seeing them. I don’t see any when I watch one of my matches. It took me a minute to realize you had a screen shot of Treasure Grove and not Dueling Grounds.

Did you try the Deadpool code? If you are using the commented code:
bits
you can freeze yourself without the enemy help:

if ready lightnig -> ligthnig and you kill an enemy minion
if ready throw ->  you try to throw a dead enemy and you freeze

so I think it’s better to use if/elif/elif/else .

I had other checks that were removed when I started focusing on the invisibility problem, but I understand what you mean. I have run into that problem.

I was just a joking.

Do you have Gift of the Trees? If you don’t there’s no point getting Ritic. He’s really good, but I can beat all the best of them (Archion, DaBeast45, Titus the Titan) with Senick, who I think’s the best hero for dueling grounds even though he only cost 2500 or something.
:lion: :lion: :lion:

I have realised this didn’t really work, let me try again:

if enemy:
    hero.wait(0.01)
    if enemy and enemy.health > 0:
        hero.attack(enemy)
# I can't say this will 100% work, and if it doesn't then that's that. In my blue 
# Pender code on Multiplayer treasure grove, Janderfuhren makes me stop doing 
# anything for ages (15 seconds). And then I start again once I can cast the spell
# I originally wanted to cast on the enemy.

:lion: :lion: :lion:

Sorry, didn’t mean to sound so aggressive. Just letting you know that I’m not as far behind as you might think. I definitely have a lot to learn before I can come close to beating your code. I simulated a few matches between us and it was quite entertaining. With your healing ability and the Paladin helping out, I think you still had full health when I was crushed.

I haven’t worked with Rangers yet, but it sounds like I should start particularly for the multiplayer battles. I’m willing to test your theory out about Senick being the best for dueling. :nerd_face:

It’s fine, when I wrote my first post I was like…should I post this?..It’s a bit… hmm… but I did.
I also recommend Silver-fire bomb over boom ball and if you’re using Ritic I think either silver-fire bomb or dragon tooth which is really good because ritic has so many ways of going invisible.
:lion: