Projekt_Sztuczna_Inteligencja/mines/disarming/parameter_json.py

39 lines
851 B
Python

import json
import mine_parameters as param
import os
# this module is self contained, used to generate a json file
DIR_DATA = os.path.join("../../resources", "data")
# just to show, how mine parameters works
def param_presents():
mine = param.MineParameters()
print(mine.jsonifyable_dict())
json_mine = json.dumps(mine.jsonifyable_dict())
print(json_mine)
new_mine = param.MineParameters(json.loads(json_mine))
print(new_mine.get_parameters())
def generate_data(file_name: str, lines: int):
file = open(os.path.join(DIR_DATA, file_name), "w")
for x in range(lines):
new_params = json.dumps(param.MineParameters().jsonifyable_dict())
file.write(new_params)
file.write("\n")
file.close()
def main():
generate_data("params3.txt", 20000)
if __name__ == "__main__":
main()