From 94f301cae53f2452d4556945752240285515099a Mon Sep 17 00:00:00 2001 From: Pawel Felcyn Date: Thu, 11 May 2023 20:12:41 +0200 Subject: [PATCH 1/2] add landfill --- agentActionType.py | 1 + gameContext.py | 1 + gridCellType.py | 3 ++- imgs/landfill.png | Bin 0 -> 857 bytes landfill.py | 39 +++++++++++++++++++++++++++++++++++++++ startup.py | 10 +++++++++- 6 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 imgs/landfill.png create mode 100644 landfill.py diff --git a/agentActionType.py b/agentActionType.py index abbf382..10fe0d8 100644 --- a/agentActionType.py +++ b/agentActionType.py @@ -4,4 +4,5 @@ class AgentActionType (Enum): MOVE_FORWARD = 0 TURN_LEFT = 1 TURN_RIGHT = 2 + EMPTY_CAN = 3 UNKNOWN = None \ No newline at end of file diff --git a/gameContext.py b/gameContext.py index b454bd2..6f6295f 100644 --- a/gameContext.py +++ b/gameContext.py @@ -14,6 +14,7 @@ class GameContext: city = None grid: Dict[Tuple[int, int], GridCellType] = {} dust_car = None + landfill = None def __init__(self) -> None: self._init_grid() diff --git a/gridCellType.py b/gridCellType.py index 68f37bf..fd88aab 100644 --- a/gridCellType.py +++ b/gridCellType.py @@ -5,4 +5,5 @@ class GridCellType(Enum): STREET_VERTICAL = 1 STREET_HORIZONTAL = 2 GARBAGE_CAN = 3 - VISITED_GARBAGE_CAN = 4 \ No newline at end of file + VISITED_GARBAGE_CAN = 4 + LANDFILL = 5 \ No newline at end of file diff --git a/imgs/landfill.png b/imgs/landfill.png new file mode 100644 index 0000000000000000000000000000000000000000..6aa52ca991d96e9d9363b3a2c537e9143c5b2c58 GIT binary patch literal 857 zcmV-f1E&0mP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGqB>(^xB>_oNB=7(L0`5sfK~zXfmDEv4 zQ&AYe@e5fF1X0K$OpD62)F6to(ujJ=EcC%p>p_E{pog9+No}SWxh#m#lF-4X&YH?h z+}vWc+Hg&=MGn!Fuwd#iD(#^_J-2V3ad!6IJGH}~an6PFyN5Hlg86m1(t z25eKl$xGtAKqGSs@;int*+Zef*MoMhr2*R{vZM)U&l>yUsYQ^q|Dea;HZ8g0L{~J8 ze25aitw$W6pLVoc%;gv9r9@EQuBgw;$)0&tl3k* zyO0dM=#0htmm@<-_{o@}Z6r_8`c=@(&`OBR#_!an|d-4 z$8vj$#4Z<~s=7ugH{@w^MIjPt?%~2Eg9Fh4NixFF+?}x8BNq@#x(DGmAW24$e)r%S zn?uIwoxE#!l`cImEg(rokXA)(Hr~i*%g%~JAnKaqRgrP`1%F6nRVgc}rPu52b~~NJ z2-2`wedHip!fW7V6s0Y8^dppJdZGrX?P0y?mf5X#H(qa)p&{Vf^G?80mvfwxh`TOf}|CnP6gUG8%e+Se8`0aQnMdu$a!iTf}qP; zDM|Vq;P?yQf}7xL45pc~Q?!M&QX8;LBHI|aE= zTdsN)nzqM~i#QZ=p<&HAOp~g8Ok_9H@GKKqtP=a-?>}OZOY11C51~bSV~~D+p3R?r j)+3Y_&V_hao89scjll16b8mCm00000NkvXXu0mjfocWRw literal 0 HcmV?d00001 diff --git a/landfill.py b/landfill.py new file mode 100644 index 0000000..575db9b --- /dev/null +++ b/landfill.py @@ -0,0 +1,39 @@ +from typing import Tuple +from gameContext import GameContext +from garbage import RecognizedGarbage +from gridCellType import GridCellType + +class Landfill: + position: Tuple[int, int] = [] + paper: list[RecognizedGarbage] + plastic_and_metal: list[RecognizedGarbage] = [] + glass: list[RecognizedGarbage] = [] + bio: list[RecognizedGarbage] = [] + mixed: list[RecognizedGarbage] = [] + + def __init__(self, position: Tuple[int, int]) -> None: + self.position = position + + def add_paper(self, paper: list[RecognizedGarbage]) -> None: + for p in paper: + self.paper.append(p) + + def add_plastic_and_metal(self, plastic_and_metal: list[RecognizedGarbage]) -> None: + for p in plastic_and_metal: + self.plastic_and_metal.append(p) + + def add_glass(self, glass: list[RecognizedGarbage]) -> None: + for g in glass: + self.glass.append(g) + + def add_paper(self, bio: list[RecognizedGarbage]) -> None: + for b in bio: + self.bio.append(b) + + def add_mixed(self, mixed: list[RecognizedGarbage]) -> None: + for m in mixed: + self.mixed.append(m) + + def render(self, game_context: GameContext) -> None: + game_context.render_in_cell(self.position, 'imgs/landfill.png') + game_context.grid[self.position] = GridCellType.LANDFILL \ No newline at end of file diff --git a/startup.py b/startup.py index 03e782b..f5b7279 100644 --- a/startup.py +++ b/startup.py @@ -6,6 +6,7 @@ from typing import Tuple, List from street import Street, StreetType from garbageTruck import GarbageTruck from garbageCan import GarbageCan +from landfill import Landfill def startup(game_context: GameContext): @@ -15,6 +16,7 @@ def startup(game_context: GameContext): car = create_dust_car(game_context) car.render(game_context) game_context.dust_car = car + _create_landfill(game_context) def create_dust_car(game_context: GameContext) -> GarbageTruck: return GarbageTruck((3, 3)) @@ -57,4 +59,10 @@ def create_trashcans() -> List[GarbageCan]: trashcans.append(GarbageCan((17, 9))) trashcans.append(GarbageCan((24, 17))) trashcans.append(GarbageCan((26, 4))) - return trashcans \ No newline at end of file + return trashcans + +def _create_landfill(game_context: GameContext) -> None: + landfil_position = (23,24) + landfill = Landfill(landfil_position) + game_context.landfill = landfill + landfill.render(game_context) \ No newline at end of file From bb3fc2715f2ea72eaa57d224697b8221c520d1e5 Mon Sep 17 00:00:00 2001 From: Pawel Felcyn Date: Thu, 11 May 2023 20:14:09 +0200 Subject: [PATCH 2/2] make dust car faster --- movement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/movement.py b/movement.py index 1947a50..8b8fe07 100644 --- a/movement.py +++ b/movement.py @@ -39,7 +39,7 @@ def move_dust_car(actions: list[AgentActionType], game_context: GameContext) -> elif game_context.grid[street_position] == GridCellType.STREET_VERTICAL: game_context.render_in_cell(street_position, "imgs/street_vertical.png") pygame.display.update() - time.sleep(0.5) + time.sleep(0.15)