循环、字典、判断、算法...
所有知识点大集合!
while hero.gold > 20: hero.summon("soldier")
for friend in hero.findFriends(): hero.command(friend, "attack")
target = {"x": 50, "y": 40}
soldiers = ["士兵1", "士兵2"] points[0] = {"x": 33, "y": 42}
if enemy: hero.attack(enemy) else: hero.move(point)
if enemy and enemy.team == "ogres": hero.attack(enemy)
# 向右移动一小步 newX = friend.pos.x + 0.35
if enemy.health > mostHealth: toughest = enemy
enemy.health # 生命值 enemy.team # 队伍 enemy.type # 类型
friend.pos.x # 横坐标 (左右) friend.pos.y # 纵坐标 (上下)
for i in range(4): hero.summon("soldier")
count = len(hero.findFriends())
best = None maxH = 0 for e in enemies: if e.health > maxH: best = e
while True: # 外层:永远监控 for f in friends: # 内层:检查每个朋友 # ...