示例#1
0
func (Println) Materialize() think.Reflex {
	s, t := think.NewSynapse()
	go func() {
		s.Focus(
			func(v interface{}) {
				fmt.Printf("%v\n", v)
			},
		)
	}()
	return think.Reflex{"Action": t}
}
示例#2
0
func (Scanln) Materialize() think.Reflex {
	s, t := think.NewSynapse()
	go func() {
		r := s.Focus(think.DontCognize)
		go func() {
			for {
				var em string
				fmt.Scanln(&em)
				r.ReCognize(em)
			}
		}()
	}()
	return think.Reflex{"Sensation": t}
}
示例#3
0
// NewEye creates a new short-term memory mechanism.
func NewEye(valve ...tree.Name) (think.Reflex, *Eye) {
	reflex := make(think.Reflex)
	m := &Eye{
		synapse: make(map[tree.Name]*think.Synapse),
		attention: EyeReCognizer{
			recognize: make(map[tree.Name]*think.ReCognizer),
			memory:    make(Memory),
		},
	}
	for _, v := range valve {
		if _, ok := reflex[v]; ok {
			panic("two valves, same name")
		}
		reflex[v], m.synapse[v] = think.NewSynapse()
		m.attention.memory.Grow(v, 0, nil)
	}
	return reflex, m
}