-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (40 loc) · 1.13 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from globalVars import *
from getTrack import *
import car
from sim import *
import neat
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ("yes", "true", "t", "y", "1"):
return True
elif v.lower() in ("no", "false", "f", "n", "0"):
return False
else:
raise argparse.ArgumentTypeError("Boolean value expected.")
def main(debug=False):
config = neat.config.Config(
neat.DefaultGenome,
neat.DefaultReproduction,
neat.DefaultSpeciesSet,
neat.DefaultStagnation,
"./neat_config.txt",
)
pop = neat.Population(config)
pop.add_reporter(neat.StdOutReporter(True))
stats = neat.StatisticsReporter()
pop.add_reporter(stats)
set_debug_flag(debug)
pop.run(run_sim, 1000)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Procedural racetrack generator")
parser.add_argument(
"--debug",
type=str2bool,
nargs="?",
const=True,
default=False,
help="Show racetrack generation steps",
)
args = parser.parse_args()
main(debug=args.debug)