summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-24 23:25:34 -0400
committerdemo <demo@antix1>2026-05-24 23:25:34 -0400
commit54294466d5624b6b0ce84c20f118070fa597daa8 (patch)
tree5849b38d84d9dec08943438be1f117087b3adbbd
parentb66bc6e6234e00ebd2e553eb9f43910d649e890f (diff)
feat: make number of players configurable
-rw-r--r--main.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/main.go b/main.go
index bdc4626..00087eb 100644
--- a/main.go
+++ b/main.go
@@ -12,16 +12,15 @@ type Ball struct{ hits int }
func main() {
numSecs := flag.Int("s", 1, "Number of seconds game should last")
+ numPlayers := flag.Int("p", 2, "Number of players")
flag.Parse()
- game(*numSecs)
+ game(*numSecs, *numPlayers)
}
-func game(numSecs int) {
+func game(numSecs, numPlayers int) {
var wg sync.WaitGroup
- // FIXME: make this a flag.
- const numPlayers = 7
players := make([]chan Ball, numPlayers+1)
players[0] = make(chan Ball)