Help on kithgard brawl no.6


#1

any links, code any thing to help because
i also need help with the
*kithgard brawl no.6
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
item = hero.findNearestItem()
if item:
hero.moveXY(item.pos.x, item.pos.y)

*backwood brawl no.4
while True:
enemy = hero.findNearestEnemy()
if hero.isReady(“cleave”):
hero.cleave(enemy)
else:
hero.attack(enemy)

*backwood treasure no.4

Collect 100 gold from two or three groves.

If you win, it gets harder (and more rewarding).

If you lose, you must wait a day before you can resubmit.

Remember, each submission gets a new random seed.

def pickUpNearestItem(items):
nearestItem = hero.findNearest(items)
if nearestItem:
moveTo(nearestItem.pos)

def moveTo(position, fast=True):
if (hero.isReady(“jump”) and hero.distanceTo > 10 and fast):
hero.jumpTo(position)
else:
hero.move(position)

def attack(target):
if target:
if (hero.distanceTo(target) > 10):
moveTo(enemy.pos)
elif (hero.isReady(“bash”)):
hero.bash(enemy)
elif (hero.isReady(“power-up”)):
hero.powerUp()
hero.attack(enemy)
elif (hero.isReady(“cleave”)):
hero.cleave(enemy)
else:
hero.attack(enemy)

*savern brawl
enemy_types = {}

ogres types

enemy_types[‘shaman’] = {‘danger’: 10, ‘focus’: 10}
enemy_types[‘warlock’] = {‘danger’: 10, ‘focus’: 10}

enemy_types[‘burl’] = {‘danger’:10, ‘focus’:5}

enemy_types[‘witch’] = {‘danger’: 8, ‘focus’: 10}

enemy_types[‘brawler’] = {‘danger’:7, ‘focus’:5}

enemy_types[‘ogre’] = {‘danger’:5, ‘focus’:5}

enemy_types[‘chieftain’] = {‘danger’:6, ‘focus’:10}

enemy_types[‘fangrider’] = {‘danger’: 4, ‘focus’: 20}

enemy_types[‘skeleton’] = {‘danger’:5, ‘focus’:10}

enemy_types[‘scout’] = {‘danger’:4, ‘focus’:10}

enemy_types[‘thrower’] = {‘danger’:3, ‘focus’:15}

enemy_types[‘munchkin’] = {‘danger’:2, ‘focus’:5}

enemy_types[‘yak’] = {‘danger’: -1, ‘focus’: 0}
enemy_types[‘ice-yak’] = {‘danger’: -1, ‘focus’: 0}

if hero.team == ‘humans’:
team = 'humans’
else:
team = ‘ogres’

def findTarget():
danger = 0
enemy_return = None
for type in enemy_types.keys():
if enemy_types[type].danger > danger:
enemy = hero.findNearest(hero.findByType(type))
if enemy and enemy.type != ‘yak’ and enemy.team != team and hero.distanceTo(enemy) < enemy_types[
type].focus:
enemy_return = enemy
danger = enemy_types[type].danger
# if enemy_return is None:
# enemy_return = hero.findNearest(hero.findEnemies())
if enemy_return and enemy_return.type != ‘yak’:
return enemy_return
else:
return None

def moveTo(position, fast=True):
if (hero.isReady(“jump”) and fast):
hero.jumpTo(position)
else:
hero.move(position)

summonTypes = [‘paladin’]

def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold > hero.costOf(type):
hero.summon(type)

def commandTroops():
for index, friend in enumerate(hero.findFriends()):
if friend.type == ‘paladin’:
CommandPaladin(friend)
elif friend.type == ‘soldier’ or friend.type == ‘archer’:
CommandSoldier(friend)

def CommandSoldier(soldier):
target = hero.findNearest(hero.findEnemies())
if target:
hero.command(soldier, “attack”, target)

def CommandPaladin(paladin):
if (paladin.canCast(“heal”) and hero.health < hero.maxHealth * 0.9):
hero.command(paladin, “cast”, “heal”, self)
else:
if enemyattack:
hero.command(paladin, “attack”, enemyattack)
else:
hero.command(paladin, “defend”, self)

