def main(args): oldAgentDir="" experianceDir="" newAgentDir="" trainingIterations="" try: options, arugments= getopt.getopt(args,"hi:o:e:l:") except getopt.GetoptError: print("trainNewAgent.py i- <inputDirecory> -o <outputDirectory> -e <experianceDirectory> -l <trainingIterations>") sys.exit(2) for opt, arg in options: if opt =="-h": print("trainNewAgent.py -i <inputDirecory> -o <outputDirectory> -e <experianceDirectory> -l <trainingIterations>") sys.exit() elif opt=="-i": oldAgentDir=arg elif opt=="-o": newAgentDir=arg elif opt=="-e": experianceDir=arg elif opt=="-l": trainingIterations=arg #main code pathList=os.path.abspath("").split("\\") pathList=pathList[:-2] path="" for pathL in pathList: path+=pathL+"\\" path=path[:-1] agent=Agent(path+"/gameData/agentConfig.json") agent.importAgent(path+"/"+oldAgentDir) agent.loadTrainingData(path+"/"+experianceDir) iter=1 try: iter=int(trainingIterations) except: pass for i in range(iter): print("Training:",i) agent.trainAgent() #export agent agent.export(path+"/"+newAgentDir) exit(1)
from Agent.Agent import Agent from Network.Exceptions import * import os.path pathList = os.path.abspath("").split("\\") pathList = pathList[:-2] path = "" for pathL in pathList: path += pathL + "\\" path = path[:-1] agent = Agent(path + "/gameData/agentConfig.json") agent.createNewAgent() agent.export(path + "/playData/agents/a0B")