示例#1
0
def update_targets_around_noise(life, noise):
	_most_likely_target = {'target': None, 'last_seen_time': 0}
	
	if 'target' in noise and not life['id'] == noise['target']:
		_visiblity = bad_numbers.clip(sight.get_stealth_coverage(LIFE[noise['target']]), 0.0, 1.0)
		_visiblity = bad_numbers.clip(_visiblity+(bad_numbers.distance(life['pos'], LIFE[noise['target']]['pos']))/(sight.get_vision(life)/2), 0, 1.0)
		
		if _visiblity >= sight.get_visiblity_of_position(life, LIFE[noise['target']]['pos']):
			brain.meet_alife(life, LIFE[noise['target']])
			
			life['know'][noise['target']]['escaped'] = 1
			life['know'][noise['target']]['last_seen_at'] = noise['pos'][:]
			life['know'][noise['target']]['last_seen_time'] = 0
	
	for target in life['know'].values():
		if not target['escaped'] or not target['last_seen_at'] or target['dead']:
			continue
		
		if bad_numbers.distance(target['last_seen_at'], noise['pos']) > noise['volume']:
			continue
		
		if judgement.is_target_threat(life, target['life']['id']):
			if not _most_likely_target['target'] or target['last_seen_time'] < _most_likely_target['last_seen_time']:
				_most_likely_target['last_seen_time'] = target['last_seen_time']
				_most_likely_target['target'] = target
	
	if _most_likely_target['target']:
		_most_likely_target['target']['escaped'] = 1
		_most_likely_target['target']['last_seen_at'] = noise['pos'][:]
		_most_likely_target['target']['last_seen_time'] = 1
		
		logging.debug('%s heard a noise, attributing it to %s.' % (' '.join(life['name']), ' '.join(_most_likely_target['target']['life']['name'])))
示例#2
0
def update_targets_around_noise(life, noise):
	_most_likely_target = {'target': None, 'last_seen_time': 0}
	
	for target in life['know'].values():
		if not target['escaped']:
			continue
		
		if numbers.distance(target['last_seen_at'], noise['pos']) > noise['volume']:
			continue
		
		if judgement.is_target_threat(life, target['life']['id']):
			if not _most_likely_target['target'] or target['last_seen_time'] < _most_likely_target['last_seen_time']:
				_most_likely_target['last_seen_time'] = target['last_seen_time']
				_most_likely_target['target'] = target
			
			#target['escaped'] = 1
			#target['last_seen_at'] = noise['pos'][:]
	
	if _most_likely_target['target']:
		print '/' * 50
		_most_likely_target['target']['escaped'] = 1
		_most_likely_target['target']['last_seen_at'] = noise['pos'][:]
		_most_likely_target['target']['last_seen_time'] = 1
		logging.debug('%s heard a noise, attributing it to %s.' % (' '.join(life['name']), ' '.join(_most_likely_target['target']['life']['name'])))