Esempio n. 1
0
func (self *MasterConfig) fillInData() {
	currentCoordId := 0
	for coordAddress, coordConf := range self.Coordinators {
		currentCoordId += 1
		coordConf.Identifier = currentCoordId
		coordConf.Agents = make([]*coordconf.AgentDefinition, 0)
		bl := coordConf.BottomLeft
		tr := coordConf.TopRight
		var currentAgentId uint32 = 0
		for _, agentConf := range self.Agents {
			currentAgentId += 1
			agentConf.Id = currentAgentId
			ap := agentConf.Position
			if bl.X <= ap.X && ap.X < tr.X && bl.Y <= ap.Y && ap.Y < tr.Y {
				ad := coordconf.NewAgentDefinition(agentConf.Id, ap.X, ap.Y, agentConf.Energy)
				agentConf.CoordAddress = coordAddress
				coordConf.Agents = append(coordConf.Agents, ad)
			}
		}
	}
}
Esempio n. 2
0
func (self *GameConfig) AddAgent(id uint32, x, y, energy int) {
	self.Agents = append(self.Agents, config.NewAgentDefinition(id, x, y, energy))
}