hero.summon("big", 0)
hero.play("hot", 0)
hero.play("boost", 0)
hero.play("goliath", 0)
et1 = hero.findTheirPlayers(1)
et0 = hero.findTheirPlayers(0)
et2 = hero.findTheirPlayers(2)
def quicksand():
et1 = hero.findTheirPlayers(1)
et0 = hero.findTheirPlayers(0)
et2 = hero.findTheirPlayers(2)
if hero.isReady("quicksand"):
if len(et1) >= 2:
hero.play("quicksand", 1)
if hero.isReady("press"):
hero.play("press", 2)
elif len(et2) >= 2:
hero.play("quicksand", 2)
if hero.isReady("press"):
hero.play("press", 1)
elif len(et0) >= 2:
hero.play("quicksand", 0)
while True:
quicksand()
if et0:
hero.summon("big", 0)
hero.summon("threat", 0)
hero.summon("driver", 0)
hero.play("hot", 0)
hero.play("boost", 0)
if et1:
hero.summon("big", 1)
hero.summon("threat", 1)
hero.summon("driver", 1)
hero.play("boost", 1)
hero.play("goliath", 1)
if et2:
hero.summon("big", 2)
hero.summon("threat", 2)
hero.summon("big", 2)
hero.play("goliath", 2)
hero.play("boost", 2)
if et0 and hero.isReady("hot") and hero.isReady("boost"):
hero.summon("big", 0)
hero.play("hot", 0)
hero.play("boost", 0)
if et1 and hero.isReady("boost") and hero.isReady("goliath"):
hero.summon("big", 1)
hero.play("boost", 1)
hero.play("goliath", 1)
if et2 and hero.isReady("goliath") and hero.isReady("boost"):
hero.summon("big", 2)
hero.play("boost", 2)
hero.play("goliath", 2)
quicksand()
Hi @Xuan_Nguyen_Nguy_n! Welcome to the Discourse!
This is a fun place to share your ideas, chat with some amazing people, and ask for help on CodeCombat levels. If you haven’t already, take a look at the new users’ guide. We hope you enjoy your time here! ![]()
Could you please format your code correctly to make it easier for us to help you?
Thanks,
Marmite
1 Like
here is my code if you want to look at it only 1 rules
1 do not copy it
my code. do not copy!
# this fuction checks two lanes and sees which one has more enemys and plays quicksand
def findAndKill(target1,target2):
if hero.isReady("quicksand"):
if hero.findTheirPlayers(targerget2) > hero.findTheirPlayers(targerget1):
hero.play("quicksand", target1)
else:
hero.play("quicksand", target2)
pass
# this fuction sends troops to a specifid lane and bufs them up
def attack(target):
hero.summon("big", target)
hero.summon("charger", target)
hero.summon("driver", target)
hero.summon("sniper", target)
hero.summon("threat", target)
if hero.isReady("goliath"):
hero.play("goliath", target)
if hero.isReady("boost"):
hero.play("boost",target )
if hero.isReady("hot"):
hero.play("hot",target )
pass
attack(1)
lastAttacket = 1
# this the main while true loop
while True:
# this section checks how many enemys are in the top and bottom lanes and stores them in a variable
e1 = hero.findTheirPlayers(1)
e2 = hero.findTheirPlayers(2)
# this if statment checks if e1 is less than e2 and runs the code inside
if e1 < e2:
# this variable stores which lane we are targeting
attacking = 1
# this checks if you last atacked the oposing lane and if so then it plays switch it also tells the code wether to run the findAndKill fuction
if lastAttacket == 2 and hero.isReady("switch"):
hero.play("switch")
quicksand = 1
else:
quicksand = 0
#this code checks if it should use the findAndKill fuction
if quicksand == 1:
findAndKill(0,2)
attack(1)
lastAttacket = 1
thing = 2
# this if statment is a mirror of the last code but for the oposing lane
if e2 < e1:
attacking = 2
if lastAttacket == 1 and hero.isReady("switch"):
hero.play("switch")
quicksand = 1
else:
quicksand = 0
if quicksand == 1 and hero.findTheirPlayers(1) > 0:
findAndKill(0,1)
attack(2)
lastAttacket = 2
thing = 1
# this code is used in the event that both have the same amount of enemys
if e2 == e1:
attack(lastAttacket)
1 Like