I need to know how to use variables with the towers like for example if I put an archer at A I code have a another variable I also need an example of a if>mana=20 code to use with those variables. Basically I need know how to switch to a different tower spot.
Hereās something that you can do.
Idk python exactly, but I think what your asking for is something like something along the lines of:
towerA = hero.build('archer', 'A')
towerB = hero.build('archer', 'B')
if(hero.mana > 20):
if(towerA.level > towerB.level):
hero.build('archer', 'B')
elif(towerB.level > towerA.level):
hero.build('archer', 'A')
from what I understand you are trying to change tower levels or something like that, so hereās and example of balancing the levels of two towers, both archers, labeled towerA and tower B.
Python
towerA = hero.build('archer', 'A')
towerB = hero.build('archer', 'B')
if hero.mana > 20:
if towerA.level > towerB.level:
hero.build('archer', 'B')
elif towerB.level > towerA.level:
hero.build('archer', 'A')
So I would just repeat that with the counters or would I put the counters like in a while true loop then add a if hero. mana code
What i was trying to do was make variables for all the towers so I can make a while true loop of the counter anomalies code so that Only when I had 20 mana it would place a tower and the rest of the time it would be looking for anomalies I just need an example to go off of.
Trying to figure it out myself. The best I can figure is make your search for anomalies go between every step of your program. Maybe turn it into a function to make it easier
This is in JavaScript so you may have to some translating
function bofa(){
tp counter stuff idk
}while(true){
hero.build(āarcherā, āAā);
bofa();
}
Iāve tried that but when I do that when its waiting for enough mana it doesnāt continue the teleport counter code.
You need to have a loop like this before you cast the build, so the code doesnāt freeze:
while hero.mana < 25:
do_anomalies_and_counters()
hero.build('your-building', 'A')
No, you need to do
do_anomalies_and_counters()
if hero.mana >= 25:
hero.build('your-building', 'A')
or
while True:
if hero.mana >= 25:
break
do_anomalies_and_counters()
hero.build('your-building', 'A')
so that there is no infinite loop
It works, because its not a āinfinite loopā, since hero.mana
is constantly increasing.
It doesnāt, donāt ask me why, CodeCombat thinks that pretty much any loop with a condition is an infinite loop
Hi, TheBredMeister. Do you know if Python 3 will be in CodeCombat?
Itās not possible to use other coding languages in the browser, since they all have to be compiled to JavaScript (as far as I know), the best editor I know of is Replitā¦