sztuczna_inteligencja_2023_.../garbageTruck.py

50 lines
1.8 KiB
Python
Raw Normal View History

2023-03-27 11:50:23 +02:00
from typing import List, Tuple
2023-04-22 16:36:13 +02:00
from agentOrientation import AgentOrientation
2023-05-29 09:57:52 +02:00
from garbage import GarbageType, RecognizedGarbage
2023-04-22 16:36:13 +02:00
from gameContext import GameContext
2023-03-26 20:58:43 +02:00
class GarbageTruck:
position: Tuple[int, int]
2023-03-26 21:13:05 +02:00
paper: List[RecognizedGarbage]
plastic_and_metal: List[RecognizedGarbage]
glass: List[RecognizedGarbage]
bio: List[RecognizedGarbage]
mixed: List[RecognizedGarbage]
2023-04-22 16:36:13 +02:00
orientation: AgentOrientation = AgentOrientation.RIGHT
def __init__(self, position: Tuple[int, int]) -> None:
2023-03-26 20:58:43 +02:00
self.position = position
self.paper = []
self.plastic_and_metal = []
self.glass = []
self.bio = []
self.mixed = []
def sort_garbage(self, RecognizedGarbage) -> None:
2023-05-29 09:57:52 +02:00
if RecognizedGarbage.garbage_type == GarbageType.PAPER:
2023-03-26 20:58:43 +02:00
self.paper.append(RecognizedGarbage)
2023-05-29 09:57:52 +02:00
elif RecognizedGarbage.garbage_type == GarbageType.PLASTIC_AND_METAL:
2023-03-26 20:58:43 +02:00
self.plastic_and_metal.append(RecognizedGarbage)
2023-05-29 09:57:52 +02:00
elif RecognizedGarbage.garbage_type == GarbageType.GLASS:
2023-03-26 20:58:43 +02:00
self.glass.append(RecognizedGarbage)
2023-05-29 09:57:52 +02:00
elif RecognizedGarbage.garbage_type == GarbageType.BIO:
2023-03-26 20:58:43 +02:00
self.bio.append(RecognizedGarbage)
2023-05-29 09:57:52 +02:00
elif RecognizedGarbage.garbage_type == GarbageType.MIXED:
2023-04-22 16:36:13 +02:00
self.mixed.append(RecognizedGarbage)
def render(self, game_context: GameContext) -> None:
path = None
if self.orientation == AgentOrientation.LEFT:
path = 'imgs/dust_car_left.png'
elif self.orientation == AgentOrientation.RIGHT:
path = 'imgs/dust_car_right.png'
elif self.orientation == AgentOrientation.UP:
path = 'imgs/dust_car_up.png'
elif self.orientation == AgentOrientation.DOWN:
path = 'imgs/dust_car_down.png'
game_context.render_in_cell(self.position, path)