filled each garbage can with 4 pieces of garbage
This commit is contained in:
parent
c8bcea171e
commit
1e5a1b9254
30
garbage.py
30
garbage.py
@ -1,21 +1,43 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
class GarbageType (Enum):
|
|
||||||
|
class GarbageType(Enum):
|
||||||
PAPER = 0,
|
PAPER = 0,
|
||||||
PLASTIC_AND_METAL = 1
|
PLASTIC_AND_METAL = 1
|
||||||
GLASS = 3
|
GLASS = 3
|
||||||
BIO = 4
|
BIO = 4
|
||||||
MIXED = 5
|
MIXED = 5
|
||||||
|
|
||||||
|
|
||||||
class Garbage:
|
class Garbage:
|
||||||
img: str
|
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.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):
|
def xxx(self):
|
||||||
|
return self.shape
|
||||||
|
|
||||||
|
|
||||||
|
class RecognizedGarbage(Garbage):
|
||||||
garbage_type: GarbageType
|
garbage_type: GarbageType
|
||||||
|
|
||||||
def __init__(self, src: Garbage, garbage_type: GarbageType) -> None:
|
def __init__(self, src: Garbage, garbage_type: GarbageType) -> None:
|
||||||
super().__init__(src.img)
|
super().__init__(src.img)
|
||||||
self.garbage_type = garbage_type
|
self.garbage_type = garbage_type
|
||||||
|
@ -3,6 +3,7 @@ from typing import List, Tuple
|
|||||||
from gameContext import GameContext
|
from gameContext import GameContext
|
||||||
from gridCellType import GridCellType
|
from gridCellType import GridCellType
|
||||||
|
|
||||||
|
|
||||||
class GarbageCan:
|
class GarbageCan:
|
||||||
position: Tuple[int, int]
|
position: Tuple[int, int]
|
||||||
garbage: List[Garbage]
|
garbage: List[Garbage]
|
||||||
@ -19,6 +20,7 @@ class GarbageCan:
|
|||||||
def remove_garbage(self, garbage: Garbage) -> None:
|
def remove_garbage(self, garbage: Garbage) -> None:
|
||||||
self.garbage.remove(garbage)
|
self.garbage.remove(garbage)
|
||||||
|
|
||||||
|
|
||||||
def render(self, game_context: GameContext) -> None:
|
def render(self, game_context: GameContext) -> None:
|
||||||
game_context.render_in_cell(self.position, "imgs/container.png")
|
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
|
||||||
|
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
|
|
@ -48,4 +48,54 @@ Irregular,Low,No,Low,Medium,Light,Medium,No,PAPER
|
|||||||
Flat,Low,No,High,Low,Dark,Low,No,PLASTIC_AND_METAL
|
Flat,Low,No,High,Low,Dark,Low,No,PLASTIC_AND_METAL
|
||||||
Irregular,Low,Yes,Low,Low,Transparent,Medium,Yes,MIXED
|
Irregular,Low,Yes,Low,Low,Transparent,Medium,Yes,MIXED
|
||||||
Flat,Low,No,High,High,Light,Low,No,PLASTIC_AND_METAL
|
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,NoMIXED
|
||||||
|
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
|
Can't render this file because it has a wrong number of fields in line 88.
|
28
startup.py
28
startup.py
@ -8,6 +8,7 @@ from garbageTruck import GarbageTruck
|
|||||||
from garbageCan import GarbageCan
|
from garbageCan import GarbageCan
|
||||||
from speedBump import SpeedBump
|
from speedBump import SpeedBump
|
||||||
from landfill import Landfill
|
from landfill import Landfill
|
||||||
|
from garbage import Garbage
|
||||||
|
|
||||||
|
|
||||||
def startup(game_context: GameContext):
|
def startup(game_context: GameContext):
|
||||||
@ -19,26 +20,45 @@ def startup(game_context: GameContext):
|
|||||||
game_context.dust_car = car
|
game_context.dust_car = car
|
||||||
_create_landfill(game_context)
|
_create_landfill(game_context)
|
||||||
|
|
||||||
|
|
||||||
def create_dust_car(game_context: GameContext) -> GarbageTruck:
|
def create_dust_car(game_context: GameContext) -> GarbageTruck:
|
||||||
return GarbageTruck((3, 3))
|
return GarbageTruck((3, 3))
|
||||||
|
|
||||||
|
|
||||||
def render_background(game_context: GameContext):
|
def render_background(game_context: GameContext):
|
||||||
bg_img = Image.open("imgs/background.jpg")
|
bg_img = Image.open("imgs/background.jpg")
|
||||||
pygame_bg_image = pygame.image.frombuffer(bg_img.tobytes(), bg_img.size, 'RGB')
|
pygame_bg_image = pygame.image.frombuffer(bg_img.tobytes(), bg_img.size, 'RGB')
|
||||||
game_context.canvas.blit(pygame_bg_image, (0, 0))
|
game_context.canvas.blit(pygame_bg_image, (0, 0))
|
||||||
|
|
||||||
|
|
||||||
def create_city() -> City:
|
def create_city() -> City:
|
||||||
city: City = City()
|
city: City = City()
|
||||||
streets = create_streets()
|
streets = create_streets()
|
||||||
trashcans = create_trashcans()
|
trashcans = create_trashcans()
|
||||||
bumps = create_speed_bumps()
|
bumps = create_speed_bumps()
|
||||||
|
garbage_pieces = create_garbage_pieces()
|
||||||
|
garbage_pieces_counter = 0
|
||||||
for s in streets:
|
for s in streets:
|
||||||
city.add_street(s)
|
city.add_street(s)
|
||||||
for t in trashcans:
|
for t in trashcans:
|
||||||
|
for i in range(4):
|
||||||
|
t.add_garbage(garbage_pieces[0])
|
||||||
|
garbage_pieces_counter = garbage_pieces_counter + 1
|
||||||
city.add_can(t)
|
city.add_can(t)
|
||||||
for b in bumps:
|
for b in bumps:
|
||||||
city.add_bump(b)
|
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]:
|
def create_streets() -> List[Street]:
|
||||||
streets = []
|
streets = []
|
||||||
@ -54,6 +74,7 @@ def create_streets() -> List[Street]:
|
|||||||
streets.append(Street(17, 23, 25, StreetType.VERTICAL))
|
streets.append(Street(17, 23, 25, StreetType.VERTICAL))
|
||||||
return streets
|
return streets
|
||||||
|
|
||||||
|
|
||||||
def create_trashcans() -> List[GarbageCan]:
|
def create_trashcans() -> List[GarbageCan]:
|
||||||
trashcans = []
|
trashcans = []
|
||||||
trashcans.append(GarbageCan((9, 4)))
|
trashcans.append(GarbageCan((9, 4)))
|
||||||
@ -65,6 +86,7 @@ def create_trashcans() -> List[GarbageCan]:
|
|||||||
trashcans.append(GarbageCan((26, 4)))
|
trashcans.append(GarbageCan((26, 4)))
|
||||||
return trashcans
|
return trashcans
|
||||||
|
|
||||||
|
|
||||||
def create_speed_bumps() -> List[SpeedBump]:
|
def create_speed_bumps() -> List[SpeedBump]:
|
||||||
bumps = []
|
bumps = []
|
||||||
bumps.append(SpeedBump((10, 9)))
|
bumps.append(SpeedBump((10, 9)))
|
||||||
@ -73,7 +95,7 @@ def create_speed_bumps() -> List[SpeedBump]:
|
|||||||
|
|
||||||
|
|
||||||
def _create_landfill(game_context: GameContext) -> None:
|
def _create_landfill(game_context: GameContext) -> None:
|
||||||
landfil_position = (23,24)
|
landfil_position = (23, 24)
|
||||||
landfill = Landfill(landfil_position)
|
landfill = Landfill(landfil_position)
|
||||||
game_context.landfill = landfill
|
game_context.landfill = landfill
|
||||||
landfill.render(game_context)
|
landfill.render(game_context)
|
||||||
|
Loading…
Reference in New Issue
Block a user