AlexeySapsay / Python_solution_CodeCombat_2018

In that repository I will post my sollution for codecombat.com games for study Python
1 stars 0 forks source link

Long range division #13

Open AlexeySapsay opened 6 years ago

AlexeySapsay commented 6 years ago
### # Destroy the mines!
### # Use `say` to call out the range to the mines.
### # Use division to calculate the range.
enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
hero.say("range1"+distanceToEnemy/3+"Fire!")
#range1 = distanceToEnemy/3
#hero.say("range1")
#hero.say("Fire!")
# Say second range: distanceToEnemy divided by 1.5
hero.say("range1"+distanceToEnemy/3+"Fire!")
#range2 = distanceToEnemy/1.5
hero.say("range2"+distanceToEnemy/1.5+"Fire!")
#hero.say("Fire!")

# Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!")
hero.say("Here we go!")
hero.say("Charge!!")

# Now, use a while-true loop to attack the enemies.
while True:
    enemy = hero.findNearestEnemy()
    hero.attack(enemy)
vadim-job-hg commented 6 years ago
enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
hero.say(distanceToEnemy / 3)
hero.say("Огонь!")
# Say second range: distanceToEnemy divided by 1.5
hero.say(distanceToEnemy / 1.5)
hero.say("Огонь!")

# Скажите эти штуки для мотивации. Серьезно. Верьте нам.
hero.say("Йи-ху!")
hero.say("Готово!")
hero.say("Заряд!")

# Теперь используйте while-true цикл для атаки противников.
while True:
    enemy = hero.findNearestEnemy()
hero.attack(enemy)
AlexeySapsay commented 6 years ago

vadim-job-hg, Спасибо за подсказку. Получилось найти в чем у меня ошибка.

Не могли бы еще сделать решение по Hunter Valley. Т.к не нашел этого решения у Вас на хабе. Хотел посмотреть и понять как решать.

AlexeySapsay commented 6 years ago
# Follow me on youtube  channel Phy Tu
# Help with programming on Python, school math, physics
# https://www.youtube.com/channel/UCP5ycahCEZ24qmRRgNnko5Q

# Destroy the mines!
# Use `say` to call out the range to the mines.
# Use division to calculate the range.

enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)

# Say first Range: distanceToEnemy divided by 3
hero.say(distanceToEnemy/3+"Fire!")

#range2 = distanceToEnemy/1.5
hero.say(distanceToEnemy/1.5+"Fire!")
#hero.say("Fire!")

# Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!")
hero.say("Here we go!")
hero.say("Charge!!")

# Now, use a while-true loop to attack the enemies.
while True:
    enemy = hero.findNearestEnemy()
    hero.attack(enemy)