sztuczna_inteligencja_2023_.../garbageTruck.py

50 lines
1.8 KiB
Python

from typing import List, Tuple
from agentOrientation import AgentOrientation
from garbage import GarbageType, RecognizedGarbage
from gameContext import GameContext
class GarbageTruck:
position: Tuple[int, int]
paper: List[RecognizedGarbage]
plastic_and_metal: List[RecognizedGarbage]
glass: List[RecognizedGarbage]
bio: List[RecognizedGarbage]
mixed: List[RecognizedGarbage]
orientation: AgentOrientation = AgentOrientation.RIGHT
def __init__(self, position: Tuple[int, int]) -> None:
self.position = position
self.paper = []
self.plastic_and_metal = []
self.glass = []
self.bio = []
self.mixed = []
def sort_garbage(self, RecognizedGarbage) -> None:
if RecognizedGarbage.garbage_type == GarbageType.PAPER:
self.paper.append(RecognizedGarbage)
elif RecognizedGarbage.garbage_type == GarbageType.PLASTIC_AND_METAL:
self.plastic_and_metal.append(RecognizedGarbage)
elif RecognizedGarbage.garbage_type == GarbageType.GLASS:
self.glass.append(RecognizedGarbage)
elif RecognizedGarbage.garbage_type == GarbageType.BIO:
self.bio.append(RecognizedGarbage)
elif RecognizedGarbage.garbage_type == GarbageType.MIXED:
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)