Ejemplo n.º 1
0
def conditions(life, alife_seen, alife_not_seen, targets_seen,
               targets_not_seen, source_map):
    return False

    RETURN_VALUE = STATE_UNCHANGED

    if not lfe.execute_raw(life, 'state', 'explore'):
        return False

    if not life['state'] == STATE:
        RETURN_VALUE = STATE_CHANGE

    #_leading_target = judgement.get_leading_target(life)
    #if _leading_target:
    #	_known = brain.knows_alife_by_id(life, _leading_target)
    #
    #	print _leading_target

    _explore_chunk = chunks.find_best_chunk(life, ignore_time=True)
    brain.store_in_memory(life, 'explore_chunk', _explore_chunk)

    if not _explore_chunk:
        return False

    return RETURN_VALUE
Ejemplo n.º 2
0
def tick(life):
    if not lfe.execute_raw(life, 'discover', 'discover_type'):
        _lost_method = lfe.execute_raw(life, 'discover', 'when_lost')
        if _lost_method:
            if not life['path'] or not brain.retrieve_from_memory(
                    life, 'discovery_lock'):
                if not 'scanned_chunks' in life['state_flags']:
                    life['state_flags']['scanned_chunks'] = []

                sight.scan_surroundings(
                    life,
                    _chunks=brain.get_flag(life, 'visible_chunks'),
                    ignore_chunks=life['state_flags']['scanned_chunks'])

                _explore_chunk = chunks.find_best_chunk(
                    life,
                    ignore_starting=True,
                    ignore_time=True,
                    lost_method=_lost_method,
                    only_recent=True)
                brain.store_in_memory(life, 'discovery_lock', True)
                brain.store_in_memory(life, 'explore_chunk', _explore_chunk)

                if not _explore_chunk:
                    brain.flag(life, 'lost')
                    return False

                survival.explore_known_chunks(life)
        else:
            return False
Ejemplo n.º 3
0
def judge(life):
	_threats = []
	_combat_targets = []
	_neutral_targets = []
	_tension = 0
	
	for alife_id in life['know']:
		_target = life['know'][alife_id]
		
		if _target['escaped'] == 2 or _target['dead'] or not _target['last_seen_at']:
			continue
		
		#TODO: Unhardcode 1. Can be used for reaction times
		if _target['last_seen_time'] >= 1 and not _target['escaped']:
			#TODO: Unhardcode 2000. How long to wait until a target is lost
			if _target['last_seen_time'] >= 2000:
				_target['escaped'] = 2
				logging.debug('%s flagged %s as lost (state 2).' % (' '.join(life['name']), ' '.join(_target['life']['name'])))
			elif _target['last_seen_time']>=25 and not _target['escaped']:
				_target['escaped'] = 1
		
		_tension += get_tension_with(life, alife_id)
		
		if can_trust(life, alife_id):
			_neutral_targets.append(alife_id)
		else:
			_combat_targets.append(alife_id)
			_threats.append(alife_id)
	
	brain.store_in_memory(life, 'threats', _threats)
	brain.store_in_memory(life, 'combat_targets', _combat_targets)
	brain.store_in_memory(life, 'targets', _neutral_targets)
	brain.store_in_memory(life, 'tension_spike', _tension-get_tension(life))
	brain.store_in_memory(life, 'tension', _tension)
Ejemplo n.º 4
0
def conditions(life, alife_seen, alife_not_seen, targets_seen, targets_not_seen, source_map):
	RETURN_VALUE = STATE_UNCHANGED
	
	if not life['state'] == STATE:
		RETURN_VALUE = STATE_CHANGE
	
	_lost_targets = judgement.get_combat_targets(life, escaped_only=True)
	brain.store_in_memory(life, 'lost_targets', _lost_targets)
	
	if not _lost_targets:
		return False
	else:
		print life['name'], _lost_targets
	
	return RETURN_VALUE
Ejemplo n.º 5
0
def conditions(life, alife_seen, alife_not_seen, targets_seen,
               targets_not_seen, source_map):
    RETURN_VALUE = STATE_UNCHANGED

    if not life['state'] == STATE:
        RETURN_VALUE = STATE_CHANGE

    _lost_targets = judgement.get_combat_targets(life, escaped_only=True)
    brain.store_in_memory(life, 'lost_targets', _lost_targets)

    if not _lost_targets:
        return False
    else:
        print life['name'], _lost_targets

    return RETURN_VALUE
Ejemplo n.º 6
0
def conditions(life, alife_seen, alife_not_seen, targets_seen, targets_not_seen, source_map):
	RETURN_VALUE = STATE_UNCHANGED

	if not judgement.is_safe(life):
		return False
	
	_job = jobs.alife_has_job(life)

	_active_goals = goals.get_active_goals(life)
	brain.store_in_memory(life, 'active_goals', value=_active_goals)
	
	if not _active_goals and not life['job'] and not _job:
		return False
	
	if not life['state'] == STATE:
		RETURN_VALUE = STATE_CHANGE

	return RETURN_VALUE
