Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Multiplayer Treasure Grove Error All experts on deck for this one!:-)


#1

Hi everyone,
I’ve recently found that a lot of my Multiplayer Treasure Grove matches end in ties. At first I thought it was my code, but closer inspection revealed that in every case it was just their hero with an error, and my hero not doing anything:

Another strange thing is that I only get the ties when fighting against red players, and the enemy hero always seems to be Tharin or Anya.

Here is my code in case there is a bug in it, in which case apologies for the disturbance:


def findBestItem(items):
    bestItem = None
    bestValue = 0
    itemsIndex = 0
    while itemsIndex < len(items):
        item = items[itemsIndex]
        if item.value / hero.distanceTo(item) > bestValue:
            bestItem = item
            bestValue = item.value / hero.distanceTo(item)
        itemsIndex += 1
    return bestItem
def summonArmy(target):
    if hero.canCast("summon-burl", target):
        hero.cast("summon-burl")
    if hero.canCast("summon-undead", target):
        hero.cast("summon-undead")
def findBestCorpse(corpses):
    bestCorpse = None
    bestValue = 0
    corpsesIndex = 0
  
    while corpsesIndex < len(corpses):
        corpse = corpses[corpsesIndex]
        corpseValue = corpse.maxHealth / hero.distanceTo(corpse)
        if corpseValue > bestValue:
            bestCorpse = corpse
            bestValue = corpseValue
        corpsesIndex += 1
    return bestCorpse
def findLunch():
    enemies = hero.findEnemies()
    enemyIndex = 0
    lunch = None
    closestLunch = 9999
    while enemyIndex < len(enemies):
        potentialLunch = enemies[enemyIndex]
        if potentialLunch:
            distance = hero.distanceTo(potentialLunch)
        if potentialLunch.health <= 200 and distance < closestLunch:
            lunch = potentialLunch
            closestLunch = distance
        enemyIndex += 1
    return lunch


def findEnemyHero():
    enemies = hero.findEnemies()
    enemyIndex = 0
    enemyHero = None 
    maxHealth = 0
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
        if enemy.type == "Sorceror":
            enemyHero = enemy
        elif enemy.maxHealth > maxHealth:
            enemyHero = enemy
            maxHealth = enemy.maxHealth
        enemyIndex += 1
    return enemyHero

def spellBook(spell, target, distance):
    if target:
        e_distance = hero.distanceTo(target)
        if e_distance <= distance:
            if hero.canCast(spell, target):
                hero.cast(spell, target)
def castSpells(target):
    spellBook("fear", target, 25)
    spellBook("poison-cloud", target, 30)
def raiseDead(c):
    if c and hero.canCast("raise-dead"):
        hero.moveXY(c.pos.x, c.pos.y)
        pass
        if c:
            hero.cast("raise-dead") 
def eatLunch(lunch):
    if lunch and hero.isReady("devour"):
        hero.move(lunch.pos)
        hero.devour(lunch)
    elif lunch:
        hero.cast("drain-life", lunch)

#hero.moveXY(hero.pos.x + 5, hero.pos.y)
while True:
    lunch = findLunch()
    enemies = hero.findEnemies()
    friends = hero.findFriends()
    enemyHero = findEnemyHero()
    summonArmy(enemyHero)
    enemy = hero.findNearestEnemy()
    items = hero.findItems()
    item = findBestItem(items)
    corpses = hero.findCorpses()
    c = findBestCorpse(corpses)
    castSpells(enemyHero)
    raiseDead(c)
    eatLunch(lunch)
    if item:
        itemB = None
        items = hero.findItems()
        itemB = findBestItem(items)
        if itemB:
            hero.move(itemB.pos)
    enemy = hero.findNearestEnemy()

Note: I had to remove the Blue fox change shape function, as that word was not allowed by the codecombat word filter thing.
Thanks in advance,
Brenin Llwyd.


#2
# you have
def summonArmy(target):
    if hero.canCast("summon-burl", target):
        hero.cast("summon-burl")
    if hero.canCast("summon-undead", target):
        hero.cast("summon-undead")
# and you are calling the function with
summonArmy(enemyHero)

But what happens if the enemy Hero is invisible or their hero is not “operational”?
==> if hero.canCast(“summon-burl”, target) will fail I think
so a simple

if target:
    # your code here
# or
     if hero.canCast("summon-burl"):
     # or if hero.isReady("summon-burl"): will give same result as above 

side note: I gave up fighting in Multiplayer levels, because I’m using only the free heroes despite being a subscriber. It seems to me that the advantage given to the richer users as payed heroes is too big and this is depressing for children of poorer parents.


#3

I used my non sub account (ArcaneBlade) and am number 9 in cavern survival, so even if you dont have payed heroes you still can win


#4

Yes, I know it’s possible to be between 10th and 20th place in some multiplayer levels and I have been there for a while. But it’s true that ordinary heroes have no power even with good code to give much resistance to wizards.
About the BreninLlwyd’s problem: I didn’t test my supposition…


#5

Hi xython,
thanks for the reply. I tried your suggestion, but unfortunately it had no effect. I’m fairly sure that my code doesn’t have any mechanical errors in it, and this seems to be backed up by the fact that the codecombat error checker doesn’t flag any issues with it either.
I think that the problem lies within the multiplayer system itself, as my brother has exactly the same problem.
On a different note, I do agree with you that the payed heroes, especially Ritic, have a big advantage in their basic stats and abilities over the free heroes. However, these barriers can be overcome with imaginative tactics and clever code, It just depends on your mindset. And finally, Codecombat would not be able to provide this incredible, free, jumping off point into the world of computer programming without subscribers like yourself, so while subscribers may seem to have an unfair advantage, they are also providing non-subscribers with a great, free resource.


#6

Playing against Ania, Tharin, Ida, Alejandro with someone from the same ‘free’ pool results in a mutual error, and the heroes are not doing anything.
So it’s a real BUG!


#7

Someone should post this on CoCo github.


#8

Hello. Just to say I’ve run into this since recently restarting with CodeCombat. I see exactly the same symptoms (in Cavern Survival in case it matters), meaning my hero just stops doing anything after the first move if the enemy hero crashes. Extremely irritating! (This with a program that worked fine submitted 2 years ago and not modified etc.)

I’ve noticed the following error in the browser dev console (might be unrelated):

(My hero is in JS so I assume this is indicative of the error in the enemy hero.)

(Edit: Actually that may well be unrelated, I’ve now had the same behaviour against a JS opponent. The console in this case was clean but the problem still present.)

(Edit: The issue is on github I see: https://github.com/codecombat/codecombat/issues/5120)