Help with Computer Science 3

I need help with level 38 Sarven Road here is my code.

while True:
# If there’s an enemy, attack.
xPos = hero.pos.x
yPos = hero.pos.y
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
hero.attack(enemy)
hero.attack(enemy)
# Else, keep moving up and to the right.
else:
hero.pos.x + 3
hero.pos.y + 3

pass

Can you post the link?

Sure

Hello are you there.

Instead of

hero.pos.x + 3
hero.pos.y + 3

try:

hero.moveXY(hero.pos.x + 3,hero.pos.y + 3)

Yes it worked. Thank you very much. And keep up the good work.

No problem :smiley: :smiley:

I need help again it’s with a different level if you don’t mind.

ok

Ok here’s my code and the link. The name of the level is

Interception

while True:
enemy = hero.findNearestEnemy()
friend = hero.findNearest(hero.findFriends())
# Find the point between the enemy’s position and your friend’s position.
# Check the guide if you need more help!
x = (enemy.pos.x + friend.pos.x) / 2
y = (enemy.pos.y + friend.pos.y) / 2
hero.move({‘x’: x, ‘y’: y})

It says there is a error on the Second line of code I think

Sorry I can’t help on that one i’m not a subscriber but i think i know someone that is

You have to be a sub for that level?

I’m not a subscriber and it lets me play it.

Are you part of a class?

I’m not trying to accuse or anything but did you try reloading the page.
The same thing happened to me yesterday and I reloaded the page and it worked.

Yes

Instead of hero.move({"x": x, "y": y}) use hero.moveXY(x, y)

@Gerren_Polk

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!
When asking for help on one level then need help with another level please make another topic for the level ok? you didn't do anything wrong but it keeps the forum clean thanks.

need cs3 lvl 3-the last level