Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Library Tactician Need Help Kithgard Dungeons

#1

def summonSoldier():
if hero.gold > hero.costOf(“soldier”):
hero.summon(“soldier”)

Soldiers spread out in a circle and defend.

def commandSoldier(soldier, soldierIndex, numSoldiers):
angle = Math.PI * 2 * soldierIndex / numSoldiers
defendPos = {“x”: 41, “y”: 40}
defendPos.x += 10 * Math.cos(angle)
defendPos.y += 10 * Math.sin(angle)
if (soldier.health > 60):
hero.command(soldier, “defend”, defendPos)
else:
hero.command(soldier, “defend”, {‘x’: 42, ‘y’: 40})

Find the strongest target (most health)

This function returns something! When you call the function, you will get some value back.

def findStrongestTarget():
strongest = None
strongestHealth = 0
enemyIndex = 0
enemies = hero.findEnemies()
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.health > strongestHealth:
strongest = enemy
strongestHealth = enemy.health
enemy.Index += 1
return strongest

If the strongestTarget has more than 15 health, attack that target. Otherwise, attack the nearest target.

def commandArcher(archer):
nearest = archer.findNearestEnemy()
if archerTarget:
hero.command(archer, “attack”, archerTarget)
elif nearest:
hero.command(archer, “attack”, nearest)

archerTarget = None

while True:
# If archerTarget is defeated or doesn’t exist, find a new one.
if not archerTarget or archerTarget.health <= 0:
# Set archerTarget to be the target that is returned by findStrongestTarget()
archerTarget = findStrongestTarget()
friends = hero.findFriends()
soldiers = hero.findByType(“soldier”)
# Create a variable containing your archers.
archers = hero.findByType(“archer”)
for i, soldier in enumerate(soldiers):
commandSoldier(soldier, i, len(soldiers));
summonSoldier()
# use commandArcher() to command your archers
for i, archer in enumerate(archers):
commandArcher(archer);

Help me

1 Like
#2

Welcome to CodeCombat @Extity! We hope you have a good experience on the Forum!

Please post your code according to our community guidelines.
Basically all you have to do is put these ` three times no spaces before and after your code!
so this:

hero.attack(enemy)

becomes:

hero.attack(enemy)

This is what it would look like

This makes it easier to read your code and helps us best figure out the solution to your problem!

#3

You should crop images. I mean, now I know u have Mr./Ms. Patterson for English teacher and you’re in 8th grade :stuck_out_tongue:

#4

I’m not disagreeing with you, but I think it’s his name: Luke (L) Patterson not his teacher, and he already gives his age. Although personally I think it’s best not to say that either.
Maybe you crop images because you have something to hide…
:lion: :lion: :lion:

1 Like
#5

Bruh what the heck??? You still tryna put me down? Just be quiet!! You acting like a 6 yr old. And I’m in 9TH GRADE thank you! That’s so rude bro. My parents don’t even teach me. I have teachers for my work!! This is why ur not close to a regular rank yet because you get yourself flagged for rude and offensive comments like this.

And don’t disrespect my parents like that. Even if they were teaching me, I would still get a great education. Cropping pictures isn’t even part of education in the first place!

I agree w what Deadpool said. Cropping pictures is when you got something to hide. I don’t.

Like I said, don’t dis my parents and I’m in 9th grade. That emoji you put is clear evidence that you messaged just to spite me. Thats not cool dude

#6

Ok. Let’s get this sorted.

Let’s try not to assume things here. I do agree with the cropping, but assuming the name and role may lead to confusion and people may be hurt.

Luke, let’s quiet down. He may not have realized that his assumption was wrong when he posted it, but that’s no reason to criticize and shout at people. Calling people 6 year olds, this is not a roasting playground. Please don’t try to shout and hurt each other like this and flag it so a moderator can handle this.

#7

@Chaboi_3000 sorry but I gotta reply to this one.

@Luke10 cropping doesn’t mean u have something to hide. It just means you don’t share your personal information with strangers on the internet. For example, would you want others to know how old are you, where you live, what websites you visit, etc.?

I’m giving you positive feedback and you’re just don’t accept the fact that you could possibly be wrong.

“That emoji you put is clear evidence that you messaged just to spite me.” Well that’s one way to look at it, :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

#8

I don’t have anything to hide so no I wouldn’t care.

First: It should be how old you are
Second: That info is already on my profile.

How do you call disrespecting my parents quote: "Positive feedback?

#9

Really? You guys learned nothing of what I said. :man_facepalming:

He only tried to give you some tips about personal security. I agree it was a bit irrelevant to this discussion, but it’s not something to get too heated up against.

He might have assumed that you were a 14 year old 8th grader. You could’ve have said something more passive like this:

@SuperSmacker, I’m in 9th grade currently, not 8th grade.

instead of criticizing people like the following:

How is @SuperSmacker’s post disrespecting your parents? It’s just an assumption that your english teacher’s name is Mr/Ms. Patterson. It might have been a bit hurtful, but the positive feedback isn’t directed towards this:

but directed towards this:

The post above is constructive feedback. (But a bit abrupt). It’s not directed towards your parents at all. Try not to make assumptions.

Are you assuming that flags are preventing him from reaching regular? The truth is, it didn’t. Jeff Atwood(codinghorror) didn’t want the trust level system to be something to put yourself in a higher position than others, but so more active users can contribute more to the safety of the forum. Please don’t use the trust level system to get a higher status and advantage than others. The forum is not some military base, but supposed to be a friendly and open board.

@Luke10, be more open towards people, they might not think or act the same as you. They have different thinking, and they might not understand some things like you do. This is also a great life lesson for the future. Your buddy might not think the same as you, but if you can adapt to that and help them out, you’ll have a strong connection with them, but if you criticize every person you think are “rude”, you will lose the chance of a possibly important connection for your life. Humans are unique, we all think differently, we just have to get used to the differences.

#10

@SuperSmacker, you have the tendency to be abrupt and possibly hurt others. Be sure to look over your post before actually posting it, you might find mistakes and words that might hurt others. Let’s go over one example:

Person A says:

What are you even trying to say? You’re so confusing. Fix it so I know what the heck you’re trying to say.

That’s hurtful, disrespectful, and not constructive. Instead, Person A can change the post to be a more positive, respectful, and constructive post. A few changes can certainly change it. Person A changes it to this:

Hello [User]! Can you please elaborate on the problem you’re experiencing? Maybe a screenshot and a more clear description can certainly help us solve the problem you’re experiencing.

Do you see the difference between the first and the second post? The second one is much more constructive and respectful the first one, which is abrupt and rude. Be sure to read over your post and change it before someone can possibly be hurt.

For your post, here’s how to change it:
Original:

You should crop images. I mean, now I know u have Mr./Ms. Patterson for English teacher and you’re in 8th grade :stuck_out_tongue:

Edited:

@Luke10, I think you should crop images because [reason].

It’s shorter and doesn’t have assumptions(They can hurt feelings). This is an example of a more helpful and relevant post. You still had the details you needed, but the post quality and “helpfulness”, is much better than the original post.

Read my guide I created in meta for hints to be a more collaborative and helpful user in the board.

Please, just take these discussions in PM’s and notify a moderator there in the future. It makes threads clean without confusion.