fai 'level_up_attack_move.fai'

# Score will be the probability * 100 of attacker unit (me) killing target unit #
# (target) if attacker can level up and if the highest probable outcome         #
# is attacker killing target.                                                   #

# function calc_exp returns exp gain for a kill of unit with level#
def calc_exp(level) 
	if(level = 0, 4, level * 8);

# function returns best defensive loc reachable by attacker to attack enemy     #
def get_best_defense_loc(moves, attacker, enemy)
	choose(filter(map(filter(moves, src=attacker.loc), dst), 
		distance_between(self, enemy.loc) = 1), 
		defense_on(attacker, self));

if(calc_exp(target.level) > (me.max_experience - me.experience),
	if(battle_outcome[1].hitpoints_left[0] = 0,
		if(battle_outcome[0].hitpoints_left[0] > 0,
			if(max(battle_outcome[1].probability) = battle_outcome[1].probability[0],
				battle_outcome[1].probability[0] / 100,
    			-5),
			-5),
		-5),
	-5)
where battle_outcome = calculate_outcome(me.loc, get_best_defense_loc(my_moves.moves, me, target), target.loc)

faiend
