IDE3 #12

Merged
s473556 merged 8 commits from IDE3 into main 2023-06-01 17:40:17 +02:00
9 changed files with 248 additions and 467 deletions
Showing only changes of commit 6df02452bc - Show all commits

View File

@ -7,6 +7,8 @@ from src.Tractor import Tractor
from src.Plant import Plant
from src.bfs import Astar
from src.Field import Field
import pickle
import os
# pygame initialization
@ -37,6 +39,9 @@ plant_group = pygame.sprite.Group()
plant_group = seedForFirstTime()
fields = return_fields_list()
#ID3 TREE
tree = pickle.load(open(os.path.join('src','tree.plk'),'rb'))
#
tractor_move = pygame.USEREVENT + 1
pygame.time.set_timer(tractor_move, 800)
@ -50,6 +55,7 @@ mx=int((mx+18)/36)
my=int((my+18)/36)
print("Destination: ", mx,my)
tmp = WORLD_MATRIX[mx][my]
print(tmp)
moves = goal_astar.search(
[tractor.rect.x, tractor.rect.y, directions[tractor.rotation]], destination)

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,14 @@
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
import pickle
import os
from sklearn import tree
import os
import pickle
import pydotplus
import matplotlib.image as pltimg
import matplotlib.pyplot as plt
# Read the CSV file
train = pd.read_csv("train_2.csv", delimiter=";")
train = pd.read_csv("train_3.csv", delimiter=";")
x_train = train.drop('czy_zebrac',axis=1)
y_train = train['czy_zebrac']
@ -16,21 +16,16 @@ y_train = train['czy_zebrac']
d_tree = DecisionTreeClassifier()
d_tree = d_tree.fit(x_train,y_train)
# Save the decision tree model as a pickle file in the script's folder
pickle.dump(d_tree, open('tree.plk', 'wb'))
# Export the decision tree as DOT data
data = tree.export_graphviz(d_tree, out_file=None)
# Create a graph from the DOT data
pickle.dump(d_tree, open(os.path.join('.','tree.plk'),'wb'))
data = tree.export_graphviz(d_tree, out_file=None, feature_names=['Wzrost','wilgotnosc','dni_od_nawiezienia','aktualna_pogoda','czy_roslina_robaczywa','paliwo','pojemnosc_ekwipunku','cena_sprzedarzy'])
graph = pydotplus.graph_from_dot_data(data)
# Save the graph as a PNG image in the script's folder
graph.write_png(os.path.join('.', 'mytree.png'))
# Read the PNG image
img = pltimg.imread(os.path.join('.', 'mytree.png'))
# img = pltimg.imread(os.path.join('.', 'mytree.png'))
# Display the image
imgplot = plt.imshow(img)
plt.show()
# imgplot = plt.imshow(img)
# plt.show()

View File