Ejemplo n.º 7
0
def tick(life):
	if not lfe.execute_raw(life, 'discover', 'discover_type'):
		_lost_method = lfe.execute_raw(life, 'discover', 'when_lost')
		if _lost_method:
			if not life['path'] or not brain.retrieve_from_memory(life, 'discovery_lock'):
				if not 'scanned_chunks' in life['state_flags']:
					life['state_flags']['scanned_chunks'] = []

				sight.scan_surroundings(life, _chunks=brain.get_flag(life, 'visible_chunks'), ignore_chunks=life['state_flags']['scanned_chunks'])
				
				_explore_chunk = chunks.find_best_chunk(life, ignore_starting=True, ignore_time=True, lost_method=_lost_method, only_recent=True)
				brain.store_in_memory(life, 'discovery_lock', True)
				brain.store_in_memory(life, 'explore_chunk', _explore_chunk)
				
				if not _explore_chunk:
					brain.flag(life, 'lost')
					return False
				
				survival.explore_known_chunks(life)
		else:
			return False
Ejemplo n.º 8
0
def judge(life):
    _threats = []
    _combat_targets = []
    _neutral_targets = []
    _tension = 0

    for alife_id in life["know"]:
        _target = life["know"][alife_id]

        if _target["escaped"] == 2 or _target["dead"] or not _target["last_seen_at"]:
            continue

            # Lost targets
            # TODO: Unhardcode 1. Can be used for reaction times
        if _target["last_seen_time"] >= 1 and not _target["escaped"]:
            # TODO: Unhardcode 2000. How long to wait until a target is lost
            # Note that `escaped` can be set to 2 after a failed search
            if _target["last_seen_time"] >= 2000:
                _target["escaped"] = 2
                logging.debug(
                    "%s flagged %s as lost (state 2)." % (" ".join(life["name"]), " ".join(_target["life"]["name"]))
                )
            elif _target["last_seen_time"] >= 25 and not _target["escaped"]:
                _target["escaped"] = 1
                # 	print 'lost.....'

        _tension += get_tension_with(life, alife_id)

        _threat = is_target_threat(life, alife_id)
        if _threat:
            _combat_targets.append(alife_id)
            _threats.append(alife_id)
        else:
            _neutral_targets.append(alife_id)

    brain.store_in_memory(life, "threats", _threats)
    brain.store_in_memory(life, "combat_targets", _combat_targets)
    brain.store_in_memory(life, "targets", _neutral_targets)
    brain.store_in_memory(life, "tension_spike", _tension - get_tension(life))
    brain.store_in_memory(life, "tension", _tension)
Ejemplo n.º 9
0
def setup(life):
    _needs_to_meet = []
    _needs_to_satisfy = []
    _needs_unmet = []

    for need in life['needs'].values():
        if not survival.needs_to_satisfy(life, need):
            continue

        if survival.can_satisfy(life, need):
            _needs_to_satisfy.append(need)

        if not survival.can_satisfy(
                life, need) and not survival.can_potentially_satisfy(
                    life, need):
            _needs_unmet.append(need)
            continue

        if not need in _needs_to_satisfy and not need in _needs_to_satisfy:
            _needs_to_meet.append(need)

    brain.store_in_memory(life, 'needs_to_meet', _needs_to_meet)
    brain.store_in_memory(life, 'needs_to_satisfy', _needs_to_satisfy)
    brain.store_in_memory(life, 'needs_unmet', _needs_unmet)

    if not _needs_to_meet and not _needs_to_satisfy:
        return False
Ejemplo n.º 10
0
def setup(life):
	_needs_to_meet = []
	_needs_to_satisfy = []
	_needs_unmet = []
	
	for need in life['needs'].values():
		if not survival.needs_to_satisfy(life, need):
			continue
		
		if survival.can_satisfy(life, need):
			_needs_to_satisfy.append(need)
		
		if not survival.can_satisfy(life, need) and not survival.can_potentially_satisfy(life, need):
			_needs_unmet.append(need)
			continue
		
		if not need in _needs_to_satisfy and not need in _needs_to_satisfy:
			_needs_to_meet.append(need)

	brain.store_in_memory(life, 'needs_to_meet', _needs_to_meet)
	brain.store_in_memory(life, 'needs_to_satisfy', _needs_to_satisfy)
	brain.store_in_memory(life, 'needs_unmet', _needs_unmet)

	if not _needs_to_meet and not _needs_to_satisfy:
		return False
Ejemplo n.º 11
0
def conditions(life, alife_seen, alife_not_seen, targets_seen, targets_not_seen, source_map):
    return False

    RETURN_VALUE = STATE_UNCHANGED

    if not lfe.execute_raw(life, "state", "explore"):
        return False

    if not life["state"] == STATE:
        RETURN_VALUE = STATE_CHANGE

        # _leading_target = judgement.get_leading_target(life)
        # if _leading_target:
        # 	_known = brain.knows_alife_by_id(life, _leading_target)
        #
        # 	print _leading_target

    _explore_chunk = chunks.find_best_chunk(life, ignore_time=True)
    brain.store_in_memory(life, "explore_chunk", _explore_chunk)

    if not _explore_chunk:
        return False

    return RETURN_VALUE