def aimed(player_attributes, enemy_attributes):
	branch_taken = 0
	if player_attributes['endurance'] < enemy_attributes['endurance'] // 10 * 10:
		branch_taken = 1
		player_attributes['endurance'] += 1
	else:
		branch_taken = 2
		for attribute in enemy_attributes:
			if player_attributes[attribute] <= enemy_attributes[attribute] // 2:
				player_attributes[attribute] += 1
				equated = False
				break
			else:
				equated = True
				
		if equated:
			branch_taken = 3
			for attribute in enemy_attributes:
				if enemy_attributes[attribute] == min(enemy_attributes.values()):
					player_attributes[attribute] += 1
					break

	return player_attributes, branch_taken

def stats_dict(endurance, strength, agility, speed):
	return {'endurance': endurance, 'strength': strength, 'agility': agility, 'speed': speed}

def stats_to_string(stats):
	return "(END {endurance}, STR {strength}, AGI {agility}, SPD {speed})".format(**stats)

def test(player_endurance, player_strength, player_agility, player_speed,
         enemy_endurance, enemy_strength, enemy_agility, enemy_speed):
	player       = stats_dict(player_endurance, player_strength, player_agility, player_speed)
	enemy        = stats_dict(enemy_endurance, enemy_strength, enemy_agility, enemy_speed)
	aimed_result, branch_taken = aimed(player.copy(), enemy)
	print("aim {0} to {1}: {2}, b#{3}".format(stats_to_string(player), stats_to_string(enemy), stats_to_string(aimed_result), branch_taken))

# Вторая ветка — увеличение «недостающего» атрибута
test(99, 3, 3, 3, 99, 9, 9, 9)
test(99, 8, 8, 8, 99, 20, 20, 20)

# Третья ветка — увеличение атрибута, соответствующего худшему атрибуту врага
test(99, 3, 3, 3, 99, 4, 4, 4)
test(99, 8, 8, 8, 99, 9, 9, 9)