The total mass of all the enemies in the lane.
Thanks!!! It worked!
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)
There are some bugs in the the documentation.
If you look at the screenshot from the editor, the mass should be 60
The mass property should be fixed, orb’s proper mass is 80
, thanks for the report!
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?
The latter, the mass of the orb should’ve always been 80
Hello,I am the newbie of of the AILeague,I don’t know when the codequest of April start,can anyone tell me?Thanks.
Does anyone know how I can change my age in codecombat? Thanks!!
I think @NalfarCryptor knows, ask him.
I think is here? CodeCombat - Coding games to learn Python and JavaScript year
Revise birth year,if you didn’t see it change in the arena,you can send the code one more time
ok, do you mean AILeauge or something related to classrooms or neither?
I mean AILeauge,whea will it start?
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
@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()
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!