give unique r.name for each robot

This commit is contained in:
Stephen McQuay 2013-11-10 23:37:43 -08:00
parent 5361cc276e
commit e4bbd4a0f4
2 changed files with 8 additions and 3 deletions

View File

@ -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,

View File

@ -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,
@ -37,6 +39,7 @@ func NewRobot(
}
r := &robot{
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,
},
}