Add new arg "delay" to delay board updates by x milliseconds (#48)
Co-authored-by: Brad Van Vugt <1531419+bvanvugt@users.noreply.github.com>
This commit is contained in:
parent
d42f5f46cc
commit
97fbcb3376
2 changed files with 7 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ Usage:
|
||||||
battlesnake play [flags]
|
battlesnake play [flags]
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
|
-d, --delay int32 Turn Delay in Milliseconds (default 0)
|
||||||
-g, --gametype string Type of Game Rules (default "standard")
|
-g, --gametype string Type of Game Rules (default "standard")
|
||||||
-H, --height int32 Height of Board (default 11)
|
-H, --height int32 Height of Board (default 11)
|
||||||
-h, --help help for play
|
-h, --help help for play
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ var Sequential bool
|
||||||
var GameType string
|
var GameType string
|
||||||
var ViewMap bool
|
var ViewMap bool
|
||||||
var Seed int64
|
var Seed int64
|
||||||
|
var TurnDelay int32
|
||||||
|
|
||||||
var playCmd = &cobra.Command{
|
var playCmd = &cobra.Command{
|
||||||
Use: "play",
|
Use: "play",
|
||||||
|
|
@ -121,6 +122,7 @@ func init() {
|
||||||
playCmd.Flags().StringVarP(&GameType, "gametype", "g", "standard", "Type of Game Rules")
|
playCmd.Flags().StringVarP(&GameType, "gametype", "g", "standard", "Type of Game Rules")
|
||||||
playCmd.Flags().BoolVarP(&ViewMap, "viewmap", "v", false, "View the Map Each Turn")
|
playCmd.Flags().BoolVarP(&ViewMap, "viewmap", "v", false, "View the Map Each Turn")
|
||||||
playCmd.Flags().Int64VarP(&Seed, "seed", "r", time.Now().UTC().UnixNano(), "Random Seed")
|
playCmd.Flags().Int64VarP(&Seed, "seed", "r", time.Now().UTC().UnixNano(), "Random Seed")
|
||||||
|
playCmd.Flags().Int32VarP(&TurnDelay, "delay", "d", 0, "Turn Delay in Milliseconds")
|
||||||
}
|
}
|
||||||
|
|
||||||
var run = func(cmd *cobra.Command, args []string) {
|
var run = func(cmd *cobra.Command, args []string) {
|
||||||
|
|
@ -156,6 +158,10 @@ var run = func(cmd *cobra.Command, args []string) {
|
||||||
} else {
|
} else {
|
||||||
log.Printf("[%v]: State: %v OutOfBounds: %v\n", Turn, state, outOfBounds)
|
log.Printf("[%v]: State: %v OutOfBounds: %v\n", Turn, state, outOfBounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if TurnDelay > 0 {
|
||||||
|
time.Sleep(time.Duration(TurnDelay) * time.Millisecond)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if GameType == "solo" {
|
if GameType == "solo" {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue