Compare commits
5 Commits
c8bcea171e
...
24f4c60e37
Author | SHA1 | Date | |
---|---|---|---|
24f4c60e37 | |||
|
d8e34ad65b | ||
|
a1f2e4b298 | ||
|
f79fa2ee66 | ||
|
1e5a1b9254 |
25
garbage.py
25
garbage.py
@ -1,19 +1,38 @@
|
||||
from enum import Enum
|
||||
|
||||
class GarbageType (Enum):
|
||||
|
||||
class GarbageType(Enum):
|
||||
PAPER = 0,
|
||||
PLASTIC_AND_METAL = 1
|
||||
GLASS = 3
|
||||
BIO = 4
|
||||
MIXED = 5
|
||||
|
||||
|
||||
class Garbage:
|
||||
img: str
|
||||
shape: str
|
||||
flexibility: str
|
||||
does_smell: str
|
||||
weight: str
|
||||
size: str
|
||||
color: str
|
||||
softness: str
|
||||
does_din: str
|
||||
|
||||
def __init__(self, img: str) -> None:
|
||||
def __init__(self, img: str, shape: str, flexibility: str, does_smell: str, weight: str, size: str, color: str, softness: str, does_din: str) -> None:
|
||||
self.img = img
|
||||
self.shape = shape
|
||||
self.flexibility = flexibility
|
||||
self.does_smell = does_smell
|
||||
self.weight = weight
|
||||
self.size = size
|
||||
self.color = color
|
||||
self.softness = softness
|
||||
self.does_din = does_din
|
||||
|
||||
class RecognizedGarbage (Garbage):
|
||||
|
||||
class RecognizedGarbage(Garbage):
|
||||
garbage_type: GarbageType
|
||||
|
||||
def __init__(self, src: Garbage, garbage_type: GarbageType) -> None:
|
||||
|
@ -3,6 +3,7 @@ from typing import List, Tuple
|
||||
from gameContext import GameContext
|
||||
from gridCellType import GridCellType
|
||||
|
||||
|
||||
class GarbageCan:
|
||||
position: Tuple[int, int]
|
||||
garbage: List[Garbage]
|
||||
@ -19,6 +20,7 @@ class GarbageCan:
|
||||
def remove_garbage(self, garbage: Garbage) -> None:
|
||||
self.garbage.remove(garbage)
|
||||
|
||||
|
||||
def render(self, game_context: GameContext) -> None:
|
||||
game_context.render_in_cell(self.position, "imgs/container.png")
|
||||
game_context.grid[self.position] = GridCellType.GARBAGE_CAN
|
29
machine_learning/garbage_infill.csv
Normal file
29
machine_learning/garbage_infill.csv
Normal file
@ -0,0 +1,29 @@
|
||||
Shape,Flexibility,DoesSmell,Weight,Size,Color,Softness,DoesDin
|
||||
Irregular,High,No,High,Medium,Dark,Low,Yes
|
||||
Longitiudonal,Low,No,Low,Low,Light,Medium,Yes
|
||||
Longitiudonal,Medium,No,Medium,Low,Dark,High,No
|
||||
Longitiudonal,Low,No,Medium,Low,Dark,High,Yes
|
||||
Round,Low,Yes,High,High,Transparent,High,Yes
|
||||
Irregular,Medium,Yes,High,Low,Transparent,Medium,No
|
||||
Longitiudonal,Medium,Yes,Low,High,Colorful,Medium,Yes
|
||||
Longitiudonal,Low,No,Low,Medium,Dark,Medium,Yes
|
||||
Flat,Medium,Yes,High,Low,Transparent,Low,Yes
|
||||
Irregular,Medium,Yes,High,Medium,Dark,Low,No
|
||||
Longitiudonal,High,No,Low,High,Colorful,Low,Yes
|
||||
Round,Medium,No,Medium,Medium,Dark,Low,No
|
||||
Longitiudonal,Medium,No,Medium,Medium,Transparent,High,No
|
||||
Flat,Medium,Yes,Low,Low,Light,Medium,No
|
||||
Flat,Medium,Yes,Medium,High,Light,Medium,No
|
||||
Flat,Low,No,High,Low,Dark,High,No
|
||||
Longitiudonal,Medium,Yes,High,High,Dark,Low,Yes
|
||||
Flat,Low,Yes,Low,Low,Transparent,Low,No
|
||||
Flat,Low,No,Medium,Low,Colorful,Low,No
|
||||
Longitiudonal,Low,Yes,High,Medium,Transparent,Low,No
|
||||
Longitiudonal,Low,No,Medium,High,Dark,Low,Yes
|
||||
Irregular,Medium,No,Medium,Medium,Light,Low,Yes
|
||||
Longitiudonal,High,No,High,High,Colorful,Low,No
|
||||
Flat,Low,No,Low,Low,Dark,High,No
|
||||
Flat,Low,Yes,Low,High,Dark,Low,Yes
|
||||
Irregular,Medium,Yes,High,High,Dark,Low,No
|
||||
Flat,High,No,High,Low,Dark,Medium,Yes
|
||||
Longitiudonal,High,Yes,Low,Medium,Colorful,Low,Yes
|
|
@ -49,3 +49,53 @@ Flat,Low,No,High,Low,Dark,Low,No,PLASTIC_AND_METAL
|
||||
Irregular,Low,Yes,Low,Low,Transparent,Medium,Yes,MIXED
|
||||
Flat,Low,No,High,High,Light,Low,No,PLASTIC_AND_METAL
|
||||
Longitiudonal,Medium,No,High,Medium,Dark,Low,Yes,PLASTIC_AND_METAL
|
||||
Round,Low,Yes,High,High,Transparent,High,No,MIXED
|
||||
Flat,Medium,No,Medium,Low,Transparent,Low,Yes,GLASS
|
||||
Longitiudonal,Low,No,High,Medium,Colorful,Medium,No,PLASTIC_AND_METAL
|
||||
Longitiudonal,Low,Yes,High,Medium,Colorful,High,No,BIO
|
||||
Longitiudonal,High,No,High,Medium,Transparent,Medium,Yes,PLASTIC_AND_METAL
|
||||
Irregular,Medium,No,Medium,Medium,Dark,High,No,PAPER
|
||||
Irregular,Low,No,Low,Medium,Light,Medium,Yes,PLASTIC_AND_METAL
|
||||
Round,High,No,Medium,Medium,Colorful,Low,Yes,PLASTIC_AND_METAL
|
||||
Irregular,High,No,High,High,Colorful,Low,No,MIXED
|
||||
Round,High,Yes,Medium,Medium,Transparent,High,Yes,PLASTIC_AND_METAL
|
||||
Flat,Medium,Yes,High,Medium,Colorful,Medium,Yes,BIO
|
||||
Round,High,No,Medium,Medium,Light,High,No,MIXED
|
||||
Flat,Low,Yes,Low,Low,Transparent,Medium,No,PLASTIC_AND_METAL
|
||||
Flat,Low,No,Medium,High,Light,High,Yes,MIXED
|
||||
Round,Medium,Yes,Medium,High,Transparent,High,No,MIXED
|
||||
Irregular,Medium,Yes,Medium,Medium,Colorful,Low,No,MIXED
|
||||
Flat,Low,Yes,Low,High,Light,Medium,No,BIO
|
||||
Flat,Low,Yes,Medium,Medium,Dark,Medium,No,MIXED
|
||||
Irregular,Low,No,High,High,Transparent,High,No,PLASTIC_AND_METAL
|
||||
Irregular,Low,Yes,Low,Medium,Dark,Low,Yes,GLASS
|
||||
Flat,Low,Yes,Low,Medium,Light,Low,No,GLASS
|
||||
Longitiudonal,Medium,Yes,Low,Medium,Dark,Low,Yes,PLASTIC_AND_METAL
|
||||
Irregular,Medium,No,Low,Low,Colorful,Medium,Yes,PAPER
|
||||
Round,High,No,Medium,Medium,Dark,High,No,MIXED
|
||||
Round,High,Yes,Low,High,Colorful,Low,No,MIXED
|
||||
Longitiudonal,Low,Yes,Low,Low,Transparent,Medium,Yes,MIXED
|
||||
Flat,Low,No,High,Medium,Light,Low,No,PLASTIC_AND_METAL
|
||||
Irregular,High,No,Low,Low,Colorful,High,Yes,PAPER
|
||||
Round,High,No,Medium,Medium,Colorful,High,No,MIXED
|
||||
Irregular,High,Yes,High,Low,Transparent,Medium,No,MIXED
|
||||
Round,Low,No,Medium,Low,Colorful,Low,No,GLASS
|
||||
Flat,Low,No,High,Low,Light,Low,No,MIXED
|
||||
Irregular,High,No,High,Medium,Light,Low,No,PLASTIC_AND_METAL
|
||||
Flat,Medium,Yes,High,Low,Dark,Low,No,MIXED
|
||||
Round,Medium,No,High,High,Colorful,Medium,No,PAPER
|
||||
Flat,Low,Yes,Medium,Low,Transparent,Medium,No,PLASTIC_AND_METAL
|
||||
Flat,Medium,No,Low,Medium,Transparent,High,No,MIXED
|
||||
Flat,Low,Yes,Medium,High,Colorful,Low,No,GLASS
|
||||
Longitiudonal,Low,Yes,High,Medium,Dark,High,No,BIO
|
||||
Longitiudonal,Medium,Yes,Low,High,Dark,High,Yes,BIO
|
||||
Round,High,No,Low,Low,Colorful,Medium,No,PAPER
|
||||
Longitiudonal,Medium,Yes,Medium,Low,Colorful,Low,Yes,PLASTIC_AND_METAL
|
||||
Longitiudonal,High,Yes,Low,Medium,Light,Medium,Yes,BIO
|
||||
Round,Medium,No,High,Low,Transparent,Low,Yes,GLASS
|
||||
Longitiudonal,High,No,Medium,High,Dark,High,Yes,MIXED
|
||||
Irregular,Medium,No,High,High,Dark,Low,Yes, PLASTIC_AND_METAL
|
||||
Flat,High,Yes,Medium,Medium,Colorful,Low,Yes,PAPER
|
||||
Longitiudonal,Low,Yes,Medium,Medium,Light,Medium,Yes,MIXED
|
||||
Round,Medium,Yes,High,Low,Light,Medium,Yes,PLASTIC_AND_METAL
|
||||
Longitiudonal,High,No,Medium,Low,Light,Low,Yes,PLASTIC_AND_METAL
|
|
25
startup.py
25
startup.py
@ -8,6 +8,7 @@ from garbageTruck import GarbageTruck
|
||||
from garbageCan import GarbageCan
|
||||
from speedBump import SpeedBump
|
||||
from landfill import Landfill
|
||||
from garbage import Garbage
|
||||
|
||||
|
||||
def startup(game_context: GameContext):
|
||||
@ -19,27 +20,47 @@ def startup(game_context: GameContext):
|
||||
game_context.dust_car = car
|
||||
_create_landfill(game_context)
|
||||
|
||||
|
||||
def create_dust_car(game_context: GameContext) -> GarbageTruck:
|
||||
return GarbageTruck((3, 3))
|
||||
|
||||
|
||||
def render_background(game_context: GameContext):
|
||||
bg_img = Image.open("imgs/background.jpg")
|
||||
pygame_bg_image = pygame.image.frombuffer(bg_img.tobytes(), bg_img.size, 'RGB')
|
||||
game_context.canvas.blit(pygame_bg_image, (0, 0))
|
||||
|
||||
|
||||
def create_city() -> City:
|
||||
city: City = City()
|
||||
streets = create_streets()
|
||||
trashcans = create_trashcans()
|
||||
bumps = create_speed_bumps()
|
||||
garbage_pieces = create_garbage_pieces()
|
||||
garbage_pieces_counter = 0
|
||||
for s in streets:
|
||||
city.add_street(s)
|
||||
for t in trashcans:
|
||||
for i in range(4):
|
||||
t.add_garbage(garbage_pieces[garbage_pieces_counter])
|
||||
garbage_pieces_counter = garbage_pieces_counter + 1
|
||||
city.add_can(t)
|
||||
for b in bumps:
|
||||
city.add_bump(b)
|
||||
return city
|
||||
|
||||
|
||||
def create_garbage_pieces() -> List[Garbage]:
|
||||
garbage_pieces = []
|
||||
with open('machine_learning/garbage_infill.csv', 'r') as file:
|
||||
lines = file.readlines()
|
||||
for line in lines[1:]:
|
||||
param = line.strip().split(',')
|
||||
garbage_pieces.append(
|
||||
Garbage('img', param[0], param[1], param[2], param[3], param[4], param[5], param[6], param[7]))
|
||||
return garbage_pieces
|
||||
|
||||
|
||||
def create_streets() -> List[Street]:
|
||||
streets = []
|
||||
streets.append(Street(3, 30, 3, StreetType.HORIZONTAL))
|
||||
@ -54,6 +75,7 @@ def create_streets() -> List[Street]:
|
||||
streets.append(Street(17, 23, 25, StreetType.VERTICAL))
|
||||
return streets
|
||||
|
||||
|
||||
def create_trashcans() -> List[GarbageCan]:
|
||||
trashcans = []
|
||||
trashcans.append(GarbageCan((9, 4)))
|
||||
@ -65,6 +87,7 @@ def create_trashcans() -> List[GarbageCan]:
|
||||
trashcans.append(GarbageCan((26, 4)))
|
||||
return trashcans
|
||||
|
||||
|
||||
def create_speed_bumps() -> List[SpeedBump]:
|
||||
bumps = []
|
||||
bumps.append(SpeedBump((10, 9)))
|
||||
@ -73,7 +96,7 @@ def create_speed_bumps() -> List[SpeedBump]:
|
||||
|
||||
|
||||
def _create_landfill(game_context: GameContext) -> None:
|
||||
landfil_position = (23,24)
|
||||
landfil_position = (23, 24)
|
||||
landfill = Landfill(landfil_position)
|
||||
game_context.landfill = landfill
|
||||
landfill.render(game_context)
|
Loading…
Reference in New Issue
Block a user