AIprojekt-wozek/Package.py

44 lines
1.6 KiB
Python

import glob2
import pygame
import random
from Field import Field
from Global_variables import Global_variables as G_var
from Types_colors import Types_colors
from Package_types import Package_types
import math
from CompanyFactory import CompanyFactory
from decision_tree.Decision_tree import DecisionTree
from neural_network.NeuralNetwork import NeuralNetwork
class Package(Field):
def __init__(self, window, x, y, type):
Field.__init__(self, window, x, y)
# self.mark_image = self.get_marking_photo()
self.type = type
self.company = CompanyFactory()
self.payed_upfront = random.randint(0,1)
self.is_placed = False
weekend = random.randint(0,1)
self.sector = self.use_decision_tree(weekend)
def use_decision_tree(self, weekend):
marking = self.type
if marking == Package_types.fragile:
marking = 0
elif marking == Package_types.priority:
marking = 1
tree = DecisionTree(marking, weekend, self.company.popularity,
self.company.payment_delay, self.payed_upfront,
self.company.shipping_type)
decision = tree.decision
# print("Decision tree: ", decision)
return decision
def draw(self):
self.color = Types_colors.get_package_color(self.type)
# self.color = (110,64,48)
block = pygame.Rect(self.x * G_var().RECT_SIZE, self.y *
G_var().RECT_SIZE, G_var().RECT_SIZE, G_var().RECT_SIZE)
pygame.draw.rect(self.window, self.color, block)