import random from Global_variables import Global_variables as G_var from Package import Package from Package_types import Package_types from decision_tree.Decision_tree import DecisionTree class Packages_spawner: def __init__(self, window,enviroment_2d): self.window = window self.enviroment_2d = enviroment_2d def spawn_package(self): package_x = random.randrange(22, 26) package_y = random.randrange(1, 13) weekend = random.randint(0,1) package_type = random.choice(list(Package_types)) new_package = Package(self.window, package_x, package_y, package_type) self.enviroment_2d[package_x][package_y] = new_package sector_type = self.use_decision_tree(new_package, weekend) return sector_type def use_decision_tree(self, package, weekend): marking = package.type if marking == Package_types.fragile: marking = 0 elif marking == Package_types.priority: marking = 1 tree = DecisionTree(marking, weekend, package.company.popularity, package.company.payment_delay, package.payed_upfront, package.company.shipping_type) decision = tree.decision return decision