Compare commits
No commits in common. "5bc61434e9b729f1a47fdf620ddf92e3f82105c2" and "3fe4b6f2e1575c5e1d7b81a1e7548d5605b7d1f2" have entirely different histories.
5bc61434e9
...
3fe4b6f2e1
@ -2,6 +2,3 @@
|
|||||||
cat = False
|
cat = False
|
||||||
movement = robot
|
movement = robot
|
||||||
#accept: human, robot
|
#accept: human, robot
|
||||||
|
|
||||||
[CONSTANT]
|
|
||||||
NumberOfBananas = 20
|
|
Binary file not shown.
Before Width: | Height: | Size: 70 KiB |
@ -1,29 +0,0 @@
|
|||||||
2-10 opakowania po cukierkach
|
|
||||||
11-18 ka逝瞠 zwierz徠
|
|
||||||
19-28 odpady zwierz璚e
|
|
||||||
29-36 skarpetka
|
|
||||||
37-44 kolczyk
|
|
||||||
45 telefon
|
|
||||||
46-48 banan
|
|
||||||
49-57 zabawki
|
|
||||||
58-61 kot
|
|
||||||
62-65 pies
|
|
||||||
66-79 kable
|
|
||||||
80-91 w這sy
|
|
||||||
92-100 szk這
|
|
||||||
101-108 o堯wki
|
|
||||||
109-113 chomik
|
|
||||||
114-122 baterie
|
|
||||||
123-128 resztki owoc闚
|
|
||||||
129-140 etykiety
|
|
||||||
141-149 bransoletki
|
|
||||||
150-158 opakowania od jedzenia
|
|
||||||
159-167 ksi捫ki
|
|
||||||
168-177 papierki
|
|
||||||
178-179 pielucha dzieci璚a
|
|
||||||
180,181 pokrywka
|
|
||||||
182,183 wazon
|
|
||||||
184,185 karm
|
|
||||||
186,187 dziecko
|
|
||||||
188,189 pieni康ze
|
|
||||||
190-198 kapcie
|
|
@ -24,7 +24,7 @@ class VacuumMoveCommand(Command):
|
|||||||
tmp = self.world.is_garbage_at(end_x, end_y)
|
tmp = self.world.is_garbage_at(end_x, end_y)
|
||||||
if len(tmp) > 0:
|
if len(tmp) > 0:
|
||||||
for t in tmp:
|
for t in tmp:
|
||||||
if self.vacuum.get_container_filling() < 100:
|
if self.vacuum.get_container_filling() < 1000:
|
||||||
self.vacuum.increase_container_filling()
|
self.vacuum.increase_container_filling()
|
||||||
self.world.dust[end_x][end_y].remove(t)
|
self.world.dust[end_x][end_y].remove(t)
|
||||||
|
|
||||||
|
@ -14,4 +14,4 @@ class Cat(Entity):
|
|||||||
self.sleeping = False
|
self.sleeping = False
|
||||||
self.direction = 0
|
self.direction = 0
|
||||||
|
|
||||||
self.properties = [4, 2, 20, 0, 1, 32, 37, 5]
|
self.props = [4,2,20,0,1,32,37,5]
|
@ -5,4 +5,4 @@ from domain.world import World
|
|||||||
class Earring(Entity):
|
class Earring(Entity):
|
||||||
def __init__(self, x: int, y: int):
|
def __init__(self, x: int, y: int):
|
||||||
super().__init__(x, y, "EARRING")
|
super().__init__(x, y, "EARRING")
|
||||||
self.properties = [1, 9, 0, 1, 0, 1, 20, 0]
|
self.props = [1,9,0,1,0,1,20,0]
|
@ -6,6 +6,6 @@ class Garbage(Entity):
|
|||||||
super().__init__(x, y, "PEEL")
|
super().__init__(x, y, "PEEL")
|
||||||
self.wet = False
|
self.wet = False
|
||||||
self.size = 0
|
self.size = 0
|
||||||
self.properties = [2, 2, 0, 0, 1, 4, 24, 1]
|
self.props = [2,2,0,0,1,4,24,1]
|
||||||
|
|
||||||
# TODO GARBAGE: add more properties
|
# TODO GARBAGE: add more properties
|
||||||
|
@ -11,7 +11,7 @@ class Vacuum(Entity):
|
|||||||
self.container_filling = 0
|
self.container_filling = 0
|
||||||
|
|
||||||
def increase_container_filling(self) -> None:
|
def increase_container_filling(self) -> None:
|
||||||
self.container_filling += 5
|
self.container_filling += 25
|
||||||
|
|
||||||
def dump_trash(self) -> None:
|
def dump_trash(self) -> None:
|
||||||
self.container_filling = 0
|
self.container_filling = 0
|
||||||
|
@ -4,7 +4,7 @@ from domain.entities.entity import Entity
|
|||||||
|
|
||||||
class World:
|
class World:
|
||||||
def __init__(self, width: int, height: int) -> object:
|
def __init__(self, width: int, height: int) -> object:
|
||||||
self.costs = [[1 for j in range(height)] for i in range(width)]
|
self.costs = [[1000 for j in range(height)] for i in range(width)]
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
self.dust = [[[] for j in range(height)] for i in range(width)]
|
self.dust = [[[] for j in range(height)] for i in range(width)]
|
||||||
@ -35,7 +35,7 @@ class World:
|
|||||||
def is_garbage_at(self, x: int, y: int):
|
def is_garbage_at(self, x: int, y: int):
|
||||||
if len(self.dust[x][y]) == 0:
|
if len(self.dust[x][y]) == 0:
|
||||||
return []
|
return []
|
||||||
return [i for i in self.dust[x][y] if evaluate([i.properties])[0] == 1]
|
return [i for i in self.dust[x][y] if evaluate([i.props])[0] == 1]
|
||||||
|
|
||||||
def is_docking_station_at(self, x: int, y: int) -> bool:
|
def is_docking_station_at(self, x: int, y: int) -> bool:
|
||||||
return bool(self.doc_station.x == x and self.doc_station.y == y)
|
return bool(self.doc_station.x == x and self.doc_station.y == y)
|
||||||
@ -53,6 +53,5 @@ class World:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_cost(self, x, y):
|
def get_cost(self, x, y):
|
||||||
return self.costs[x][y]
|
return self.costs[x][y]
|
21
main.py
21
main.py
@ -13,10 +13,9 @@ from domain.entities.earring import Earring
|
|||||||
from domain.entities.docking_station import Doc_Station
|
from domain.entities.docking_station import Doc_Station
|
||||||
from domain.world import World
|
from domain.world import World
|
||||||
from view.renderer import Renderer
|
from view.renderer import Renderer
|
||||||
|
|
||||||
# from AI_brain.movement import GoAnyDirectionBFS, State
|
# from AI_brain.movement import GoAnyDirectionBFS, State
|
||||||
# from AI_brain.rotate_and_go_bfs import RotateAndGoBFS, State
|
# from AI_brain.rotate_and_go_bfs import RotateAndGoBFS, State
|
||||||
from AI_brain.rotate_and_go_aStar import RotateAndGoAStar, State
|
from AI_brain.rotate_and_go_astar import RotateAndGoAStar, State
|
||||||
|
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
@ -98,20 +97,12 @@ class Main:
|
|||||||
def handle_action2(self, action):
|
def handle_action2(self, action):
|
||||||
if action == "GO":
|
if action == "GO":
|
||||||
self.commands.append(
|
self.commands.append(
|
||||||
VacuumMoveCommand(
|
VacuumMoveCommand(self.world, self.world.vacuum, self.world.vacuum.direction)
|
||||||
self.world, self.world.vacuum, self.world.vacuum.direction
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
elif action == "RR":
|
elif action == "RR":
|
||||||
self.world.vacuum.direction = (
|
self.world.vacuum.direction = (-self.world.vacuum.direction[1], self.world.vacuum.direction[0])
|
||||||
-self.world.vacuum.direction[1],
|
|
||||||
self.world.vacuum.direction[0],
|
|
||||||
)
|
|
||||||
elif action == "RL":
|
elif action == "RL":
|
||||||
self.world.vacuum.direction = (
|
self.world.vacuum.direction = (self.world.vacuum.direction[1], -self.world.vacuum.direction[0])
|
||||||
self.world.vacuum.direction[1],
|
|
||||||
-self.world.vacuum.direction[0],
|
|
||||||
)
|
|
||||||
|
|
||||||
def process_input(self):
|
def process_input(self):
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
@ -145,7 +136,7 @@ class Main:
|
|||||||
|
|
||||||
def generate_world(tiles_x: int, tiles_y: int) -> World:
|
def generate_world(tiles_x: int, tiles_y: int) -> World:
|
||||||
world = World(tiles_x, tiles_y)
|
world = World(tiles_x, tiles_y)
|
||||||
for _ in range(config.getint("CONSTANT", "NumberOfBananas")):
|
for _ in range(35):
|
||||||
temp_x = randint(0, tiles_x - 1)
|
temp_x = randint(0, tiles_x - 1)
|
||||||
temp_y = randint(0, tiles_y - 1)
|
temp_y = randint(0, tiles_y - 1)
|
||||||
world.add_entity(Garbage(temp_x, temp_y))
|
world.add_entity(Garbage(temp_x, temp_y))
|
||||||
@ -163,6 +154,7 @@ def generate_world(tiles_x: int, tiles_y: int) -> World:
|
|||||||
world.add_entity(Earring(5, 5))
|
world.add_entity(Earring(5, 5))
|
||||||
world.add_entity(Earring(4, 6))
|
world.add_entity(Earring(4, 6))
|
||||||
|
|
||||||
|
|
||||||
for x in range(world.width):
|
for x in range(world.width):
|
||||||
for y in range(world.height):
|
for y in range(world.height):
|
||||||
if world.is_garbage_at(x, y):
|
if world.is_garbage_at(x, y):
|
||||||
@ -171,7 +163,6 @@ def generate_world(tiles_x: int, tiles_y: int) -> World:
|
|||||||
world.costs[x][y] = 10
|
world.costs[x][y] = 10
|
||||||
return world
|
return world
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = Main()
|
app = Main()
|
||||||
if config["APP"]["movement"] == "human":
|
if config["APP"]["movement"] == "human":
|
||||||
|
Loading…
Reference in New Issue
Block a user