本文整理匯總了Golang中agent.Comm.Move方法的典型用法代碼示例。如果您正苦於以下問題:Golang Comm.Move方法的具體用法?Golang Comm.Move怎麽用?Golang Comm.Move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類agent.Comm
的用法示例。
在下文中一共展示了Comm.Move方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Turn
func (self *Configurable) Turn(comm agent.Comm) {
broadcasted := comm.Broadcast(23, []byte("hello_world"))
if self.LogBroadcast {
comm.Log("Broadcast success:", broadcasted)
}
comm.Move(self.XVelocity, self.YVelocity)
if self.LogMove {
// comm.Logf("Pos: %v (%t)", self.Position(), success)
}
if self.LogListen {
comm.Log("Heard:", string(comm.Listen(23)))
}
if self.LogCollect {
comm.Log("Collected: ", comm.Collect())
}
if self.LogLook {
comm.Log("Look: ", comm.Collect())
}
if self.LogPrevious {
comm.Log("Previous: ", comm.PrevResult())
}
if self.LogEnergy {
comm.Log("Energy:", comm.Energy())
}
return
}
示例2: Turn
func (self *RandomBot) Turn(comm agent.Comm) {
defer func() { self.time += 1 }()
if self.Time()%250 == 0 {
x := pseudo_rand.Intn(2) - 1
y := pseudo_rand.Intn(2) - 1
comm.Move(x, y)
self.log("info", "moved", x, y)
}
if self.Id() == 8 && self.Time() == 500 {
self.send.Send([]byte("Hello there Number 1."), 1)
}
self.hello.Run(comm)
self.route.Run(self.hello.Neighbors(), comm)
m := self.send.Run(self.route.Routes(), comm)
if m != nil {
self.log("info", self.Time(), "got a message", string([]byte(m.Body())))
}
if self.Time()%100 == 9 {
// self.log("info", self.Time(), "neighbors", self.hello.Neighbors())
// self.log("info", self.Time(), "reachable", self.route.Reachable())
// s := fmt.Sprintf("\nRoute Table (%v):\n", self.agent.Id())
// for i := uint32(1); i <= 8; i++ {
// if route, has := self.routes[i]; has {
// s += fmt.Sprint(route, "\n")
// }
// }
// self.log("info", s)
}
}
示例3: Turn
func (self *Simple) Turn(comm agent.Comm) {
if !comm.Move(agent.NewMove(1, 0)) {
fmt.Println("Move Failed!")
}
if !comm.Move(agent.NewMove(1, 0)) {
fmt.Println("Move Failed!")
}
return
}