Merge branch 'master' of https://git.wmi.amu.edu.pl/s440556/SZI2019SmieciarzWmi
This commit is contained in:
commit
9567999454
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,4 +4,4 @@ env
|
|||||||
.vscode
|
.vscode
|
||||||
*.swp
|
*.swp
|
||||||
linux_env
|
linux_env
|
||||||
Results/*
|
moveset_data.json
|
30
utilities.py
30
utilities.py
@ -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,16 +25,20 @@ 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':
|
||||||
with open(output_file, 'w') as f:
|
path = '\moveset_data.json'
|
||||||
try:
|
else:
|
||||||
results = json.loads(f)
|
path = '/moveset_data.json'
|
||||||
except:
|
output_file = os.path.normpath(os.getcwd()) + '\moveset_data.json'
|
||||||
results = {
|
with open(output_file, 'w') as f:
|
||||||
"moveset": []
|
try:
|
||||||
}
|
results = json.loads(f)
|
||||||
finally:
|
except:
|
||||||
results["moveset"].append(moveset)
|
results = {
|
||||||
json.dump(results, f, indent=2)
|
"moveset": []
|
||||||
print('Moveset saved to the file /Results/moveset_data.json')
|
}
|
||||||
|
finally:
|
||||||
|
results["moveset"].append(moveset)
|
||||||
|
json.dump(results, f, indent=2)
|
||||||
|
print('Moveset saved to the file moveset_data.json')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user