Exemple #1
0
func (self CoordinatorSlice) StartAndConnectAgents(agents map[uint32]agent.Agent) {
	for _, coord := range self {
		for _, agent_desc := range coord.conf.Agents {
			logflow.Print("Starting agent ", agent_desc.Id, " in ", coord.conf)
			go agent.RunWithCoordinator(agents[agent_desc.Id], coord.conf.Address)
		}
	}
}
Exemple #2
0
func (self *GameState) AgentStatesToExport(req GameStateRequest) []cagent.AgentState {
	bl := req.BottomLeft
	tr := req.TopRight
	upForAdoption := make([]cagent.AgentState, 0)
	for _, agent := range self.upForAdoption {
		p := agent.State().Position
		if bl.X <= p.X && bl.Y <= p.Y && p.X < tr.X && p.Y < tr.Y {
			upForAdoption = append(upForAdoption, *agent.State())
			agent.MigrateTo(req.SenderAddress)
		}
	}
	if len(upForAdoption) > 0 {
		logflow.Print("gamestate/info", "Transferring from ", self.conf.Identifier, " to ", req.SenderIdentifier, ":")
		logflow.Print("gamestate/info", upForAdoption)
	}
	return upForAdoption
}