diff options
author | Emile <git@emile.space> | 2023-04-09 00:37:54 +0200 |
---|---|---|
committer | Emile <git@emile.space> | 2023-04-09 00:37:54 +0200 |
commit | 87142c0cb5f42d877327c357497a5be6f3c5dbd0 (patch) | |
tree | e4b2094315dc16fe680ad0a15587bb0671dea636 /src/config.go | |
parent | 907f5bc763959c3cc2196329a600a8afedebac5a (diff) |
Should work, lol
Diffstat (limited to 'src/config.go')
-rw-r--r-- | src/config.go | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/src/config.go b/src/config.go deleted file mode 100644 index 706d29e..0000000 --- a/src/config.go +++ /dev/null @@ -1,76 +0,0 @@ -package main - -import ( - "flag" - "time" - - "github.com/sirupsen/logrus" -) - -// parseConfig parses the config needed to start the game -func parseConfig() Config { - - // bot configs - arch := flag.String("arch", "x86", "bot architecture (mips|arm|x86)") - bits := flag.Int("bits", 32, "bot bitness (8|16|32|64)") - maxProgSize := flag.Int("maxProgSize", 64, "the maximum bot size") - memPerBot := flag.Int("memPerBot", 512, "the amount of memory each bot should add to the arena") - gameRoundDuration := flag.Duration("t", 250*time.Millisecond, "The duration of a round") - - v := flag.Bool("v", false, "info") - vv := flag.Bool("vv", false, "debug") - vvv := flag.Bool("vvv", false, "trace") - - // parse the flags - flag.Parse() - - if *v == true { - logrus.SetLevel(logrus.InfoLevel) - } else if *vv == true { - logrus.SetLevel(logrus.DebugLevel) - } else if *vvv == true { - logrus.SetLevel(logrus.TraceLevel) - } else { - logrus.SetLevel(logrus.WarnLevel) - } - - // parse all trailing command line arguments as path to bot sourcecode - amountOfBots := flag.NArg() - - memsize := amountOfBots * *memPerBot - - logrus.WithFields(logrus.Fields{ - "mem per bot": *memPerBot, - "amountOfBots": amountOfBots, - "memsize": memsize, - }).Infof("Loaded config") - - // define a config to return - config := Config{ - Arch: *arch, - Bits: *bits, - Memsize: memsize, - MaxProgSize: *maxProgSize, - AmountOfBots: amountOfBots, - GameRoundDuration: *gameRoundDuration, - } - - return config -} - -// define bots defines the bots given via command line arguments -func defineBots(config *Config) { - - logrus.Info("Defining the bots") - - // define a list of bots by parsing the command line arguments one by one - var bots []Bot - for i := 0; i < config.AmountOfBots; i++ { - bot := Bot{ - Path: flag.Arg(i), - } - bots = append(bots, bot) - } - - config.Bots = bots -} |