The Fierce Forces Topic

The total mass of all the enemies in the lane.

1 Like

Thanks!!! It worked! :grin: :grin: :grin:

2 Likes

Lol look at this:

3 Likes

Question On Orb’s Mass

Shouldn’t this be 80 based on documentation?
When I run mass property against an Orb, it’s returning a value of 60 (which is Phoenix)

Documentation

print(unit.mass result)

image

1 Like

There are some bugs in the the documentation.
image
If you look at the screenshot from the editor, the mass should be 60

2 Likes

The mass property should be fixed, orb’s proper mass is 80, thanks for the report!

3 Likes

Thanks @Venneth glad to help.

May I ask if you updated the actual mass of the orbs or just modified the returned value from the property call?

1 Like

The latter, the mass of the orb should’ve always been 80

3 Likes

Hello,I am the newbie of of the AILeague,I don’t know when the codequest of April start,can anyone tell me?Thanks.

1 Like

Does anyone know how I can change my age in codecombat? Thanks!!

1 Like

I think @NalfarCryptor knows, ask him.

1 Like

I think is here? CodeCombat - Coding games to learn Python and JavaScript year

1 Like

Revise birth year,if you didn’t see it change in the arena,you can send the code one more time

1 Like

ok, do you mean AILeauge or something related to classrooms or neither?

1 Like

I mean AILeauge,whea will it start?

1 Like

Check this topic

Now that they have launched Anti-Gravity, Vennith has archived the Beta Test and started a New Topic for it. "Anti Gravity" discussions, tips & tricks, chatter

2 Likes

@iggymaster99, I need help with my code. NO ONE COPY IT!!

def enemyLaneOrNot():
    # Define the lanes
    lanes = [1, 0, 2]
    
    # Define the mass and capabilities of different units
    unit_capabilities = {
        "phoenix": {"mass": 60, "speed": 10, "health": 15},
        "elemental": {"mass": 70, "speed": 4, "health": 25},
        "orb": {"mass": 80, "speed": 15, "health": 5},
        "snail": {"mass": 200, "speed": 1, "health": 50},
    }
    
    # Loop through the lanes
    for lane in lanes:
        enemyMaxMass = 0
        friendMaxMass = 0
        # Search the lane for enemies
        enemies = hero.findEnemyUnits(lane)
        friends = hero.findMyUnits(lane)
        # If there are enemies in the lane
        if enemies:
            # Calculate the total mass of the enemy forces
            for enemy in enemies:
                enemyMaxMass += enemy.mass
            if friends:
                friend = hero.findNearest(friends)
                if friend:
                    friendMaxMass += friend.mass
                enemy = hero.findNearest(hero.findEnemyUnits(lane))
                # Summon units until your forces are stronger
                if enemy:
                    if enemyMaxMass > friendMaxMass:
                        # Determine the best unit to summon based on the enemy's mass
                        for unit, capabilities in unit_capabilities.items():
                            if capabilities["mass"] >= enemy.mass and capabilities["speed"] >= enemy.strength and capabilities["health"] >= enemy.strength:
                                hero.summon(unit, enemy.lane)
                else:
                    # If there are no enemies, summon a default unit
                    hero.summon("snail", lane)    
                    hero.summon("orb", lane)
                    hero.summon("orb", lane)


while True:
    hero.summon("phoenix", 0)    
    hero.summon("phoenix", 0)    
    hero.summon("elemental", 0)
    hero.summon("elemental", 0) 
    hero.summon("orb", 0)
    hero.summon("orb", 0)
    enemyLaneOrNot()  
1 Like

if there aren’t enemies, the code inside if enemies: don’t run. so, you have to bring the code to out of if-statement.

def enemyLaneOrNot():
    ...
    for lane in lanes:
        ...
        enemies = hero.findEnemyUnits(lane)
        friends = hero.findMyUnits(lane)

        if enemies:
            for enemy in enemies:
                enemyMaxMass += enemy.mass
        if friends:
            friend = hero.findNearest(friends)
            if friend:
                friendMaxMass += friend.mass
        enemy = hero.findNearest(hero.findEnemyUnits(lane))
        if enemy:
            if enemyMaxMass > friendMaxMass:
                ...
            else:
                ...

btw, if enemies: and if friends: are not necessary. and if you want to know to total of friends’ mass, you have to use for-statement.

    for lane in lanes:
        enemyMaxMass = 0
        friendMaxMass = 0

        enemies = hero.findEnemyUnits(lane)
        friends = hero.findMyUnits(lane)
        for enemy in enemies:
            enemyMaxMass += enemy.mass
        for friend in friends:
            friendMaxMass += friend.mass
        
        enemy = hero.findNearest(hero.findEnemyUnits(lane))
        if enemy:
            if enemyMaxMass > friendMaxMass:
                for unit, capabilities in unit_capabilities.items():
                    if capabilities["mass"] >= enemy.mass and capabilities["speed"] >= enemy.strength and capabilities["health"] >= enemy.strength:
                        hero.summon(unit, enemy.lane)
        else:
            hero.summon("snail", lane)    
            hero.summon("orb", lane)
            hero.summon("orb", lane)

I was able to change my age, thanks!