예제 #1
0
def old_steels_uniwersal_basic_experiment(num_iter, agents, stimuli, interaction, 
			classifier = SteelsClassifier, topology = None, 
			inc_category_treshold = None, dump_freq = 50):
				
	sys.path.append("../")
	from cog_abm.core.agent import Agent
	from cog_abm.agent.sensor import SimpleSensor
	from pygraph.classes.graph import graph
	from pygraph.algorithms.generators import generate
	from cog_abm.core.environment import Environment
	from cog_abm.stimuli.stimulus import SimpleStimulus
	from cog_abm.extras.color import Color
	from cog_abm.core.simulation import Simulation


	num_agents = len(agents)
	topology = def_value(topology, 
	                     generate(num_agents, num_agents*(num_agents-1)/2))
	
	stimuli = def_value(stimuli, default_stimuli())
	
	if inc_category_treshold is not None:
		interaction.__class__.def_inc_category_treshold = inc_category_treshold
		
	env = Environment(stimuli, True)
	Simulation.global_environment = env

	s = Simulation(topology, interaction, agents)
	res = s.run(num_iter, dump_freq)
	
	return res
예제 #2
0
def steels_uniwersal_basic_experiment(num_iter, agents, environments, interaction, 
			classifier = SteelsClassifier, topology = None, 
			inc_category_treshold = None, dump_freq = 50, stimuli = None):
				
	sys.path.append("../")
	from cog_abm.core.agent import Agent
	from cog_abm.agent.sensor import SimpleSensor
	from pygraph.classes.graph import graph
	from pygraph.algorithms.generators import generate
	from cog_abm.core.environment import Environment
	from cog_abm.stimuli.stimulus import SimpleStimulus
	from cog_abm.extras.color import Color
	from cog_abm.core.simulation import Simulation


	num_agents = len(agents)
	topology = def_value(topology, 
	                     generate(num_agents, num_agents*(num_agents-1)/2))
	
	if stimuli == None:
		stimuli = def_value(None, default_stimuli())
	
	if inc_category_treshold is not None:
		interaction.__class__.def_inc_category_treshold = inc_category_treshold
		
	env = Environment(stimuli, True)
	for key in environments.keys():
			Simulation.environments[key] = Environment(environments[key].stimuli, True)
	#bez sensu...
	if "global" in environments:
		glob = Environment([SimpleStimulus(c) for c in environments["global"].stimuli], True)
	else:
		glob = None
		
	Simulation.global_environment = def_value(glob , env)

	s = Simulation(topology, interaction, agents)
	res = s.run(num_iter, dump_freq)
	
	return res