Beispiel #1
0
def manage_territory(life, group_id):
	_shelter = get_shelter(life, group_id)
	
	if not _shelter:
		return False
	
	_shelter_chunk = chunks.get_nearest_chunk_in_list(life['pos'], references.get_reference(_shelter))
	
	for known_group_id in life['known_groups']:
		if group_id == known_group_id:
			continue
		
		_opposing_shelter = get_possible_group_location(life, known_group_id)
		if not _opposing_shelter:
			continue
		
		_distance = chunks.get_distance_to_nearest_chunk_in_list(WORLD_INFO['chunk_map'][_shelter_chunk]['pos'], references.get_reference(_opposing_shelter))
		
		if _distance<=30:
			print '2 CLOSE 2 HANDLE'
	
	for seen_life_id in life['seen']:
		_target = brain.knows_alife_by_id(life, seen_life_id)
		
		if not _target or _target['alignment'] == 'trust' or not _target['last_seen_at'] or _target['dead']:
			continue
		
		if chunks.get_distance_to_nearest_chunk_in_list(_target['last_seen_at'], references.get_reference(_shelter))>30:
			continue
		
		print 'L@@K'* 20
		print life['name'], LIFE[seen_life_id]['name'], _target['alignment']
		
		memory.create_question(life, seen_life_id, 'territory_violation', ignore_if_said_in_last=-1)
Beispiel #2
0
def _find_nearest_reference_type_exact(position, ref_type=None):
	_lowest = {'chunk_key': None, 'reference': None, 'distance': -1}
	
	for chunk_keys in WORLD_INFO['refs'][ref_type]:
		_nearest_chunk_key = chunks.get_nearest_chunk_in_list(position, chunk_keys)
		_center = [int(val)+(WORLD_INFO['chunk_size']/2) for val in _nearest_chunk_key.split(',')]
		_distance = numbers.distance(position, _center)
		
		if not _lowest['chunk_key'] or _distance<_lowest['distance']:
			_lowest['distance'] = _distance
			_lowest['chunk_key'] = _nearest_chunk_key
			_lowest['chunk_keys'] = chunk_keys
	
	return _lowest
Beispiel #3
0
def manage_territory(life, group_id):
	if get_stage(life, group_id) == STAGE_ATTACKING:
		return False
	
	_shelter = get_shelter(life, group_id)
	
	if not _shelter:
		return False
	
	_shelter_chunk = chunks.get_nearest_chunk_in_list(life['pos'], factions.get_territory(_shelter)['chunk_keys'])
	
	for known_group_id in life['known_groups']:
		if group_id == known_group_id:
			continue
		
		_opposing_shelter = get_possible_group_location(life, known_group_id)
		if not _opposing_shelter:
			continue
		
		_distance = chunks.get_distance_to_nearest_chunk_in_list(WORLD_INFO['chunk_map'][_shelter_chunk]['pos'], factions.get_territory(_opposing_shelter)['chunk_keys'])
		
		if _distance<=30:
			print '2 CLOSE 2 HANDLE'