Compare commits
No commits in common. "aec533956d171d8296f376e7ffe420d72675ccda" and "eb7857323c52e6b74e7d23d829951f8afd8c2565" have entirely different histories.
aec533956d
...
eb7857323c
@ -4,5 +4,4 @@ class AgentActionType (Enum):
|
|||||||
MOVE_FORWARD = 0
|
MOVE_FORWARD = 0
|
||||||
TURN_LEFT = 1
|
TURN_LEFT = 1
|
||||||
TURN_RIGHT = 2
|
TURN_RIGHT = 2
|
||||||
EMPTY_CAN = 3
|
|
||||||
UNKNOWN = None
|
UNKNOWN = None
|
@ -14,7 +14,6 @@ class GameContext:
|
|||||||
city = None
|
city = None
|
||||||
grid: Dict[Tuple[int, int], GridCellType] = {}
|
grid: Dict[Tuple[int, int], GridCellType] = {}
|
||||||
dust_car = None
|
dust_car = None
|
||||||
landfill = None
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._init_grid()
|
self._init_grid()
|
||||||
|
@ -5,5 +5,4 @@ class GridCellType(Enum):
|
|||||||
STREET_VERTICAL = 1
|
STREET_VERTICAL = 1
|
||||||
STREET_HORIZONTAL = 2
|
STREET_HORIZONTAL = 2
|
||||||
GARBAGE_CAN = 3
|
GARBAGE_CAN = 3
|
||||||
VISITED_GARBAGE_CAN = 4
|
VISITED_GARBAGE_CAN = 4
|
||||||
LANDFILL = 5
|
|
Binary file not shown.
Before Width: | Height: | Size: 857 B |
39
landfill.py
39
landfill.py
@ -1,39 +0,0 @@
|
|||||||
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
|
|
@ -39,7 +39,7 @@ def move_dust_car(actions: list[AgentActionType], game_context: GameContext) ->
|
|||||||
elif game_context.grid[street_position] == GridCellType.STREET_VERTICAL:
|
elif game_context.grid[street_position] == GridCellType.STREET_VERTICAL:
|
||||||
game_context.render_in_cell(street_position, "imgs/street_vertical.png")
|
game_context.render_in_cell(street_position, "imgs/street_vertical.png")
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
time.sleep(0.15)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
10
startup.py
10
startup.py
@ -6,7 +6,6 @@ from typing import Tuple, List
|
|||||||
from street import Street, StreetType
|
from street import Street, StreetType
|
||||||
from garbageTruck import GarbageTruck
|
from garbageTruck import GarbageTruck
|
||||||
from garbageCan import GarbageCan
|
from garbageCan import GarbageCan
|
||||||
from landfill import Landfill
|
|
||||||
|
|
||||||
|
|
||||||
def startup(game_context: GameContext):
|
def startup(game_context: GameContext):
|
||||||
@ -16,7 +15,6 @@ def startup(game_context: GameContext):
|
|||||||
car = create_dust_car(game_context)
|
car = create_dust_car(game_context)
|
||||||
car.render(game_context)
|
car.render(game_context)
|
||||||
game_context.dust_car = car
|
game_context.dust_car = car
|
||||||
_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))
|
||||||
@ -59,10 +57,4 @@ def create_trashcans() -> List[GarbageCan]:
|
|||||||
trashcans.append(GarbageCan((17, 9)))
|
trashcans.append(GarbageCan((17, 9)))
|
||||||
trashcans.append(GarbageCan((24, 17)))
|
trashcans.append(GarbageCan((24, 17)))
|
||||||
trashcans.append(GarbageCan((26, 4)))
|
trashcans.append(GarbageCan((26, 4)))
|
||||||
return trashcans
|
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)
|
|
Loading…
Reference in New Issue
Block a user