def attack(target):
if target:
if (hero.distanceTo(target) > 10):
moveTo(target.pos)
elif (hero.isReady(“bash”)):
hero.bash(target)
elif (hero.canCast(‘chain-lightning’, target) and yak_alert == False):
hero.cast(‘chain-lightning’, target)
elif (hero.isReady(“attack”)):
hero.attack(target)
else:
hero.shield()

index = 0
route = [[20, 20, True], [140, 20, True], [140, 117, True], [20, 110, True]]

def moveHero():
ind = index % len(route)
moveTo({‘x’: route[ind][0], ‘y’: route[ind][1]}, route[ind][2])
if (hero.pos.x == route[ind][0] and hero.pos.y == route[ind][1]):
return True
else:
return False

while True:
yak_alert = False
enemyattack = findTarget()
yak = hero.findNearest(hero.findByType(‘sand-yak’))
if yak and hero.distanceTo(yak) < 40:
yak_alert = True
commandTroops()
summonTroops()
if enemyattack:
attack(enemyattack)
elif (moveHero()):
index = index + 1

*savern siege no.4
hero.moveXY(74, 51)
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)

*sarven treasure no.3

Collect 150 gold while evading ogres with teleporters.

If you win, it gets harder (and more rewarding).

If you lose, you must wait a day before you can resubmit.

Remember, each submission gets a new random seed.

while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
coin = hero.findNearestItem()
if coin:
hero.moveXY(coin.pos.x, coin.pos.y)

*cloudrip brawl no.3
while True:
enemy = hero.findNearestEnemy()
if hero.isReady(“bash”):
hero.bash(hero.findNearestEnemy())
else:
hero.shield()

*cloudrip siege no.3
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.buildXY(“fire-trap”, enemy.pos.x, enemy.pos.y)

*cloudrip treasure

Your goal is to collect coins / gems.

This level is repeatable. If you win, the difficulty and rewards will increase.

If you fail, you have to wait a day to resubmit.

This level is an optional challenge level. You don’t need to beat it to continue the campaign!

def moveTo(position, fast=True):
if (hero.isReady(“jump”) and hero.distanceTo > 10 and fast):
hero.jumpTo(position)
else:
hero.move(position)

pickup coin

def pickUpNearestItem(items):
nearestItem = hero.findNearest(items)
if nearestItem:
moveTo(nearestItem.pos)

add soldier

summonTypes = [‘griffin-rider’, ‘soldier’, ‘archer’ , ‘peasant’]

def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold > hero.costOf(type):
hero.summon(type)

def findNearest(index):
top = False
left = False
if (index == 0):
top = True
left = True
elif (index == 1):
top = True
elif (index == 3):
left = True
items = hero.findItems()
for item in items:
if (item.pos.y > 66 and top and left and item.pos.x < 76):
return item
elif (item.pos.y < 66 and not top and left and item.pos.x < 76):
return item
elif (item.pos.y > 66 and top and not left and item.pos.x > 76):
return item
elif (item.pos.y < 66 and not top and not left and item.pos.x > 76):
return item
return None

commands attack

def commandTroops():
index = 0
for friend in hero.findFriends():
if friend.type == ‘peasant’:
item = findNearest(index)
index += 1
if item:
hero.command(friend, ‘move’, item.pos)
else:
enemy = hero.findNearest(hero.findEnemies())
if enemy:
hero.command(friend, “attack”, enemy)

def attack(target):
if target:
if (hero.distanceTo(target) > 10):
moveTo(enemy.pos)
elif (hero.isReady(“bash”)):
hero.bash(enemy)
elif (hero.isReady(“power-up”)):
hero.powerUp()
hero.attack(enemy)
elif (hero.isReady(“cleave”)):
hero.cleave(enemy)
else:
hero.attack(enemy)

while True:
summonTroops()
commandTroops()
enemy = hero.findNearest(hero.findEnemies())
attack(enemy)


#2

If you need help with those levels please post your codes properly formatted according to the FAQ.