Compare commits

...

5 Commits

Author SHA1 Message Date
24f4c60e37 Merge pull request 'filled each garbage can with 4 pieces of garbage' (#28) from cvs_wypelnienie_smietnika into master
Reviewed-on: #28
Reviewed-by: Paweł Felcyn <pawfel1@st.amu.edu.pl>
2023-05-27 14:58:33 +02:00
majkellll
d8e34ad65b delated test methods 2023-05-27 13:46:44 +02:00
majkellll
a1f2e4b298 garbage_pieces_counter 2023-05-27 13:45:31 +02:00
majkellll
f79fa2ee66 dodany przecinek 2023-05-27 13:35:39 +02:00
majkellll
1e5a1b9254 filled each garbage can with 4 pieces of garbage 2023-05-27 13:16:41 +02:00
5 changed files with 131 additions and 8 deletions

View File

@ -1,21 +1,40 @@
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:
super().__init__(src.img)
self.garbage_type = garbage_type
self.garbage_type = garbage_type

View File

@ -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
game_context.grid[self.position] = GridCellType.GARBAGE_CAN

View 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
1 Shape Flexibility DoesSmell Weight Size Color Softness DoesDin
2 Irregular High No High Medium Dark Low Yes
3 Longitiudonal Low No Low Low Light Medium Yes
4 Longitiudonal Medium No Medium Low Dark High No
5 Longitiudonal Low No Medium Low Dark High Yes
6 Round Low Yes High High Transparent High Yes
7 Irregular Medium Yes High Low Transparent Medium No
8 Longitiudonal Medium Yes Low High Colorful Medium Yes
9 Longitiudonal Low No Low Medium Dark Medium Yes
10 Flat Medium Yes High Low Transparent Low Yes
11 Irregular Medium Yes High Medium Dark Low No
12 Longitiudonal High No Low High Colorful Low Yes
13 Round Medium No Medium Medium Dark Low No
14 Longitiudonal Medium No Medium Medium Transparent High No
15 Flat Medium Yes Low Low Light Medium No
16 Flat Medium Yes Medium High Light Medium No
17 Flat Low No High Low Dark High No
18 Longitiudonal Medium Yes High High Dark Low Yes
19 Flat Low Yes Low Low Transparent Low No
20 Flat Low No Medium Low Colorful Low No
21 Longitiudonal Low Yes High Medium Transparent Low No
22 Longitiudonal Low No Medium High Dark Low Yes
23 Irregular Medium No Medium Medium Light Low Yes
24 Longitiudonal High No High High Colorful Low No
25 Flat Low No Low Low Dark High No
26 Flat Low Yes Low High Dark Low Yes
27 Irregular Medium Yes High High Dark Low No
28 Flat High No High Low Dark Medium Yes
29 Longitiudonal High Yes Low Medium Colorful Low Yes

View File

@ -48,4 +48,54 @@ Irregular,Low,No,Low,Medium,Light,Medium,No,PAPER
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
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
1 Shape Flexibility DoesSmell Weight Size Color Softness DoesDin GarbageType
48 Flat Low No High Low Dark Low No PLASTIC_AND_METAL
49 Irregular Low Yes Low Low Transparent Medium Yes MIXED
50 Flat Low No High High Light Low No PLASTIC_AND_METAL
51 Longitiudonal Medium No High Medium Dark Low Yes PLASTIC_AND_METAL
52 Round Low Yes High High Transparent High No MIXED
53 Flat Medium No Medium Low Transparent Low Yes GLASS
54 Longitiudonal Low No High Medium Colorful Medium No PLASTIC_AND_METAL
55 Longitiudonal Low Yes High Medium Colorful High No BIO
56 Longitiudonal High No High Medium Transparent Medium Yes PLASTIC_AND_METAL
57 Irregular Medium No Medium Medium Dark High No PAPER
58 Irregular Low No Low Medium Light Medium Yes PLASTIC_AND_METAL
59 Round High No Medium Medium Colorful Low Yes PLASTIC_AND_METAL
60 Irregular High No High High Colorful Low No MIXED
61 Round High Yes Medium Medium Transparent High Yes PLASTIC_AND_METAL
62 Flat Medium Yes High Medium Colorful Medium Yes BIO
63 Round High No Medium Medium Light High No MIXED
64 Flat Low Yes Low Low Transparent Medium No PLASTIC_AND_METAL
65 Flat Low No Medium High Light High Yes MIXED
66 Round Medium Yes Medium High Transparent High No MIXED
67 Irregular Medium Yes Medium Medium Colorful Low No MIXED
68 Flat Low Yes Low High Light Medium No BIO
69 Flat Low Yes Medium Medium Dark Medium No MIXED
70 Irregular Low No High High Transparent High No PLASTIC_AND_METAL
71 Irregular Low Yes Low Medium Dark Low Yes GLASS
72 Flat Low Yes Low Medium Light Low No GLASS
73 Longitiudonal Medium Yes Low Medium Dark Low Yes PLASTIC_AND_METAL
74 Irregular Medium No Low Low Colorful Medium Yes PAPER
75 Round High No Medium Medium Dark High No MIXED
76 Round High Yes Low High Colorful Low No MIXED
77 Longitiudonal Low Yes Low Low Transparent Medium Yes MIXED
78 Flat Low No High Medium Light Low No PLASTIC_AND_METAL
79 Irregular High No Low Low Colorful High Yes PAPER
80 Round High No Medium Medium Colorful High No MIXED
81 Irregular High Yes High Low Transparent Medium No MIXED
82 Round Low No Medium Low Colorful Low No GLASS
83 Flat Low No High Low Light Low No MIXED
84 Irregular High No High Medium Light Low No PLASTIC_AND_METAL
85 Flat Medium Yes High Low Dark Low No MIXED
86 Round Medium No High High Colorful Medium No PAPER
87 Flat Low Yes Medium Low Transparent Medium No PLASTIC_AND_METAL
88 Flat Medium No Low Medium Transparent High No MIXED
89 Flat Low Yes Medium High Colorful Low No GLASS
90 Longitiudonal Low Yes High Medium Dark High No BIO
91 Longitiudonal Medium Yes Low High Dark High Yes BIO
92 Round High No Low Low Colorful Medium No PAPER
93 Longitiudonal Medium Yes Medium Low Colorful Low Yes PLASTIC_AND_METAL
94 Longitiudonal High Yes Low Medium Light Medium Yes BIO
95 Round Medium No High Low Transparent Low Yes GLASS
96 Longitiudonal High No Medium High Dark High Yes MIXED
97 Irregular Medium No High High Dark Low Yes PLASTIC_AND_METAL
98 Flat High Yes Medium Medium Colorful Low Yes PAPER
99 Longitiudonal Low Yes Medium Medium Light Medium Yes MIXED
100 Round Medium Yes High Low Light Medium Yes PLASTIC_AND_METAL
101 Longitiudonal High No Medium Low Light Low Yes PLASTIC_AND_METAL

View File

@ -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)
landfill.render(game_context)