-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create config struct and hydration from CLI args
- Loading branch information
Showing
2 changed files
with
26 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
) | ||
|
||
type Cfg struct { | ||
boardX, boardY, generations, intervalSecs int | ||
} | ||
|
||
func Config() Cfg { | ||
|
||
c := Cfg{} | ||
|
||
flag.IntVar(&c.boardX, "x", 50, "Size of row for the board") | ||
flag.IntVar(&c.boardY, "y", 5, "Size of col for the board") | ||
flag.IntVar(&c.generations, "g", 40, "Num of generations to process") | ||
flag.IntVar(&c.intervalSecs, "i", 1, "Interval secs for board generation") | ||
flag.Parse() | ||
|
||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
package main | ||
|
||
func main() { | ||
b := Board{ | ||
{false, false, false, false, true}, | ||
{false, true, false, false, true}, | ||
{false, true, true, false, false}, | ||
{false, true, false, false, true}, | ||
} | ||
g := NewGame(b, 10, 1) | ||
|
||
cfg := Config() | ||
b := RandomBoard(cfg.boardX, cfg.boardY) | ||
g := NewGame(b, cfg.generations, cfg.intervalSecs) | ||
g.Run() | ||
} |