@ -1,6 +1,9 @@
import pygame
from settings import block_size, tile
mx=0
my=0
class Tractor(pygame.sprite.Sprite):
def __init__(self, engine, transmission, fuel, fertilizer, capacity):
super().__init__()
@ -24,6 +27,8 @@ class Tractor(pygame.sprite.Sprite):
self.transmission = transmission
self.fuel = fuel
self.fertilizer = fertilizer
def movement_using_keys(self):
keys = pygame.key.get_pressed()
@ -47,6 +52,7 @@ class Tractor(pygame.sprite.Sprite):
self.rect.y += block_size
if self.rect.x > 0 and self.rotation == 270:
self.rect.x -= block_size
def move_left(self):
self.rotation -= 90
@ -69,6 +75,7 @@ class Tractor(pygame.sprite.Sprite):
self.image = self.left
def movement(self, direction):
print(int((self.rect.x-18)/36),';',int((self.rect.y-18)/36))
if direction == 'F':
self.move_forward()
elif direction == 'L':

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -1,202 +0,0 @@
wzrost;wilgotnosc;dni_od_nawiezienia;aktualna_pogoda;czy_roslina_robaczywa;typ_rosliny;pojemnosc_ekwipunku;cena_sprzedarzy;czy_zebrac
54;19;15;0;0;0;90;66;0
64;63;5;0;0;0;16;4;0
93;0;29;0;1;0;77;73;1
30;43;23;0;1;0;74;75;1
48;30;10;0;0;0;39;23;0
44;86;2;0;1;0;41;64;0
99;74;8;0;1;0;39;37;0
70;80;25;0;1;0;11;90;1
62;35;2;0;1;0;53;57;0
32;71;29;0;1;0;21;54;1
59;27;11;0;0;0;71;68;0
43;97;24;0;0;0;82;70;0
24;49;1;0;0;0;22;40;0
60;59;18;0;1;0;29;99;1
100;87;23;0;1;0;69;55;1
5;88;24;0;1;0;54;87;1
35;92;17;0;1;0;30;100;1
9;89;29;0;0;0;35;24;0
58;7;11;0;1;0;6;62;1
98;88;1;0;1;0;100;88;0
14;74;7;0;1;0;71;24;0
6;67;18;0;0;0;72;12;0
53;41;25;0;0;0;45;56;0
35;40;1;0;0;0;61;36;0
93;17;15;0;1;0;63;0;1
20;70;19;0;1;0;14;88;1
12;57;24;0;1;0;10;90;1
59;67;7;0;0;0;35;90;0
79;29;8;0;1;0;59;37;0
48;81;14;0;1;0;85;78;1
41;32;8;0;0;0;5;26;0
6;62;1;0;0;0;75;22;0
18;74;5;0;1;0;9;32;0
62;44;7;0;0;0;0;87;0
34;19;14;0;0;0;83;92;0
84;39;15;0;1;0;8;86;1
55;39;4;0;1;0;31;63;0
17;58;2;0;1;0;33;22;0
95;12;17;0;0;0;51;16;0
85;91;5;0;1;0;19;8;0
62;87;1;0;1;0;22;48;0
50;21;15;0;0;0;76;55;0
21;84;8;0;0;0;63;87;0
87;36;9;0;0;0;62;69;0
60;85;22;0;0;0;98;24;0
72;0;18;0;1;0;31;36;1
60;41;29;0;1;0;11;60;1
43;50;20;0;1;0;53;66;1
56;24;10;0;1;0;91;87;1
30;75;29;0;0;0;83;36;0
86;62;13;0;1;0;97;26;1
69;35;10;0;1;0;25;100;1
98;55;11;0;0;0;66;18;0
71;23;26;0;1;0;47;88;1
97;88;0;0;1;0;37;55;0
89;90;17;0;0;0;50;47;0
84;44;1;0;0;0;99;86;0
57;72;12;0;1;0;85;44;1
89;65;20;0;0;0;39;16;0
31;100;7;0;0;0;64;66;0
45;47;3;0;1;0;76;35;0
21;52;27;0;1;0;90;15;1
7;30;8;0;0;0;39;70;0
42;67;27;0;0;0;72;82;0
88;69;28;0;1;0;85;63;1
84;62;21;0;1;0;43;16;1
41;62;25;0;1;0;26;24;1
18;39;9;0;1;0;70;96;0
75;60;16;0;1;0;37;64;1
66;9;29;0;1;0;3;84;1
2;92;25;0;0;0;2;19;0
100;20;11;0;0;0;45;65;0
21;19;8;0;1;0;82;2;0
93;37;10;0;0;0;57;3;0
35;12;5;0;1;0;48;96;0
62;12;4;0;0;0;94;1;0
82;73;12;0;1;0;66;81;1
43;74;15;0;1;0;43;70;1
54;76;11;0;1;0;80;88;1
51;64;26;0;1;0;31;21;1
14;12;12;0;1;0;97;17;1
58;59;22;0;0;0;79;36;0
17;48;17;0;0;0;81;72;0
47;2;12;0;1;0;3;22;1
38;52;13;0;0;0;31;46;0
32;19;4;0;1;0;30;85;0
9;28;29;0;0;0;20;46;0
98;0;15;0;1;0;72;15;1
95;33;0;0;1;0;33;11;0
55;56;10;0;0;0;28;56;0
18;22;13;0;0;0;94;90;0
81;28;17;0;1;0;95;29;1
96;6;6;0;0;0;14;89;0
58;26;24;0;0;0;70;76;0
83;33;16;0;1;0;31;54;1
90;48;29;0;1;0;55;40;1
65;72;4;0;1;0;70;10;0
74;100;14;0;1;0;44;24;1
56;25;30;0;1;0;84;16;1
14;75;29;0;1;0;42;9;1
90;51;2;0;1;0;86;79;0
60;31;25;0;0;0;43;54;0
74;1;2;0;0;0;17;76;0
86;72;16;0;1;0;38;53;1
70;69;19;0;0;0;40;63;0
37;18;24;0;1;0;84;78;1
48;77;7;0;0;0;99;42;0
90;92;5;0;0;0;80;48;0
99;74;9;0;1;0;41;68;0
58;18;5;0;1;0;53;94;0
42;22;10;0;1;0;24;17;1
44;34;29;0;0;0;86;8;0
79;13;0;0;0;0;31;43;0
16;54;28;0;0;0;26;84;0
44;44;12;0;0;0;60;94;0
36;6;9;0;0;0;90;90;0
33;43;5;0;1;0;5;86;0
24;5;0;0;0;0;47;41;0
87;67;11;0;1;0;70;32;1
62;76;6;0;1;0;33;96;0
48;85;25;0;1;0;41;12;1
31;15;13;0;1;0;87;18;1
27;69;2;0;0;0;38;2;0
4;98;24;0;1;0;22;22;1
61;50;20;0;0;0;14;0;0
2;31;29;0;1;0;40;0;1
53;19;29;0;0;0;34;100;0
64;71;13;0;1;0;65;66;1
86;67;15;0;1;0;69;34;1
33;63;4;0;0;0;87;24;0
22;84;8;0;0;0;73;13;0
54;64;10;0;1;0;13;65;1
51;25;4;0;1;0;26;0;0
1;95;14;0;0;0;83;64;0
8;32;19;0;1;0;96;77;1
47;97;10;0;1;0;74;16;1
30;65;24;0;0;0;83;89;0
76;58;7;0;0;0;73;86;0
84;41;17;0;1;0;68;78;1
50;61;9;0;0;0;6;72;0
37;12;8;0;1;0;11;46;0
7;91;29;0;0;0;1;7;0
64;69;4;0;1;0;57;28;0
21;71;3;0;0;0;53;23;0
58;54;13;0;0;0;19;1;0
96;11;22;0;0;0;46;12;0
85;41;2;0;1;0;28;24;0
58;11;13;0;0;0;90;41;0
49;8;30;0;0;0;63;39;0
70;72;9;0;0;0;56;65;0
82;39;20;0;1;0;98;55;1
43;67;28;0;0;0;33;27;0
70;48;6;0;1;0;58;2;0
10;89;0;0;0;0;46;52;0
73;18;24;0;0;0;65;40;0
84;29;26;0;1;0;80;30;1
32;83;0;0;0;0;68;100;0
17;40;14;0;1;0;47;44;1
5;77;30;0;1;0;44;65;1
27;95;29;0;1;0;71;81;1
27;39;15;0;1;0;22;13;1
81;96;23;0;1;0;61;89;1
84;58;19;0;1;0;84;62;1
23;40;21;0;0;0;64;13;0
57;61;20;0;0;0;84;10;0
31;55;3;0;0;0;98;26;0
25;33;2;0;1;0;68;75;0
56;15;6;0;1;0;34;51;0
45;60;20;0;0;0;9;51;0
14;42;19;0;0;0;49;46;0
41;100;17;0;0;0;71;18;0
38;38;20;0;1;0;41;5;1
73;99;17;0;0;0;99;45;0
43;62;21;0;1;0;57;58;1
99;31;18;0;1;0;51;52;1
83;4;9;0;1;0;3;65;0
53;71;26;0;0;0;93;78;0
18;28;13;0;1;0;34;76;1
22;29;29;0;1;0;47;68;1
96;40;9;0;1;0;91;51;0
24;74;9;0;1;0;57;4;0
58;56;1;0;1;0;17;40;0
43;39;20;0;0;0;81;77;0
24;6;9;0;1;0;90;42;0
32;100;16;0;0;0;56;71;0
75;25;6;0;0;0;48;18;0
80;96;27;0;0;0;62;84;0
57;90;19;0;0;0;81;26;0
1;18;12;0;0;0;4;0;0
28;79;11;0;1;0;95;19;1
20;4;11;0;0;0;96;64;0
37;80;14;0;1;0;97;64;1
2;24;23;0;0;0;63;52;0
54;97;18;0;1;0;20;65;1
42;44;20;0;0;0;33;20;0
68;51;12;0;1;0;76;90;1
93;77;24;0;1;0;41;59;1
74;94;21;0;1;0;17;39;1
63;63;26;0;1;0;67;2;1
65;73;1;0;0;0;74;40;0
100;39;19;0;0;0;41;9;0
Internal Server Error - Gitea: Git with a cup of tea

Internal Server Error