I've done quite a bit of searching but I'm struggling to find a solution to my specific problem. I'm sure it's a pretty simple solution.
I am taking the best agent from a field in card playing game and playing it against other agents. The agent evolves in generations. So in each iteration I want to do the following:
create file named "results+generation number" i.e. results2
then I want to add the output from each function call on a new line
results from playing x = outputs1
results from playing y = outputs2
So I did indeed find a solution to the question but I'm running into another issue. When I run the program once, nothing is saved except the file name. The second time, the results from the first and so on.
f = open("results_{0}.txt".format(counter),'w')
f.write("Agent A vs. Champion\n"+"Champion wins = "+str(winsA1)+" Agent A wins = "+str(winsB1))
f.write("\n\nAgent B vs. Champion\n"+"Champion wins = "+str(winsA2)+" Agent B wins = "+str(winsB2))
f.write("\n\nRandom vs. Champion\n"+"Champion wins = "+str(winsA3)+" Random wins = "+str(winsB3))
f.close