def examine_possible_moves(p, targets):
	#TODO: Cancel move?
	_moves = {}
	
	#if p['next_stance']['stance']:
	#	return False
	
	for _target in targets:
		target = LIFE[_target]
		if target == p:
			continue
		
		if sum([abs(i) for i in target['velocity']]):
			continue
		
		if 'player' in p:
			_moves[_target] = {'moves': [], 'counters': []}
		
		_next_stance = p['next_stance']['stance']
		_next_target_stance = target['next_stance']['stance']
		_incoming_attack = False
		
		#Target is attacking
		if target['stance'] in target['moves']:
			_incoming_attack = target['stance']
		elif _next_target_stance in target['moves']:
			_incoming_attack = _next_target_stance
		
		if _incoming_attack:
			if not _next_stance in p['moves'][_incoming_attack]['counters']:
				if 'player' in p:
					_moves[_target]['counters'].extend(p['moves'][_incoming_attack]['counters'])
				elif p['moves'][_incoming_attack]['counters']:
					assume_stance(p, random.choice(p['moves'][_incoming_attack]['counters']), towards=_target)
					return False
			
			elif p['stance'] in p['moves'][_incoming_attack]['counters']:
				return True
		
		if 'player' in p:
			_moves[_target]['moves'].extend(p['moves'].keys())
		else:
			assume_stance(p, random.choice(p['moves'].keys()), towards=_target)
			return True
		
		#if _next_stance and _next_stance in p['moves'] and not p['stance'] in p['moves'][_next_stance]['counters']:
		#	assume_stance(p, p['moves'][_next_stance]['counters'][0], towards=_target)
		#	return False
		#elif (not _next_stance or not target['stance'] in p['moves']):
		#	assume_stance(p, random.choice(p['moves'].keys()), towards=_target)
		#	return True
	
	if _moves and menus.get_menu_by_name('Advanced Movement')==-1 and not sum([abs(i) for i in p['velocity']]):
		_menu = []
		
		for target_id in _moves:
			if _moves[target_id]['moves']:
				_menu.append(menus.create_item('title', '%s (Attacks)' % ' '.join(LIFE[target_id]['name']), None))
				
				for move in _moves[target_id]['moves']:
					_menu.append(menus.create_item('single', move, None, move=move, target=target_id))
			
			if _moves[target_id]['counters']:
				_menu.append(menus.create_item('title', '%s (Counters)' % ' '.join(LIFE[target_id]['name']), None))
				
				for move in _moves[target_id]['counters']:
					_menu.append(menus.create_item('single', move, None, move=move, target=target_id))
		
		_m = menus.create_menu(menu=_menu,
		                       position=[1, 1],
		                       title='Advanced Movement',
		                       format_str='$k',
		                       on_select=lambda entry: assume_stance(LIFE[SETTINGS['controlling']],
		                                                             entry['move'],
		                                                             towards=entry['target']),
		                       close_on_select=True)
		menus.activate_menu(_m)
dataset/ETHPy150Open flags/Reactor-3/melee.py/examine_possible_moves/original