windows update

This commit is contained in:
michalStarski 2019-05-21 23:51:03 +02:00
parent 7181bb133a
commit 28d38d7589
2 changed files with 18 additions and 14 deletions

2
.gitignore vendored
View File

@ -4,4 +4,4 @@ env
.vscode .vscode
*.swp *.swp
linux_env linux_env
Results/* moveset_data.json

View File

@ -1,6 +1,6 @@
from config import GRID_WIDTH, GRID_HEIGHT from config import GRID_WIDTH, GRID_HEIGHT
from DataModels.Road import Road from DataModels.Road import Road
import json, os import json, os, platform
def movement(environment, x ,y): def movement(environment, x ,y):
movement = { movement = {
@ -25,7 +25,11 @@ def check_moves(environment, x,y,direction=None):
return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y) and dir != movement(environment,x,y)[1][direction]]) return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y) and dir != movement(environment,x,y)[1][direction]])
def save_moveset(moveset): def save_moveset(moveset):
output_file = os.path.normpath(os.getcwd()) + '/Results/moveset_data.json' if platform.system() == 'Windows':
path = '\moveset_data.json'
else:
path = '/moveset_data.json'
output_file = os.path.normpath(os.getcwd()) + '\moveset_data.json'
with open(output_file, 'w') as f: with open(output_file, 'w') as f:
try: try:
results = json.loads(f) results = json.loads(f)
@ -36,5 +40,5 @@ def save_moveset(moveset):
finally: finally:
results["moveset"].append(moveset) results["moveset"].append(moveset)
json.dump(results, f, indent=2) json.dump(results, f, indent=2)
print('Moveset saved to the file /Results/moveset_data.json') print('Moveset saved to the file moveset_data.json')