Example #1
0
func (e *Econ) isTracked(a sim.Agent) bool {
	for _, id := range e.Tracked {
		if a.Id() == id {
			return true
		}
	}
	return false
}
Example #2
0
func (b *Books) regAgent(a sim.Agent) {
	if _, ok := b.agentDat[a.Id()]; ok {
		return
	}

	tp := reflect.Indirect(reflect.ValueOf(a)).Type()
	b.agentDat[a.Id()] = &agentData{
		Id:   a.Id(),
		Name: a.Name(),
		Type: tp.PkgPath() + "." + tp.Name(),
		Born: b.getTime(),
	}

	// this comes last to prevent infinite looping
	if par := a.Parent(); par != nil {
		b.agentDat[a.Id()].ParentId = par.Id()
		b.regAgent(par)
	}
}