Exemplo n.º 1
0
func init() {
	brainFile := "Brain"
	var brain *microhal.Microhal

	if _, err := os.Stat(brainFile); os.IsNotExist(err) {
		brain = microhal.NewMicrohal(brainFile, MarkovChainOrder)
	} else {
		brain = microhal.LoadMicrohal(brainFile)
	}
	brainIn, brainOut := brain.Start(10000*time.Millisecond, 250)
	plugin_registry.RegisterPlugin(&HalPlugin{brainIn: brainIn, brainOut: brainOut})
}
Exemplo n.º 2
0
Arquivo: hal.go Projeto: piguet/yatzie
func loadHAL(m *HalPlugin) {
	brainFile := "Brain"
	m.MarkovChainOrder = 3 // our default
	if plugin_registry.Config.HALBrainfile != "" {
		brainFile = plugin_registry.Config.HALBrainfile
	}
	brainFile = strings.Replace(brainFile, ".json", "", -1)

	if plugin_registry.Config.HALMarkovChainOrder != 0 {
		m.MarkovChainOrder = plugin_registry.Config.HALMarkovChainOrder
	}
	var brain *microhal.Microhal
	log.Println("My brainfile is:" + brainFile)

	if _, err := os.Stat(brainFile + ".json"); os.IsNotExist(err) {
		brain = microhal.NewMicrohal(brainFile, m.MarkovChainOrder)
	} else {
		brain = microhal.LoadMicrohal(brainFile)
	}
	brainIn, brainOut := brain.Start(10000*time.Millisecond, 250)
	m.brainIn = brainIn
	m.brainOut = brainOut
	m.started = true
}