Projekt_Sztuczna_Inteligencja/decision_tree/mine_parameters.py

46 lines
1.4 KiB
Python
Raw Normal View History

import random
import hash_function as hf
class MineParameters:
def __init__(self, jdict=None, mine_type=None):
if jdict is None:
self.mine_type = random.choice(list(hf.TypeHash))
self.danger_cls = random.choice(list(hf.DangerClassHash))
self.series = random.choice(list(hf.SeriesHash))
self.indicator = random.choice(list(hf.IndicatorHash))
self.specificity = random.choice(list(hf.SpecificityHash))
else:
self.mine_type = jdict["mine_type"]
self.danger_cls = jdict["danger_cls"]
self.series = jdict["series"]
self.specificity = jdict["specificity"]
self.indicator = jdict["indicator"]
if mine_type is not None:
self.mine_type = mine_type
def jsonifyable_dict(self):
wire = hf.get_wire_from_enums(
self.mine_type, self.danger_cls, self.series,
self.indicator, self.specificity
)
jdict = {
"mine_type": self.mine_type.value[1],
"danger_cls": self.danger_cls.value[1],
"series": self.series.value[1],
"specificity": self.specificity.value[1],
"indicator": self.indicator.value[1],
"wire": wire.value[1]
}
return jdict
def get_parameters(self):
return self.mine_type, self.danger_cls, self.series,\
self.specificity, self.indicator