From 87142c0cb5f42d877327c357497a5be6f3c5dbd0 Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 9 Apr 2023 00:37:54 +0200 Subject: Should work, lol --- src/config.go | 76 ----------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 src/config.go (limited to 'src/config.go') 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 -} -- cgit 1.4.1