Skip to content

Commit

Permalink
Merge pull request #32 from ByteArena/feat-specify-host-viz
Browse files Browse the repository at this point in the history
feat: add option to specify host for the viz server
  • Loading branch information
Sven SAULEAU authored Dec 21, 2017
2 parents 5fd2c47 + 619ba61 commit 4789676
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/ba/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func makeapp() *cli.App {
cli.StringFlag{Name: "host", Value: "", Usage: "IP serving the trainer; required"},
cli.StringSliceFlag{Name: "agent", Usage: "Agent images"},
cli.IntFlag{Name: "port", Value: 8080, Usage: "Port serving the trainer"},
cli.StringFlag{Name: "viz-host", Value: "127.0.0.1", Usage: "Specify a host for the visualization server"},
cli.StringFlag{Name: "record-file", Value: "", Usage: "Destination file for recording the game"},
cli.StringFlag{Name: "map", Value: "hexagon", Usage: "Name of the map used by the trainer"},
cli.BoolFlag{Name: "no-browser", Usage: "Disable automatic browser opening at start"},
Expand All @@ -99,6 +100,7 @@ func makeapp() *cli.App {
host := c.String("host")
agents := c.StringSlice("agent")
port := c.Int("port")
vizhost := c.String("viz-host")
recordFile := c.String("record-file")
mapName := c.String("map")
nobrowser := c.Bool("no-browser")
Expand All @@ -111,6 +113,7 @@ func makeapp() *cli.App {
tps,
host,
port,
vizhost,
nobrowser,
recordFile,
agents,
Expand Down
5 changes: 3 additions & 2 deletions subcommand/train/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TrainAction(
tps int,
host string,
vizport int,
vizhost string,
nobrowser bool,
recordFile string,
agentimages []string,
Expand Down Expand Up @@ -224,7 +225,7 @@ func TrainAction(
vizgames[0] = viztypes.NewVizGame(game, gamedescription)

vizservice := visualization.NewVizService(
"127.0.0.1:"+strconv.Itoa(vizport),
vizhost+":"+strconv.Itoa(vizport),
mapName,
func() ([]*viztypes.VizGame, error) { return vizgames, nil },
recorder,
Expand All @@ -239,7 +240,7 @@ func TrainAction(
utils.FailWith(startErr)
}

url := "http://localhost:" + strconv.Itoa(vizport) + "/arena/1"
url := "http://" + vizhost + ":" + strconv.Itoa(vizport) + "/arena/1"

if !nobrowser {
open.Run(url)
Expand Down

0 comments on commit 4789676

Please sign in to comment.