Split out binary from library
I still want to do a few things: - move common hackerbot code to a package called hackerbot - make the stuff in here more trivially usable outside of this repo
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"bitbucket.org/hackerbots/botclient"
|
||||
"bitbucket.org/hackerbots/botserv"
|
||||
)
|
||||
|
||||
var hp = flag.Int("hp", 50, "")
|
||||
var speed = flag.Int("speed", 50, "")
|
||||
var acceleration = flag.Int("acceleration", 50, "")
|
||||
var scannerRadius = flag.Int("srad", 50, "scanner radius")
|
||||
var turnSpeed = flag.Int("omega", 50, "turn speed")
|
||||
var fireRate = flag.Int("fire-rate", 50, "scanner radius")
|
||||
var weaponRadius = flag.Int("wrad", 50, "weapon radius")
|
||||
var weaponDamage = flag.Int("wdamage", 50, "weapons umph")
|
||||
var weaponSpeed = flag.Int("wspeed", 50, "weapons speed")
|
||||
|
||||
// XXX: add TurnSpeed, WeaponDamage, WeaponSpeed
|
||||
|
||||
var server = flag.String("server", "localhost", "server hostname")
|
||||
var port = flag.Int("port", 8666, "server port")
|
||||
|
||||
var botname = flag.String("name", "gobot", "the name that other players will see")
|
||||
|
||||
var botcount = flag.Int("bots", 1, "number of bots to spin up")
|
||||
|
||||
var verbose = flag.Bool("verbose", false, "run verbosly")
|
||||
var forceJSON = flag.Bool("json", false, "force json encoding")
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var gameName string
|
||||
flag.Parse()
|
||||
if flag.NArg() < 1 {
|
||||
gameName = "debug"
|
||||
} else {
|
||||
gameName = flag.Arg(0)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < *botcount; i++ {
|
||||
r := &botclient.Robot{
|
||||
Server: *server,
|
||||
Port: *port,
|
||||
Name: fmt.Sprintf("%s%d", *botname, i),
|
||||
GameName: gameName,
|
||||
// XXX: update with missing fields
|
||||
StatsReq: botserv.StatsRequest{
|
||||
Hp: *hp,
|
||||
Speed: *speed,
|
||||
Acceleration: *acceleration,
|
||||
ScannerRadius: *scannerRadius,
|
||||
TurnSpeed: *turnSpeed,
|
||||
FireRate: *fireRate,
|
||||
WeaponRadius: *weaponRadius,
|
||||
WeaponDamage: *weaponDamage,
|
||||
WeaponSpeed: *weaponSpeed,
|
||||
},
|
||||
Wg: &wg,
|
||||
KnownObstacles: make(map[string]botserv.Obstacle),
|
||||
}
|
||||
wg.Add(1)
|
||||
go r.Play()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user