def simulation(self, realtime=False, trace=True, gui=True, initial_time=0, environment_process=None, **kwargs): """ Prepare simulation of the model This does not run the simulation, it only returns the simulation object. The object can then be run using run(max_time) command. realtime: should the simulation be run in real time or not? trace: should the trace of the simulation be printed? gui: should the environment appear on a separate screen? (This requires tkinter.) initial_time: what is the starting time point of the simulation? environment_process: what environment process should the simulation use? The environment_process argument should be supplied with the method environment_process of the environment used in the model. kwargs are arguments that environment_process will be supplied with. """ if len(self.decmems) == 1: for key in self.__buffers: self.__buffers[ key].dm = self.decmem #if only one dm, let all buffers use it elif len([x for x in self.decmems.values() if x]) == 1: for key in self.__buffers: if not self.__buffers[key].dm: self.__buffers[ key].dm = self.decmem #if only one non-trivial dm, let buffers use it that do not have a dm specified decmem = {name: self.__buffers[name].dm for name in self.__buffers\ if self.__buffers[name].dm != None} #dict of declarative memories used; more than 1 decmem might appear here self.__buffers["manual"] = motor.Motor() #adding motor buffer if self.__env: self.__env.initial_time = initial_time #set the initial time of the environment to be the same as simulation if self.visbuffers: self.__buffers.update(self.visbuffers) else: dm = list(decmem.values())[0] self.__buffers["visual"] = vision.Visual( self.__env, dm) #adding vision buffers self.__buffers["visual_location"] = vision.VisualLocation( self.__env, dm) #adding vision buffers self.productions.used_rulenames = { } # remove any previously stored rules for utility learning used_productions = productions.ProductionRules(self.productions, self.__buffers, decmem, self.model_parameters) chunks.Chunk._similarities = self.__similarities return simulation.Simulation(self.__env, realtime, trace, gui, self.__buffers, used_productions, initial_time, environment_process, **kwargs)
def visualBuffer(self, name_visual, name_visual_location, default_harvest=None, finst=4): """ Create visual buffers for ACTRModel. Two buffers are present in vision: visual What buffer, called just visual buffer (encoding seen objects) and visual Where buffer, called visual_location buffer (encoding positions). Both are created and returned. Finst is relevant only for the visual location buffer. name_visual and name_visual_location specify the name by which the two buffers are referred to in production rules. """ v1 = vision.Visual(self.__env, default_harvest) v2 = vision.VisualLocation(self.__env, default_harvest, finst) self.visbuffers[name_visual] = v1 self.visbuffers[name_visual_location] = v2 return v1, v2