Example #1
0
def understand(life):
	if SETTINGS['controlling']:
		_dist_to_player = numbers.distance(life['pos'], LIFE[SETTINGS['controlling']]['pos'])
		if _dist_to_player < 100:
			if life['think_rate_max']>=30:
				if _dist_to_player < 75:
					life['think_rate_max'] = 1
					life['online'] = True
					logging.debug('[Agent] %s brought online (Reason: Near viewer)' % ' '.join(life['name']))
				
			else:
				life['think_rate_max'] = 1
		else:
			if _dist_to_player >= OFFLINE_ALIFE_DISTANCE and life['online']:
				life['online'] = False
				logging.debug('[Agent] %s went offline (Reason: Away from viewer)' % ' '.join(life['name']))
			elif life['think_rate_max']<30:
				if _dist_to_player < OFFLINE_ALIFE_DISTANCE:
					life['online'] = True
				
				logging.debug('[Agent] %s went passive (Reason: Away from viewer)' % ' '.join(life['name']))
			
			life['think_rate_max'] = numbers.clip(15*(((_dist_to_player-100)+30)/30), 30, 60)
	else:
		life['think_rate_max'] = 5
	
	if not life['online'] or life['asleep']:
		return False
	
	if len(life['actions'])-len(lfe.find_action(life, matches=[{'action': 'move'}, {'action': 'dijkstra_move'}]))>0:
		lfe.clear_actions(life)
		life['path'] = []
		
		return False
	
	if life['think_rate']>0:
		life['think_rate'] -= 1
		
		return False
	
	for module in CONSTANT_MODULES:
		module.setup(life)
	
	life['think_rate'] = life['think_rate_max']
	
	#if life['name'][0].startswith('Tim'):
	#	_goal, _tier, _plan = planner.get_next_goal(life, debug='attack')
	#else:
	_goal, _tier, _plan = planner.get_next_goal(life)
	
	if _goal:
		lfe.change_goal(life, _goal, _tier, _plan)
	else:
		lfe.change_goal(life, 'idle', TIER_RELAXED, [])
		#logging.error('%s has no possible goal.' % ' '.join(life['name']))
		
		return False
	
	planner.think(life)
	
Example #2
0
def understand(life):
	if SETTINGS['controlling']:
		_dist_to_player = numbers.distance(life['pos'], LIFE[SETTINGS['controlling']]['pos'])
		if _dist_to_player < 100:
			if life['think_rate_max']>=30:
				if _dist_to_player < 75:
					life['think_rate_max'] = 1
					life['online'] = True
					logging.debug('[Agent] %s brought online (Reason: Near viewer)' % ' '.join(life['name']))
				
			else:
				life['think_rate_max'] = 1
		else:
			if _dist_to_player >= OFFLINE_ALIFE_DISTANCE and life['online']:
				life['online'] = False
				logging.debug('[Agent] %s went offline (Reason: Away from viewer)' % ' '.join(life['name']))
			elif life['think_rate_max']<30:
				if _dist_to_player < OFFLINE_ALIFE_DISTANCE:
					life['online'] = True
				
				logging.debug('[Agent] %s went passive (Reason: Away from viewer)' % ' '.join(life['name']))
			
			life['think_rate_max'] = numbers.clip(15*(((_dist_to_player-100)+30)/30), 30, 60)
	else:
		life['think_rate_max'] = 5
	
	if not life['online']:
		return False
	
	if life['think_rate']:
		life['think_rate'] -= 1
		
		return False
	
	for module in CONSTANT_MODULES:
		module.setup(life)
	
	life['think_rate'] = life['think_rate_max']
	
	_goal, _tier, _plan = planner.get_next_goal(life)
	
	if _goal:
		lfe.change_goal(life, _goal, _tier, _plan)
	else:
		lfe.change_goal(life, 'idle', TIER_RELAXED, [])
		logging.error('%s has no possible goal.' % ' '.join(life['name']))
		return False
	
	planner.think(life)
	
Example #3
0
def understand(life):
    if SETTINGS['controlling']:
        _dist_to_player = numbers.distance(
            life['pos'], LIFE[SETTINGS['controlling']]['pos'])
        if _dist_to_player < 100:
            if life['think_rate_max'] >= 30:
                if _dist_to_player < 75:
                    life['think_rate_max'] = 1
                    life['online'] = True
                    logging.debug(
                        '[Agent] %s brought online (Reason: Near viewer)' %
                        ' '.join(life['name']))

            else:
                life['think_rate_max'] = 1
        else:
            if _dist_to_player >= OFFLINE_ALIFE_DISTANCE and life['online']:
                life['online'] = False
                logging.debug(
                    '[Agent] %s went offline (Reason: Away from viewer)' %
                    ' '.join(life['name']))
            elif life['think_rate_max'] < 30:
                if _dist_to_player < OFFLINE_ALIFE_DISTANCE:
                    life['online'] = True

                logging.debug(
                    '[Agent] %s went passive (Reason: Away from viewer)' %
                    ' '.join(life['name']))

            life['think_rate_max'] = numbers.clip(
                15 * (((_dist_to_player - 100) + 30) / 30), 30, 60)
    else:
        life['think_rate_max'] = 5

    if not life['online'] or life['asleep']:
        return False

    if len(life['actions']) - len(
            lfe.find_action(life,
                            matches=[{
                                'action': 'move'
                            }, {
                                'action': 'dijkstra_move'
                            }])) > 0:
        lfe.clear_actions(life)
        life['path'] = []

        return False

    if life['think_rate'] > 0:
        life['think_rate'] -= 1

        return False

    for module in CONSTANT_MODULES:
        module.setup(life)

    life['think_rate'] = life['think_rate_max']

    #if life['name'][0].startswith('Tim'):
    #	_goal, _tier, _plan = planner.get_next_goal(life, debug='attack')
    #else:
    _goal, _tier, _plan = planner.get_next_goal(life)

    if _goal:
        lfe.change_goal(life, _goal, _tier, _plan)
    else:
        lfe.change_goal(life, 'idle', TIER_RELAXED, [])
        #logging.error('%s has no possible goal.' % ' '.join(life['name']))

        return False

    planner.think(life)