dooooooduo

COMP3620 - ASS0_Q4_Part2_test

Mar 3rd, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import os
  2. import json
  3. import time
  4.  
  5. def main ():
  6.     total_score = 0
  7.     for i in range(1, 6):
  8.         print("Scenario {} - ".format(i), end = '')
  9.  
  10.         results = [0, 0]
  11.         stime   = time.time()
  12.  
  13.         for key, agent in enumerate(["HealthAgent", "SmartHealthAgent"]):
  14.             os.system("python3 disease_simulation.py -s exercise4_maps/scenario{}.scn -H 100 -n 100 -a {} > /dev/null".format(i, agent))
  15.             with open("scenario{}.results.json".format(i)) as json_data:
  16.                 results[key] = json.load(json_data)["average_score"]
  17.  
  18.         raw_score    = max(1, 4 * (1 - (100 - results[1]) / (100 - results[0])))
  19.         total_score += raw_score
  20.  
  21.         print(("HealthAgent: {:.2f}  " +
  22.                "SmartHealthAgent: {:.2f}  " +
  23.                "Raw mark: {:.2f}  " +
  24.                "Time elapsed: {:.4f} seconds").format(results[0], results[1], raw_score, time.time() - stime))
  25.  
  26.     print("Raw mark:   {:.2f}".format(total_score))
  27.     print("Total mark: {}".format(round(total_score)))
  28.  
  29. if __name__ == "__main__":
  30.     main()
Add Comment
Please, Sign In to add comment