I switched you to Python for that level.
Oh thank u so much!!!
It says commandArcher isnāt identified on 2 to bottom line
hereās my code
please help
# Ogres are trying to kill your reindeer!
# Keep your archers back while summoning soldiers to attack.
def pickUpCoin():
# Collect coins.
items = self.findItems()
nearestCoin = self.findNearest(items)
if nearestCoin:
self.move(nearestCoin.pos)
pass
def summonTroops():
# Summon soldiers if you have the gold.
if self.costOf("soldier")<self.gold:
self.summon("soldier")
pass
# This function has an argument named soldier.
# Arguments are like variables.
# The value of an argument is determined when the function is called.
def commandSoldier(soldier):
# Soldiers should attack enemies.
for soldier in self.findFriends():
enemy = soldier.findNearestEnemy()
if enemy:
self.command(soldier, "attack", enemy)
pass
# Write a commandArcher function to tell your archers what to do!
# It should take one argument that will represent the archer passed to the function when it's called.
# Archers should only attack enemies who are closer than 25 meters, otherwise, stay still.
def commandarcher(archer):
enemy = archer.findNearest(archer.findenemies)
if enemy and archer.distanceto(enemy) < 25:
self.command(archer, "attack", enemy)
else:
self.command(archer, "move", archer.pos)
loop:
pickUpCoin()
summonTroops()
friends = self.findFriends()
for friend in friends:
if friend.type == "soldier":
# This friend will be assigned to the variable soldier in commandSoldier
commandSoldier(friend)
elif friend.type == "archer":
#commandArcher(friend)
commandArcher(friend)
pass
First of all before anything @Doom U must format your code according to the FAQ!!
Put 3 backticks before and after the the code, like so:
code
FYI: I forgot to put the backticks at the end because it is not working.
Here is a link to the FAQ if u need it:
how am I supposed to do that please
Keep your archers back while summoning soldiers to attack.
def pickUpCoin():
# Collect coins.
items = self.findItems()
nearestCoin = self.findNearest(items)
if nearestCoin:
self.move(nearestCoin.pos)
pass
def summonTroops():
# Summon soldiers if you have the gold.
if self.costOf("soldier") self.summon("soldier")
pass
This function has an argument named soldier.
Arguments are like variables.
The value of an argument is determined when the function is called.
def commandSoldier(soldier):
# Soldiers should attack enemies.
for soldier in self.findFriends():
enemy = soldier.findNearestEnemy()
if enemy:
self.command(soldier, "attack", enemy)
pass
Write a commandArcher function to tell your archers what to do!
It should take one argument that will represent the archer passed to the function when it's called.
Archers should only attack enemies who are closer than 25 meters, otherwise, stay still.
def commandarcher(archer):
enemy = archer.findNearest(archer.findenemies)
if enemy and archer.distanceto(enemy) < 25:
self.command(archer, "attack", enemy)
else:
self.command(archer, "move", archer.pos)
loop:
pickUpCoin()
summonTroops()
friends = self.findFriends()
for friend in friends:
if friend.type == "soldier":
# This friend will be assigned to the variable soldier in commandSoldier
commandSoldier(friend)
elif friend.type == "archer":
#commandArcher(friend)
commandArcher(friend)
pass
This is the best i can do
Also I will fail if i donāt get this problem solvedā¦When I do levels that if I lose i submit in a dayā¦It says wait a month and Iāve been waiting for 4 months
PLEASE HELP
Note that the levels that you have to wait a day between each submission are not required to progress in the main campaign. In any case, it looks like you are experiencing a quite odd bug, does it really say to wait a month? Can you post a screenshot? Is your computerās system clock adjusted correctly? Perhaps @nick can take a look at your accountās data to check if it hasnāt been corrupted.
As for your code, please try to copy it from the gameās text editor and paste it inside ``` here. The code youāve posted above is missing indentation.
how do I do that?And please notify nick about the bug
THANK YOU
And I already did ```
I meant ```PleaseHelp
NM
I made a mistake
Can You Help?
You mean, the system clock? It depends on your computerās operating system. There is usually a clock in a corner of your screen, you can click in the clock one or two times and it should display a calendar. Check if the calendar is displaying the correct date.
I already @-mentioned him here, so he should be able to see this thread when he has time.
If you say what you need help with, I may be able to help.
With my code and the bug!
And Thereās no clock
For the bug, all I can do is tell you to check your machineās system clock. If it is actually an issue with your account data, you will need one of the core guys to take a look at the CodeCombat database. Nick should be able to do that when he has time if we havenāt solved the issue until then.
As for the code, can you please try posting it again between ```? The one you have posted above is missing indentationāthe spaces in the beginning of the linesāwhich makes it extremely hard to read.
Keep your archers back while summoning soldiers to attack.
def pickUpCoin():
# Collect coins.
items = self.findItems()
nearestCoin = self.findNearest(items)
if nearestCoin:
self.move(nearestCoin.pos)
pass
def summonTroops():
# Summon soldiers if you have the gold.
if self.costOf("soldier") self.summon("soldier")
pass
This function has an argument named soldier.
Arguments are like variables.
The value of an argument is determined when the function is called.
def commandSoldier(soldier):
# Soldiers should attack enemies.
for soldier in self.findFriends():
enemy = soldier.findNearestEnemy()
if enemy:
self.command(soldier, "attack", enemy)
pass
Write a commandArcher function to tell your archers what to do!
It should take one argument that will represent the archer passed to the function when it's called.
Archers should only attack enemies who are closer than 25 meters, otherwise, stay still.
def commandarcher(archer):
enemy = archer.findNearest(archer.findenemies)
if enemy and archer.distanceto(enemy) < 25:
self.command(archer, "attack", enemy)
else:
self.command(archer, "move", archer.pos)
loop:
pickUpCoin()
summonTroops()
friends = self.findFriends()
for friend in friends:
if friend.type == "soldier":
# This friend will be assigned to the variable soldier in commandSoldier
commandSoldier(friend)
elif friend.type == "archer":
#commandArcher(friend)
commandArcher(friend)
pass
I did it but it doesnāt show up