give unique r.name for each robot
This commit is contained in:
parent
5361cc276e
commit
e4bbd4a0f4
2
main.go
2
main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"sync"
|
||||
@ -43,6 +44,7 @@ func main() {
|
||||
*server,
|
||||
*port,
|
||||
gameName,
|
||||
fmt.Sprintf("%s%d", *botname, i),
|
||||
*hp,
|
||||
*speed,
|
||||
*acceleration,
|
||||
|
9
robot.go
9
robot.go
@ -19,12 +19,14 @@ type robot struct {
|
||||
ws *websocket.Conn
|
||||
game GameParam
|
||||
playerId string
|
||||
name string
|
||||
}
|
||||
|
||||
func NewRobot(
|
||||
server string,
|
||||
port int,
|
||||
gameName string,
|
||||
botName string,
|
||||
hp,
|
||||
speed,
|
||||
acceleration,
|
||||
@ -36,7 +38,8 @@ func NewRobot(
|
||||
return nil, errors.New(fmt.Sprintf("connection failure: %s", err))
|
||||
}
|
||||
r := &robot{
|
||||
ws: ws,
|
||||
ws: ws,
|
||||
name: botName,
|
||||
}
|
||||
|
||||
// XXX: update with missing fields
|
||||
@ -84,7 +87,7 @@ func (r *robot) negociate(req StatsRequest, gameName string) (err error) {
|
||||
Name string `json:"name"`
|
||||
Useragent string `json:"useragent"`
|
||||
}{
|
||||
Name: *botname,
|
||||
Name: r.name,
|
||||
Useragent: "gobot",
|
||||
Type: "robot",
|
||||
})
|
||||
@ -101,7 +104,7 @@ func (r *robot) negociate(req StatsRequest, gameName string) (err error) {
|
||||
conf := ClientConfig{
|
||||
ID: gameName,
|
||||
Stats: map[string]StatsRequest{
|
||||
*botname: req,
|
||||
r.name: req,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user