Ejemplo n.º 1
0
// opSenseOthers: sense energy ahead, excluding those with the same bytecode, capped at 255
func opSenseOthers(o *org.Organism, c *Cpu) error {
	filter := func(n interface{}) float64 {
		if org, ok := n.(*org.Organism); ok {
			if nc, ok := org.Driver.(*Cpu); ok {
				if c.Hash() == nc.Hash() {
					return 0.0
				}
			}
		}
		return 1.0
	}
	c.R[0] = clip(int(o.Sense(filter)), 0, 255)
	return nil
}
Ejemplo n.º 2
0
// opSense: sense energy ahead, capped at 255
func opSense(o *org.Organism, c *Cpu) error {
	c.R[0] = clip(int(o.Sense(nil)), 0, 255)
	return nil
}