Dodanie rodzaju towaru w paczce, oraz temperatury i wilgotności na polu w magazynie
This commit is contained in:
parent
45136dcea0
commit
23a8321e2d
1
agent.py
1
agent.py
@ -236,3 +236,4 @@ class Agent:
|
|||||||
pack.lays_on_field.capacity -= pack.size
|
pack.lays_on_field.capacity -= pack.size
|
||||||
pack.status = PackStatus.STORED
|
pack.status = PackStatus.STORED
|
||||||
self.warehouse.packages.append(pack)
|
self.warehouse.packages.append(pack)
|
||||||
|
print(tile.air_temperature, tile.humidity)
|
||||||
|
33
products_types.py
Normal file
33
products_types.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
PRODUCT_TYPES = {
|
||||||
|
"freezed": [
|
||||||
|
"frozen food",
|
||||||
|
"seeds",
|
||||||
|
"frozen liquids"
|
||||||
|
],
|
||||||
|
"fragile": [
|
||||||
|
"glass",
|
||||||
|
"porcelain",
|
||||||
|
"vials",
|
||||||
|
"phials",
|
||||||
|
"plate",
|
||||||
|
],
|
||||||
|
"keep_dry": [
|
||||||
|
"electronic",
|
||||||
|
"drugs",
|
||||||
|
"books",
|
||||||
|
"clothes",
|
||||||
|
"cardboard"
|
||||||
|
],
|
||||||
|
"normal": [
|
||||||
|
"cosmetics",
|
||||||
|
"wood",
|
||||||
|
"metal",
|
||||||
|
"plastic"
|
||||||
|
],
|
||||||
|
"flammable": [
|
||||||
|
"gasoline",
|
||||||
|
"lacquer",
|
||||||
|
"ammo"
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
50
warehouse.py
50
warehouse.py
@ -1,4 +1,5 @@
|
|||||||
from attributes import PackStatus
|
from attributes import PackStatus
|
||||||
|
from products_types import PRODUCT_TYPES
|
||||||
import random
|
import random
|
||||||
import queue
|
import queue
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
@ -20,6 +21,8 @@ class Pack:
|
|||||||
def __init__(self, size=5, categ='general', lays_on_field=None):
|
def __init__(self, size=5, categ='general', lays_on_field=None):
|
||||||
self.size = size
|
self.size = size
|
||||||
self.category = categ
|
self.category = categ
|
||||||
|
self.products_inside = self.set_products_inside()
|
||||||
|
|
||||||
assert isinstance(lays_on_field, Tile), AssertionError("Attribute lays_on_field must be a Tile object! You know, package cannot lay in void :)")
|
assert isinstance(lays_on_field, Tile), AssertionError("Attribute lays_on_field must be a Tile object! You know, package cannot lay in void :)")
|
||||||
self.lays_on_field = lays_on_field
|
self.lays_on_field = lays_on_field
|
||||||
self.status = self.set_status()
|
self.status = self.set_status()
|
||||||
@ -35,6 +38,26 @@ class Pack:
|
|||||||
status = PackStatus.STORED
|
status = PackStatus.STORED
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
def set_products_inside(self):
|
||||||
|
seed = random.random()
|
||||||
|
products_category = None
|
||||||
|
if seed < 0.6:
|
||||||
|
products_category = "normal"
|
||||||
|
elif 0.6 <= seed < 0.75:
|
||||||
|
products_category = "keep_dry"
|
||||||
|
elif 0.75 <= seed < 0.9:
|
||||||
|
products_category = "fragile"
|
||||||
|
elif 0.9 <= seed < 0.98:
|
||||||
|
products_category = "freezed"
|
||||||
|
elif 0.96 <= seed <= 1.0:
|
||||||
|
products_category = "flammable"
|
||||||
|
|
||||||
|
products_in_category = PRODUCT_TYPES.get(products_category, ["food"])
|
||||||
|
product_inside = random.choice(products_in_category)
|
||||||
|
print(product_inside)
|
||||||
|
return product_inside
|
||||||
|
|
||||||
|
|
||||||
CATEGORY = {
|
CATEGORY = {
|
||||||
'floor': CategoryData('Floor', True, False), #lava
|
'floor': CategoryData('Floor', True, False), #lava
|
||||||
'rack': CategoryData('Rack', False, True),
|
'rack': CategoryData('Rack', False, True),
|
||||||
@ -53,7 +76,10 @@ class Warehouse:
|
|||||||
self.no_of_packages = no_of_packages
|
self.no_of_packages = no_of_packages
|
||||||
self.generate_racks()
|
self.generate_racks()
|
||||||
self.open_isolated_areas()
|
self.open_isolated_areas()
|
||||||
|
self.set_temperature(20, 30)
|
||||||
|
self.set_humidity()
|
||||||
self.create_fridge(10)
|
self.create_fridge(10)
|
||||||
|
print([row[0].air_temperature for row in self.tiles])
|
||||||
self.packages = self.place_packages(no_of_packages)
|
self.packages = self.place_packages(no_of_packages)
|
||||||
self.tiles[1][1] = Tile('floor', 1, 1)
|
self.tiles[1][1] = Tile('floor', 1, 1)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -97,6 +123,21 @@ class Warehouse:
|
|||||||
node_y = next_node.y_position
|
node_y = next_node.y_position
|
||||||
self.tiles[node_x][node_y] = Tile('rack', node_x, node_y)
|
self.tiles[node_x][node_y] = Tile('rack', node_x, node_y)
|
||||||
|
|
||||||
|
def set_temperature(self, min_temperature=20, max_temperature=30):
|
||||||
|
for num, row in enumerate(self.tiles):
|
||||||
|
row_temperature = min_temperature + round(num/2)
|
||||||
|
for cell in row:
|
||||||
|
cell.air_temperature = row_temperature
|
||||||
|
|
||||||
|
def set_humidity(self, min_humidity=0.2, max_humidity=0.7):
|
||||||
|
current_humidity = min_humidity
|
||||||
|
for y in range(self.height):
|
||||||
|
current_humidity += (0.1/4)
|
||||||
|
for x in range(self.width):
|
||||||
|
self.tiles[x][y].humidity = round(current_humidity, 1)
|
||||||
|
# print(round(current_humidity, 1))
|
||||||
|
|
||||||
|
|
||||||
def create_fridge(self, size):
|
def create_fridge(self, size):
|
||||||
x_corner = random.choice(['left', 'right'])
|
x_corner = random.choice(['left', 'right'])
|
||||||
y_corner = random.choice(['top', 'bottom'])
|
y_corner = random.choice(['top', 'bottom'])
|
||||||
@ -124,9 +165,9 @@ class Warehouse:
|
|||||||
for num, row in enumerate(rows, start_x):
|
for num, row in enumerate(rows, start_x):
|
||||||
for index, tile in enumerate(row[start_y:end_y], start_y):
|
for index, tile in enumerate(row[start_y:end_y], start_y):
|
||||||
if self.tiles[num][index].category.name == "Floor":
|
if self.tiles[num][index].category.name == "Floor":
|
||||||
self.tiles[num][index] = Tile('fridge_floor', num, index)
|
self.tiles[num][index] = Tile('fridge_floor', num, index, temperature=-5)
|
||||||
else:
|
else:
|
||||||
self.tiles[num][index] = Tile('fridge', num, index, capacity=random.randrange(10, 12))
|
self.tiles[num][index] = Tile('fridge', num, index, capacity=random.randrange(10, 12), temperature=-15)
|
||||||
|
|
||||||
def get_not_rack_nodes(self, node_x, node_y):
|
def get_not_rack_nodes(self, node_x, node_y):
|
||||||
adjacent_tiles = self.get_adjacent_tiles(node_x, node_y)
|
adjacent_tiles = self.get_adjacent_tiles(node_x, node_y)
|
||||||
@ -181,6 +222,7 @@ class Warehouse:
|
|||||||
self.tiles[bottom_left.x][bottom_left.y]
|
self.tiles[bottom_left.x][bottom_left.y]
|
||||||
]
|
]
|
||||||
return diagonals
|
return diagonals
|
||||||
|
|
||||||
def get_all_racks(self):
|
def get_all_racks(self):
|
||||||
""":return list of Tile objects"""
|
""":return list of Tile objects"""
|
||||||
racks = []
|
racks = []
|
||||||
@ -247,10 +289,12 @@ class Warehouse:
|
|||||||
return wall
|
return wall
|
||||||
|
|
||||||
class Tile:
|
class Tile:
|
||||||
def __init__(self, category, x_position, y_position, capacity=10):
|
def __init__(self, category, x_position, y_position, capacity=10, temperature: int=24, humidity: float=0.3):
|
||||||
self.category = CATEGORY.get(category, CATEGORY['floor'])
|
self.category = CATEGORY.get(category, CATEGORY['floor'])
|
||||||
self.x_position = x_position
|
self.x_position = x_position
|
||||||
self.y_position = y_position
|
self.y_position = y_position
|
||||||
|
self.air_temperature = temperature
|
||||||
|
self.humidity = humidity
|
||||||
self.capacity = capacity
|
self.capacity = capacity
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user