Szkielet szkieletu

This commit is contained in:
andrzej 2020-04-02 15:25:15 +02:00
commit 89b63b585c
4 changed files with 101 additions and 0 deletions

5
agent.py Normal file
View File

@ -0,0 +1,5 @@
class Forklifter:
def __init__(self, start_x, start_y):
self.x = start_x
self.y = start_y

14
attributes.py Normal file
View File

@ -0,0 +1,14 @@
from enum import Enum
class PackSize(Enum):
ALL = 0
SMALL = 1
MEDIUM = 2
LARGE = 3
HUGE = 4
PACK_CATEGORIES = {
'general',
'freezed',
}

22
main.py Normal file
View File

@ -0,0 +1,22 @@
import pygame
import warehouse
from attributes import PackSize
WINDOW_SIZE = (1000, 800)
COLORS = [(255, 255, 255), (0, 0, 0)]
def main():
pygame.init()
display = pygame.display.set_mode(WINDOW_SIZE)
warehouse_map = warehouse.Warehouse(50, 50)
# import pdb
# pdb.set_trace()
print(warehouse_map)
for t in warehouse_map.tiles[0][:10]:
print(t)
while True:
pygame.display.flip()
if __name__ == '__main__':
main()

60
warehouse.py Normal file
View File

@ -0,0 +1,60 @@
from attributes import PackSize
import random
class CategoryData:
def __init__(self, name, passable=False, can_store=True, location='general', pack_size=PackSize.ALL):
self.name = name
self.passable = passable
self.can_store = can_store
self.location = location
self.pack_size = pack_size
def __repr__(self):
return self.name
class Pack:
def __init__(self, size, categ='general'):
self.size = size
self.category = categ
CATEGORY = {
'floor': CategoryData('Floor', True, False), #lava
'rack': CategoryData('Rack', False, True),
# 'freezer': CategoryData('Freezer', False, True, location='cold_room')
}
class Warehouse:
def __init__(self, width, length):
self.width = width
self.length = length
self.tiles = self.generate_map()
def __str__(self):
return "Magazyn {}x{}".format(self.width, self.length)
def generate_map(self):
warehouse_tiles = []
categories = list(CATEGORY.keys())
for x in range(self.width):
row = [Tile('floor', x, y) for y in range(self.length)]
warehouse_tiles.append(row)
# warehouse_tiles = self.create_racks(20, warehouse_tiles)
return warehouse_tiles
# def create_racks(self, number_of_racks=0, warehouse_tiles=[]):
class Tile:
def __init__(self, category, x_position, y_position):
self.category = CATEGORY.get(category, CATEGORY['floor'])
self.x_position = x_position
self.y_position = y_position
def __str__(self):
return "Tile type: {} on position ({},{})".format(self.category, self.x_position, self.y_position)
def __repr__(self):
return "Tile type: {} on position ({},{})".format(self.category, self.x_position, self.y_position)