func TestWithCoord(t *testing.T) { fmt.Println("Testing With Coord") agnt := make(chan link.Message, 10) prox := make(chan link.Message, 10) simple := NewSimple(1) proxy := cagent.NewAgentProxy(prox, agnt) go func() { agent.Run(simple, agnt, prox) }() co := coord.NewCoordinator() co.Configure( config.NewConfig( 0, []cagent.Agent{ proxy, }, "noise", true, true, geo.NewPoint(0, 0), geo.NewPoint(10, 10), ), ) co.Run() }
func CoordinatorList(k int, configTemplate *config.Config) CoordinatorSlice { coords := make(CoordinatorSlice, k) for i := 0; i < k; i++ { coords[i] = NewCoordinator() coords[i].Configure(configTemplate.Duplicate(i, geo.NewPoint(0, 0), geo.NewPoint(0, 0))) } return coords }
func (self *GameConfig) SideBySideCoordinators(k, w, h int) CoordinatorSlice { coords := make(CoordinatorSlice, k) for i := 0; i < k; i++ { newConf := self.CoordConfig(i, geo.NewPoint(w*i, 0), geo.NewPoint(w*(i+1), h)) coords[i] = NewCoordinator() coords[i].Configure(newConf) } return coords }
func NewAgentProxy(send link.SendLink, recv link.RecvLink) *AgentProxy { self := new(AgentProxy) self.state = NewAgentState(0, geo.NewPoint(0, 0), 0) self.snd = send self.rcv = recv self.log = log.New(os.Stdout, "AgentProxy : ", 0) return self }
func NewGameConfig(maxTurns int, msgStyle string, food bool, w, h int) *GameConfig { return &GameConfig{MaxTurns: maxTurns, MessageStyle: msgStyle, UseFood: food, Size: *geo.NewPoint(w, h), Agents: make([]*config.AgentDefinition, 0), } }
func RunAgentLocal(a agent.Agent, x, y, energy int) *AgentProxy { p2a := make(chan link.Message, 10) a2p := make(chan link.Message, 10) proxy := NewAgentProxy(p2a, a2p) proxy.SetState(cagent.NewAgentState(a.Id(), 0, *geo.NewPoint(x, y), Energy(energy))) go func() { agent.Run(a, a2p, p2a) }() return proxy }
func newMove(x, y int) *Move { self := new(Move) self.pos = *geo.NewPoint(x, y) return self }
func (self *comm) Move(x, y int) bool { c, _ := self.acked_send(link.NewMessage(link.Commands["Move"], geo.NewPoint(x, y))) return c }