Compare commits
81 Commits
423e7e858c
...
a4f822ad93
Author | SHA1 | Date | |
---|---|---|---|
|
a4f822ad93 | ||
3283eaa46d | |||
8a05edf925 | |||
f20ac56cc0 | |||
|
2d4cc41157 | ||
|
f4ad111371 | ||
|
afdcac8b56 | ||
c95ce82ac4 | |||
|
ccefc6afbc | ||
|
f5003e93fe | ||
e972dcfd83 | |||
|
7dd2190c76 | ||
|
029bcb1986 | ||
|
8ef3da8df0 | ||
|
3b761e41ab | ||
2929495348 | |||
|
959ed6bfda | ||
2c9500c2bf | |||
|
f7b97c5f74 | ||
|
291e028a8a | ||
|
047ef87bab | ||
|
83ef0fecad | ||
|
03ece1218b | ||
|
a0fe606c23 | ||
|
5b85d415e4 | ||
40a8322852 | |||
|
5de48e2c3f | ||
|
c54a99369e | ||
adf4eaee00 | |||
|
77feab6a4e | ||
|
31dcf7b6dc | ||
|
28af8048b9 | ||
848e23d062 | |||
|
7358cb73fe | ||
|
50a0eda8ef | ||
|
5818a63e1e | ||
ad828cb7d1 | |||
|
667d19084f | ||
|
586a94e0c0 | ||
|
be307ebab5 | ||
|
4933c04bd8 | ||
|
e55dbcccea | ||
|
7757843da8 | ||
|
51a629285d | ||
a65b07727b | |||
7809879c7c | |||
ff3f344fca | |||
|
e37a889e1e | ||
|
101136b0b7 | ||
4ec034d548 | |||
|
8d9c4146a4 | ||
ef2e1a1fb7 | |||
|
2200cf15d7 | ||
|
9b7bb1a62c | ||
|
a5e38a707b | ||
|
257f0f7d1d | ||
|
3696636245 | ||
|
d080b04763 | ||
9ac833550c | |||
|
9db0cc3cfd | ||
|
63912b9b24 | ||
|
997bd72a97 | ||
2ea0e3b27d | |||
9c4b811c98 | |||
|
edc78b9103 | ||
|
7eb0a8b7fa | ||
|
6f31a587b9 | ||
|
0580148281 | ||
|
341e198749 | ||
3aee864b8c | |||
963f2da849 | |||
8714f2aa8f | |||
b9f443c424 | |||
58f85007f5 | |||
645aa663e3 | |||
acce6f6bd1 | |||
460e18fb06 | |||
85281d93e8 | |||
|
2516befe86 | ||
1ed6a272b8 | |||
00e08867e6 |
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
14
.idea/Machine_learning_2023.iml
Normal file
14
.idea/Machine_learning_2023.iml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/PythEnv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (Machine_learning_2023)" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Machine_learning_2023.iml" filepath="$PROJECT_DIR$/.idea/Machine_learning_2023.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -56,3 +56,61 @@ Summary:
|
||||
The "Automatic cleaning robot" project is a simple yet educational programming project. Users are tasked with specifying the positions that the robot should clean, as well as the coordinates of obstacles. The robot, built using artificial intelligence, is responsible for avoiding obstacles, making decisions in case of random events, and cleaning the designated points. The project was written in Python with the use of artificial intelligence. The analysis of images is based on neural networks.
|
||||
|
||||
******
|
||||
******
|
||||
|
||||
Dokumentacja projektu "Automatyczny robot sprzątający"
|
||||
|
||||
Wprowadzenie:
|
||||
Projekt "Automatyczny robot sprzątający" jest projektem bazującym się na symulacji pracy robota sprzątającego w pomieszczeniu za pomocą sztucznej inteligencji. Robot ma za zadanie wyznaczać miejsca do sprzątania oraz uniknąć przeszkód oraz reagować na zdarzenia losowe. Projekt jest napisany w języku Python.
|
||||
|
||||
Instrukcja obsługi:
|
||||
|
||||
Uruchomienie projektu:
|
||||
Aby uruchomić projekt należy uruchomić plik "main.py" za pomocą interpretera Python. Projektu wyświetli się w konsoli.Po uruchomieniu projektu na ekranie wyświetli się plansza o wymiarach NxN (default: 10x10). Robot "Cleaner" (oznaczony jako "R" na planszy) startuje z pozycji (0,0). użytkownik ma za zadanie wprowadzić pozycje do sprzątania, które są oznaczone na planszy jako litery "D". Możliwe pozycje to liczby od 0 do N-1.
|
||||
|
||||
Użytkownik wprowadza pozycje za pomocą terminala. Wprowadzenie koordynat odbywa się w następujący sposób:
|
||||
Najpierw wprowadzamy numer wiersza, a następnie numer kolumny, oddzielając je spacją.
|
||||
Przykładowo, jeśli chcemy wskazać pozycję (4,5) wpisujemy: "4 5".
|
||||
Po wskazaniu pozycji do sprzątania, użytkownik musi uniknąć przeszkód, które są oznaczone na planszy jako znak "X". Robot nie może przejść przez przeszkody. Jeśli użytkownik wskazuje pozycję przeszkody, projektu zwróci błąd i będzie wymagała podania nowych współrzędnych.
|
||||
|
||||
Przebieg projektu:
|
||||
Robot, zgodnie z zbudowaną mapą, musi obliczyć najkrótszą ścieżkę do sprzątania wszystkich pozycji oraz uniknąć przeszkód. Podczas sprzątania mogą wystąpić przypadkowe zdarzenia, na które robot będzie reagował. W tym celu, z pomocą sieci neuronowych, robot analizuje zdjęcie zdarzenia, aby wybrać najlepsze rozwiązania.
|
||||
|
||||
Zakończenie projektu:
|
||||
Program kończy swoje działanie w momencie, gdy robot posprząta wszystkie przez użytkownika wybrane pola do sprzątania. Na zakończenie programu zostanie wyświetlona liczba wykonanych ruchów przez robota oraz podjęte decyzje w przypadku zaistnienia zdarzeń.
|
||||
|
||||
Możliwe modyfikacje:
|
||||
Projekt zostanie napisany z myślą o możliwości łatwej modyfikacji. Można zmienić wymiary planszy, dodać lub usunąć przeszkody oraz ilość przypadkowych zdarzeń i pozycji do sprzątania. Wszystkie te zmiany można wprowadzić w pliku "config.py".
|
||||
|
||||
Podsumowanie:
|
||||
Projekt "Automatyczny robot sprzątający" to prosty, ale edukacyjny projekt programistyczny. Użytkownik ma za zadanie wskazanie pozycji, które robot powinien posprzątać, a także koordynat przeszkody. Natomiast zadaniem robota, który został zbudowany przy użyciu sztucznej inteligencji, jest unikanie przeszkód, podejmowanie decyzji w przypadku wystąpienia przypadkowych zdarzeń oraz sprzątanie wyznaczonych punktów. Projekt został napisany w języku Python z wykorzystaniem sztucznej inteligencji. Analiza zdjęć jest oparta na sieciach neuronowych.
|
||||
|
||||
******
|
||||
|
||||
Documentation of the "Automatic Cleaning Robot" project
|
||||
|
||||
Introduction:
|
||||
The "Automatic Cleaning Robot" project is based on simulating the work of a cleaning robot in a room using artificial intelligence. The robot is tasked with determining the areas to be cleaned, avoiding obstacles, and reacting to random events. The project is written in Python.
|
||||
|
||||
User Guide:
|
||||
Starting the project:
|
||||
To start the project, you need to run the "main.py" file using a Python interpreter. The project will be displayed on the console. Once the project is launched, a 10x10 board will be displayed on the screen. The "Cleaner" robot (marked as "R" on the board) starts from the position (0,0). The user needs to enter the positions to be cleaned, which are marked as the letter "D" on the board. The possible positions are numbers from 0 to 9.
|
||||
|
||||
The user enters the positions through the terminal. The entry of coordinates is done as follows:
|
||||
First, we enter the row number, and then the column number, separating them with a space.
|
||||
For example, if we want to indicate the position (4,5), we enter "4 5".
|
||||
After indicating the positions to be cleaned, the user must avoid obstacles, which are marked on the board as the "X" symbol. The robot cannot pass through obstacles. If the user points to an obstacle position, the project will return an error and require new coordinates.
|
||||
|
||||
Project process:
|
||||
Based on the built map, the robot must calculate the shortest path to clean all positions and avoid obstacles. Random events may occur during cleaning, to which the robot will react. To do this, with the help of neural networks, the robot analyzes the image of the event to choose the best solutions.
|
||||
|
||||
Project conclusion:
|
||||
The program is ending when the robot cleans all the fields selected by the user. At the end of the program, the number of robot moves performed and the decisions made in case of events will be displayed.
|
||||
|
||||
Possible modifications:
|
||||
The "Automatic cleaning robot" project has been designed with the possibility of easy modifications in mind. Users can change the dimensions of the board, add or remove obstacles, and adjust the number of random events and cleaning positions. All these changes can be made in the "config.py" file.
|
||||
|
||||
Summary:
|
||||
The "Automatic cleaning robot" project is a simple yet educational programming project. Users are tasked with specifying the positions that the robot should clean, as well as the coordinates of obstacles. The robot, built using artificial intelligence, is responsible for avoiding obstacles, making decisions in case of random events, and cleaning the designated points. The project was written in Python with the use of artificial intelligence. The analysis of images is based on neural networks.
|
||||
|
||||
******
|
||||
|
22
decisionTree/data.csv
Normal file
22
decisionTree/data.csv
Normal file
@ -0,0 +1,22 @@
|
||||
1-2-3-4-5;1-green 2-yellow 3-orange 4-black 5-while 6-blue;in dB 0-100;0-24;0/1;in cm;in C;0/1
|
||||
Size;Color;Sound;Time;Smell;Height;Temperature;ToRemove
|
||||
1;2;0;16;1;10;25;1
|
||||
2;1;0;12;0;50;24;0
|
||||
2;3;30;13;1;38;38;0
|
||||
1;4;0;7;1;5;27;1
|
||||
1;2;0;16;1;10;25;1
|
||||
2;1;0;12;0;50;24;0
|
||||
2;3;30;13;1;38;38;0
|
||||
1;4;0;7;1;5;27;1
|
||||
1;2;0;16;1;10;25;1
|
||||
2;1;0;12;0;50;24;0
|
||||
2;3;30;13;1;38;38;0
|
||||
1;4;0;7;1;5;27;1
|
||||
1;2;0;16;1;10;25;1
|
||||
2;1;0;12;0;50;24;0
|
||||
2;3;30;13;1;38;38;0
|
||||
1;4;0;7;1;5;27;1
|
||||
1;2;0;16;1;10;25;1
|
||||
2;1;0;12;0;50;24;0
|
||||
2;3;30;13;1;38;38;0
|
||||
1;4;0;7;1;5;27;1
|
|
BIN
decisionTree/decision_tree_model.pkl
Normal file
BIN
decisionTree/decision_tree_model.pkl
Normal file
Binary file not shown.
9
decisionTree/evaluate.py
Normal file
9
decisionTree/evaluate.py
Normal file
@ -0,0 +1,9 @@
|
||||
import joblib
|
||||
|
||||
def evaluate(data):
|
||||
# Load the model
|
||||
clf = joblib.load('decisionTree/decision_tree_model.pkl')
|
||||
|
||||
# Make a prediction
|
||||
prediction = clf.predict(data)
|
||||
return prediction
|
21
decisionTree/prepare.py
Normal file
21
decisionTree/prepare.py
Normal file
@ -0,0 +1,21 @@
|
||||
import pandas as pd
|
||||
from sklearn.tree import DecisionTreeClassifier
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn import metrics
|
||||
import joblib
|
||||
|
||||
pima = pd.read_csv("data.csv", header=1, delimiter=';')
|
||||
|
||||
feature_cols = ['Size', 'Color', 'Sound', 'Time','Smell', 'Height','Temperature']
|
||||
X = pima[feature_cols]
|
||||
y = pima.ToRemove
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1)
|
||||
clf = DecisionTreeClassifier()
|
||||
clf = clf.fit(X_train,y_train)
|
||||
|
||||
joblib.dump(clf, 'decision_tree_model.pkl')
|
||||
|
||||
y_pred = clf.predict(X_test)
|
||||
|
||||
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
|
@ -13,3 +13,5 @@ class Cat(Entity):
|
||||
self.busy = False
|
||||
self.sleeping = False
|
||||
self.direction = 0
|
||||
|
||||
self.props = [1,2,0,16,1,10,25]
|
8
domain/entities/earring.py
Normal file
8
domain/entities/earring.py
Normal file
@ -0,0 +1,8 @@
|
||||
from domain.entities.entity import Entity
|
||||
from domain.world import World
|
||||
|
||||
|
||||
class Earring(Entity):
|
||||
def __init__(self, x: int, y: int):
|
||||
super().__init__(x, y, "EARRING")
|
||||
self.props = [2,1,0,12,0,50,24]
|
@ -1,11 +1,11 @@
|
||||
from domain.entities.entity import Entity
|
||||
from domain.world import World
|
||||
|
||||
|
||||
class Garbage(Entity):
|
||||
def __init__(self, x: int, y: int):
|
||||
super().__init__(x, y, "GARBAGE")
|
||||
super().__init__(x, y, "PEEL")
|
||||
self.wet = False
|
||||
self.size = 0
|
||||
self.props = [1,2,0,16,1,10,25]
|
||||
|
||||
# TODO GARBAGE: add more properties
|
||||
|
@ -35,6 +35,59 @@ class World:
|
||||
def is_docking_station_at(self, x: int, y: int) -> bool:
|
||||
return bool(self.doc_station.x == x and self.doc_station.y == y)
|
||||
|
||||
def accepted_move(self, checking_x, checking_y):
|
||||
if (
|
||||
checking_x > self.width - 1
|
||||
or checking_y > self.height - 1
|
||||
or checking_x < 0
|
||||
or checking_y < 0
|
||||
):
|
||||
return False
|
||||
|
||||
if self.is_obstacle_at(checking_x, checking_y):
|
||||
return False
|
||||
from decisionTree.evaluate import evaluate
|
||||
from domain.entities.entity import Entity
|
||||
|
||||
|
||||
class World:
|
||||
def __init__(self, width: int, height: int) -> object:
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.dust = [[[] for j in range(height)] for i in range(width)]
|
||||
self.obstacles = [[[] for j in range(height)] for i in range(width)]
|
||||
|
||||
self.vacuum = None
|
||||
self.cat = None
|
||||
self.doc_station = None
|
||||
|
||||
def add_entity(self, entity: Entity):
|
||||
if entity.type == "PEEL":
|
||||
self.dust[entity.x][entity.y].append(entity)
|
||||
elif entity.type == "EARRING":
|
||||
self.dust[entity.x][entity.y].append(entity)
|
||||
elif entity.type == "VACUUM":
|
||||
self.vacuum = entity
|
||||
elif entity.type == "DOC_STATION":
|
||||
self.doc_station = entity
|
||||
elif entity.type == "CAT":
|
||||
self.cat = entity
|
||||
self.obstacles[entity.x][entity.y].append(entity)
|
||||
else:
|
||||
self.obstacles[entity.x][entity.y].append(entity)
|
||||
|
||||
def is_obstacle_at(self, x: int, y: int) -> bool:
|
||||
return bool(self.obstacles[x][y])
|
||||
|
||||
def is_garbage_at(self, x: int, y: int) -> bool:
|
||||
if len(self.dust[x][y]) == 0:
|
||||
return False
|
||||
tmp = evaluate([self.dust[x][y][0].props])
|
||||
return bool(tmp[0])
|
||||
|
||||
def is_docking_station_at(self, x: int, y: int) -> bool:
|
||||
return bool(self.doc_station.x == x and self.doc_station.y == y)
|
||||
|
||||
def accepted_move(self, checking_x, checking_y):
|
||||
if (
|
||||
checking_x > self.width - 1
|
||||
@ -48,5 +101,7 @@ class World:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_cost(self, x, y):
|
||||
return self.costs[x][y]
|
11
main.py
11
main.py
@ -8,6 +8,8 @@ from domain.commands.vacuum_move_command import VacuumMoveCommand
|
||||
from domain.entities.cat import Cat
|
||||
from domain.entities.entity import Entity
|
||||
from domain.entities.vacuum import Vacuum
|
||||
from domain.entities.garbage import Garbage
|
||||
from domain.entities.earring import Earring
|
||||
from domain.entities.docking_station import Doc_Station
|
||||
from domain.world import World
|
||||
from view.renderer import Renderer
|
||||
@ -134,11 +136,11 @@ class Main:
|
||||
|
||||
def generate_world(tiles_x: int, tiles_y: int) -> World:
|
||||
world = World(tiles_x, tiles_y)
|
||||
for _ in range(35):
|
||||
for _ in range(10):
|
||||
temp_x = randint(0, tiles_x - 1)
|
||||
temp_y = randint(0, tiles_y - 1)
|
||||
world.add_entity(Entity(temp_x, temp_y, "PEEL"))
|
||||
world.vacuum = Vacuum(0, 0)
|
||||
world.add_entity(Garbage(temp_x, temp_y))
|
||||
world.vacuum = Vacuum(1, 1)
|
||||
world.doc_station = Doc_Station(9, 8)
|
||||
if config.getboolean("APP", "cat"):
|
||||
world.cat = Cat(7, 8)
|
||||
@ -148,7 +150,8 @@ def generate_world(tiles_x: int, tiles_y: int) -> World:
|
||||
world.add_entity(Entity(3, 4, "PLANT2"))
|
||||
world.add_entity(Entity(8, 8, "PLANT2"))
|
||||
world.add_entity(Entity(9, 3, "PLANT3"))
|
||||
world.add_entity(Entity(4, 0, "PLANT2"))
|
||||
world.add_entity(Earring(5, 5))
|
||||
|
||||
|
||||
for x in range(world.width):
|
||||
for y in range(world.height):
|
||||
|
BIN
media/sprites/earrings.webp
Normal file
BIN
media/sprites/earrings.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
@ -1,3 +1,6 @@
|
||||
pygame
|
||||
configparser
|
||||
formaFormatting: Provider - black
|
||||
pandas
|
||||
scikit-learn
|
||||
joblib
|
||||
# formaFormatting: Provider - black
|
@ -94,6 +94,13 @@ class Renderer:
|
||||
self.tile_height + self.tile_height / 4,
|
||||
),
|
||||
),
|
||||
"EARRING": pygame.transform.scale(
|
||||
pygame.image.load("media/sprites/earrings.webp"),
|
||||
(
|
||||
self.tile_width + self.tile_width / 4,
|
||||
self.tile_height + self.tile_height / 4,
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
self.cat_direction_sprite = {
|
||||
|
Loading…
Reference in New Issue
Block a user