IDE3 #12
Binary file not shown.
202
assets/data/train_2.csv
Normal file
202
assets/data/train_2.csv
Normal file
@ -0,0 +1,202 @@
|
||||
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
|
|
48
main.py
48
main.py
@ -2,10 +2,15 @@ import pygame
|
||||
import sys
|
||||
import random
|
||||
from settings import screen_height, screen_width, SIZE, SPECIES, block_size, tile, road_coords, directions
|
||||
from src.map import drawRoads, seedForFirstTime, return_fields_list
|
||||
from src.map import drawRoads, seedForFirstTime, return_fields_list, WORLD_MATRIX
|
||||
from src.Tractor import Tractor
|
||||
from src.Plant import Plant
|
||||
from src.bfs import Astar
|
||||
from src.Plant import Plant
|
||||
from src.Field import Field
|
||||
import pickle
|
||||
import os
|
||||
from src.ID3 import make_decision
|
||||
|
||||
|
||||
# pygame initialization
|
||||
pygame.init()
|
||||
@ -30,18 +35,53 @@ tractor = Tractor('oil','manual', 'fuel', 'fertilizer1', 20)
|
||||
tractor_group = pygame.sprite.Group()
|
||||
tractor_group.add(tractor)
|
||||
|
||||
tractor.setCapacity(90)
|
||||
tractor.setFuel(100)
|
||||
|
||||
#PLANTS
|
||||
plant_group = pygame.sprite.Group()
|
||||
plant_group = seedForFirstTime()
|
||||
fields = return_fields_list()
|
||||
|
||||
|
||||
|
||||
#
|
||||
tractor_move = pygame.USEREVENT + 1
|
||||
pygame.time.set_timer(tractor_move, 800)
|
||||
moves = []
|
||||
goal_astar = Astar()
|
||||
destination = (random.randrange(0, 936, 36), random.randrange(0, 900, 36))
|
||||
mx=random.randrange(0, 936, 36)
|
||||
my=random.randrange(0, 936, 36)
|
||||
destination = (mx, my)
|
||||
print("Destination: ", destination)
|
||||
mx=int((mx+18)/36)
|
||||
my=int((my+18)/36)
|
||||
print("Destination: ", mx,my)
|
||||
|
||||
#ID3 TREE LOADING
|
||||
dtree = pickle.load(open(os.path.join('src','tree.plk'),'rb'))
|
||||
|
||||
# pobierz dane o polu field i czy ma na sobie roslinke, zadecyduj czy zebrac
|
||||
this_field = WORLD_MATRIX[mx][my]
|
||||
this_contain = Field.getContain(this_field)
|
||||
if isinstance(this_contain, Plant):
|
||||
this_plant = this_contain
|
||||
params=Plant.getParameters(this_plant)
|
||||
#ID3 decision
|
||||
decision=make_decision(params[0],params[1],params[2],params[3],params[4],tractor.fuel,tractor.capacity,params[5],dtree)
|
||||
print('wzorst',params[0],'wilgotnosc',params[1],'dni_od_nawiezienia',params[2],'pogoda',params[3],'zdrowa',params[4],'paliwo',tractor.fuel,'pojemnosc eq',tractor.capacity,'cena sprzedazy',params[5])
|
||||
print(decision)
|
||||
if decision == 1:
|
||||
# Tractor.collect(self=tractor, plant_group=plant_group)
|
||||
print('Gotowe do zbioru')
|
||||
else:
|
||||
# decision = 1
|
||||
print('nie zbieramy')
|
||||
|
||||
else:
|
||||
print('Road, no plant growing')
|
||||
|
||||
|
||||
moves = goal_astar.search(
|
||||
[tractor.rect.x, tractor.rect.y, directions[tractor.rotation]], destination)
|
||||
|
||||
@ -67,6 +107,8 @@ if __name__ == "__main__":
|
||||
step = moves_list.pop() # pop the last element
|
||||
moves = tuple(moves_list) # convert back to tuple
|
||||
tractor.movement(step[0])
|
||||
if (tractor.rect.x, tractor.rect.y) == destination and decision == 1:
|
||||
tractor.collect(plant_group)
|
||||
|
||||
|
||||
Tractor.movement_using_keys(tractor)
|
||||
|
BIN
mytree.png
Normal file
BIN
mytree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
@ -1,10 +1,13 @@
|
||||
from cmath import sqrt
|
||||
|
||||
|
||||
# screen_width=1200
|
||||
screen_width=936
|
||||
# screen_height=1000
|
||||
screen_height=936
|
||||
SIZE = (screen_width, screen_height)
|
||||
SPECIES=["carrot","potato","beetroot","wheat"]
|
||||
WEATHER=['slonce','wiatr','snieg','deszcz']
|
||||
# size in pixels of one tile = 36px/36px
|
||||
tile = (36, 36)
|
||||
block_size = 36
|
||||
@ -12,6 +15,6 @@ road_coords = [0, 5, 10, 15, 20, 25]
|
||||
field_width = 4
|
||||
field_height = 4
|
||||
field_size = field_width*field_height
|
||||
fields_amount = 26
|
||||
fields_amount = 25
|
||||
|
||||
directions = {0: 'UP', 90: 'RIGHT', 180: 'DOWN', 270: 'LEFT'}
|
11
src/Field.py
11
src/Field.py
@ -1,8 +1,9 @@
|
||||
from pygame.sprite import Sprite
|
||||
from src.Plant import Plant
|
||||
|
||||
class Field(Sprite):
|
||||
def __init__(self, type, x, y, image, cost, hydration_level , soil,
|
||||
fertilizer_degree, development_degree, plant_type, fertilizer_type, to_water):
|
||||
fertilizer_degree, development_degree, plant_type, fertilizer_type, to_water, contain):
|
||||
super().__init__()
|
||||
self.type = type
|
||||
self.x = x
|
||||
@ -18,4 +19,12 @@ class Field(Sprite):
|
||||
self.plant_type = plant_type
|
||||
self.fertilizer_type = fertilizer_type
|
||||
self.to_water = to_water
|
||||
self.contain = contain
|
||||
|
||||
def getContain(self):
|
||||
return self.contain
|
||||
|
||||
def setContain(self,newPlant):
|
||||
self.contain=newPlant
|
||||
|
||||
|
||||
|
90
src/ID3.ipynb
Normal file
90
src/ID3.ipynb
Normal file
File diff suppressed because one or more lines are too long
44
src/ID3.py
Normal file
44
src/ID3.py
Normal file
@ -0,0 +1,44 @@
|
||||
import pandas as pd
|
||||
from sklearn.tree import DecisionTreeClassifier
|
||||
from sklearn import tree
|
||||
import os
|
||||
import pickle
|
||||
import pydotplus
|
||||
import matplotlib.image as pltimg
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def make_decision(Wzrost, wilgotnosc, dni_od_nawiezienia, aktualna_pogoda, czy_roslina_robaczywa, paliwo, pojemnosc_ekwipunku,cena_sprzedarzy, tree):
|
||||
decision = tree.predict([[Wzrost,wilgotnosc, dni_od_nawiezienia, aktualna_pogoda, czy_roslina_robaczywa, paliwo, pojemnosc_ekwipunku,cena_sprzedarzy]])
|
||||
return decision
|
||||
|
||||
def learnTree():
|
||||
# Read the CSV file
|
||||
train = pd.read_csv("./train_3.csv")
|
||||
|
||||
print(f'Shape: {train.shape}')
|
||||
print(f'Head:\n{train.head()}')
|
||||
|
||||
x_train = train.drop('czy_zebrac',axis=1)
|
||||
y_train = train['czy_zebrac']
|
||||
|
||||
d_tree = DecisionTreeClassifier()
|
||||
d_tree = d_tree.fit(x_train,y_train)
|
||||
|
||||
pickle.dump(d_tree, open(os.path.join('.','tree.plk'),'wb')) #1-4 1 śnieg, 2 deszcz, 3 wiatr, 4 slonce
|
||||
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'))
|
||||
imgplot = plt.imshow(img)
|
||||
plt.show()
|
||||
|
||||
return d_tree
|
||||
|
||||
# dtree = learnTree() #w, w, d, p,R,P,P,S
|
||||
# #przy robaczywej == 1 daje ok czyli jak 1 to git jest mozna zbierac, ale planowalem inaczej
|
||||
# decision=make_decision(70,85,12,4,0,65,54,1500,dtree)
|
||||
# print(decision)
|
21
src/Plant.py
21
src/Plant.py
@ -2,11 +2,24 @@ import pygame
|
||||
from settings import block_size
|
||||
|
||||
class Plant(pygame.sprite.Sprite):
|
||||
def __init__(self,species,is_ill,pos_x,pos_y):
|
||||
def __init__(self,wzrost,
|
||||
wilgotnosc,
|
||||
dni_od_nawiezienia,
|
||||
aktualna_pogoda,
|
||||
czy_robaczywa,
|
||||
cena_sprzedarzy,
|
||||
species,
|
||||
pos_x,
|
||||
pos_y):
|
||||
|
||||
super().__init__()
|
||||
self.species=species
|
||||
self.is_ill=is_ill
|
||||
|
||||
self.wzrost=wzrost
|
||||
self.wilgotnosc=wilgotnosc
|
||||
self.dni_od_nawiezienia=dni_od_nawiezienia
|
||||
self.aktualna_pogoda=aktualna_pogoda
|
||||
self.czy_robaczywa=czy_robaczywa
|
||||
self.cena_sprzedarzy=cena_sprzedarzy
|
||||
if species=="carrot":
|
||||
self.growth_time=100
|
||||
self.weight=50
|
||||
@ -48,3 +61,5 @@ class Plant(pygame.sprite.Sprite):
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.center = [pos_x,pos_y]
|
||||
|
||||
def getParameters(self):
|
||||
return [self.wzrost, self.wilgotnosc, self.dni_od_nawiezienia,self.aktualna_pogoda,self.czy_robaczywa,self.cena_sprzedarzy]
|
9
src/Road.py
Normal file
9
src/Road.py
Normal file
@ -0,0 +1,9 @@
|
||||
from pygame.sprite import Sprite
|
||||
|
||||
class Road(Sprite):
|
||||
def __init__(self,x,y):
|
||||
super().__init__()
|
||||
self.x=x
|
||||
self.y=y
|
||||
self.type='Road'
|
||||
self.cost=200
|
@ -1,5 +1,12 @@
|
||||
import pygame
|
||||
from settings import block_size, tile
|
||||
import pickle
|
||||
from sklearn import tree
|
||||
|
||||
mx=0
|
||||
my=0
|
||||
|
||||
|
||||
|
||||
class Tractor(pygame.sprite.Sprite):
|
||||
def __init__(self, engine, transmission, fuel, fertilizer, capacity):
|
||||
@ -19,11 +26,20 @@ class Tractor(pygame.sprite.Sprite):
|
||||
self.rotation = 90
|
||||
|
||||
self.collected = 0
|
||||
self.capacity = capacity
|
||||
self.engine = engine
|
||||
self.transmission = transmission
|
||||
self.fuel = fuel
|
||||
self.fertilizer = fertilizer
|
||||
self.capacity = capacity
|
||||
self.fuel = fuel
|
||||
|
||||
|
||||
|
||||
def setFuel(self,fuelLevel):
|
||||
self.fuel=fuelLevel
|
||||
|
||||
def setCapacity(self, newCapacity):
|
||||
self.capacity = newCapacity
|
||||
|
||||
|
||||
def movement_using_keys(self):
|
||||
keys = pygame.key.get_pressed()
|
||||
@ -48,6 +64,7 @@ class Tractor(pygame.sprite.Sprite):
|
||||
if self.rect.x > 0 and self.rotation == 270:
|
||||
self.rect.x -= block_size
|
||||
|
||||
|
||||
def move_left(self):
|
||||
self.rotation -= 90
|
||||
if self.rotation < 0:
|
||||
@ -69,6 +86,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':
|
||||
@ -101,3 +119,7 @@ class Tractor(pygame.sprite.Sprite):
|
||||
def find_nearest_plant(self, plant_group):
|
||||
self.plant_group = plant_group
|
||||
|
||||
def getLocation(self):
|
||||
return [self.rect.x, self.rect.y]
|
||||
|
||||
|
BIN
src/__pycache__/Field.cpython-310.pyc
Normal file
BIN
src/__pycache__/Field.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/ID3.cpython-310.pyc
Normal file
BIN
src/__pycache__/ID3.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/__pycache__/Road.cpython-310.pyc
Normal file
BIN
src/__pycache__/Road.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
65
src/map.py
65
src/map.py
@ -4,6 +4,8 @@ from settings import screen_height, screen_width, SIZE, SPECIES, block_size, til
|
||||
from src.Plant import Plant
|
||||
import random
|
||||
from src.Field import Field
|
||||
from src.Road import Road
|
||||
import csv
|
||||
|
||||
|
||||
def get_type_by_position(fields, x, y):
|
||||
@ -30,18 +32,28 @@ def get_cost_by_type(plant_type):
|
||||
|
||||
fields = pygame.sprite.Group()
|
||||
|
||||
|
||||
WORLD_MATRIX = [[0 for _ in range(fields_amount+1)] for _ in range(fields_amount+1)]
|
||||
|
||||
def drawRoads(screen):
|
||||
#drawing roads:
|
||||
road = pygame.image.load("assets/road.jpeg")
|
||||
road = pygame.transform.scale(road, tile)
|
||||
for x in road_coords:
|
||||
for block in range(26):
|
||||
for block in range(int(fields_amount)+1):
|
||||
screen.blit(road, (x*block_size, block * 36))
|
||||
fields.add(Field('road', x*block_size, block * 36, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None))
|
||||
new_road = Road(x,block)
|
||||
tmp_field=Field('road', x*block_size, block * 36, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None,contain=new_road)
|
||||
fields.add(tmp_field)
|
||||
WORLD_MATRIX[x][block]=tmp_field
|
||||
for y in road_coords:
|
||||
for block in range(26):
|
||||
screen.blit(road, (block * 36, y*block_size))
|
||||
fields.add(Field('road', block * 36, y*block_size, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None))
|
||||
for block in range(int(fields_amount)+1):
|
||||
screen.blit(road, (block * block_size, y*block_size))
|
||||
new_road = Road(block,y)
|
||||
tmp_field=Field('road', block * block_size, y*block_size, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None,contain=new_road)
|
||||
fields.add(tmp_field)
|
||||
WORLD_MATRIX[block][y]=tmp_field
|
||||
|
||||
|
||||
barn_img = pygame.image.load('assets/barn.png')
|
||||
barn = pygame.transform.scale(barn_img, tile)
|
||||
@ -52,17 +64,54 @@ def drawRoads(screen):
|
||||
def seedForFirstTime():
|
||||
plant_group = pygame.sprite.Group()
|
||||
for field in range(fields_amount):
|
||||
plant = random.choice(SPECIES)
|
||||
plant_name = random.choice(SPECIES)
|
||||
blocks_seeded_in_field = 0
|
||||
while (blocks_seeded_in_field < field_size):
|
||||
|
||||
x = (((field%5)*((block_size*(field_width+1)))) + ((blocks_seeded_in_field % field_width)*block_size) + ((3/2)*block_size))
|
||||
y = ((int(field/5)*((block_size*(field_width+1)))) + ((int(blocks_seeded_in_field/field_height))*block_size) + ((3/2)*block_size))
|
||||
new_plant = Plant(plant,0, x, y)
|
||||
# wzrost;wilgotnosc;dni_od_nawiezienia;aktualna_pogoda;czy_roslina_robaczywa;typ_rosliny;pojemnosc_ekwipunku;cena_sprzedarzy;czy_zebrac
|
||||
|
||||
new_plant = Plant(
|
||||
wzrost=random.randint(0, 100),
|
||||
wilgotnosc=random.randint(0, 100),
|
||||
dni_od_nawiezienia=random.randint(0, 31),
|
||||
aktualna_pogoda=random.randint(1,4),
|
||||
czy_robaczywa=random.randint(0,1),
|
||||
cena_sprzedarzy=random.randint(1000, 2000),
|
||||
species=plant_name,
|
||||
pos_x=x,
|
||||
pos_y=y)
|
||||
|
||||
# BOOSTED PLANTS
|
||||
# new_plant = Plant(
|
||||
# wzrost=random.randint(90, 100),
|
||||
# wilgotnosc=random.randint(0, 50),
|
||||
# dni_od_nawiezienia=random.randint(15, 31),
|
||||
# aktualna_pogoda=random.randint(3,4),
|
||||
# czy_robaczywa=0,
|
||||
# cena_sprzedarzy=random.randint(1500, 2000),
|
||||
# species=plant_name,
|
||||
# pos_x=x,
|
||||
# pos_y=y)
|
||||
blocks_seeded_in_field = blocks_seeded_in_field + 1
|
||||
plant_group.add(new_plant)
|
||||
fields.add(Field('field', x-18, y-18, None, get_cost_by_type(plant), None, None, None, None, plant, None, None))
|
||||
tmp_field_plant = Field('field', x-18, y-18, None, get_cost_by_type(plant_name), None, None, None, None, plant_name, None, None, contain=new_plant)
|
||||
fields.add(tmp_field_plant)
|
||||
|
||||
mx = int((x-18)/36)
|
||||
my = int((y-18)/36)
|
||||
WORLD_MATRIX[mx][my]=tmp_field_plant
|
||||
|
||||
#debug
|
||||
# print(WORLD_MATRIX)
|
||||
#end of debug
|
||||
|
||||
return plant_group
|
||||
|
||||
def put_to_matrix():
|
||||
return 0
|
||||
|
||||
def return_fields_list():
|
||||
return fields
|
||||
|
||||
|
BIN
src/mytree.png
Normal file
BIN
src/mytree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 KiB |
202
src/train_3.csv
Normal file
202
src/train_3.csv
Normal file
@ -0,0 +1,202 @@
|
||||
Wzrost,wilgotnosc,dni_od_nawiezienia,aktualna_pogoda,czy_roslina_robaczywa,paliwo,pojemnosc_ekwipunku,cena_sprzedarzy,czy_zebrac
|
||||
23,78,12,2,1,78,88,1377,0
|
||||
39,31,15,4,1,82,37,1969,0
|
||||
12,41,21,2,1,62,28,994,0
|
||||
2,42,11,1,1,68,96,1291,0
|
||||
43,16,20,3,0,91,23,1653,0
|
||||
9,8,8,1,1,78,28,1709,0
|
||||
47,0,23,2,0,94,46,1702,1
|
||||
70,85,12,3,1,65,14,1758,0
|
||||
34,76,15,2,0,80,13,1461,1
|
||||
22,24,6,3,0,17,19,681,0
|
||||
79,9,17,4,0,94,75,1244,1
|
||||
56,30,0,3,1,43,55,542,0
|
||||
45,34,12,3,1,93,80,1967,0
|
||||
49,15,26,1,1,48,76,1095,0
|
||||
69,16,13,4,1,10,13,1558,0
|
||||
74,97,9,1,1,97,25,1940,0
|
||||
37,40,19,4,0,65,81,693,0
|
||||
83,26,3,2,0,91,62,1676,1
|
||||
52,37,0,3,0,93,4,1756,0
|
||||
67,68,30,4,0,34,3,626,1
|
||||
96,93,18,4,0,42,5,961,0
|
||||
90,22,11,3,1,59,69,824,1
|
||||
38,10,17,4,1,57,33,1479,0
|
||||
62,51,23,3,1,55,60,587,0
|
||||
64,44,5,2,1,92,85,1058,0
|
||||
93,87,25,2,0,61,41,1012,1
|
||||
46,45,16,4,1,85,46,1609,0
|
||||
12,41,28,4,0,26,42,1570,0
|
||||
40,27,23,3,0,66,100,1161,1
|
||||
0,53,20,1,1,52,61,1636,0
|
||||
31,10,3,1,1,97,87,1325,0
|
||||
40,72,0,2,1,39,39,1884,0
|
||||
19,19,27,3,1,25,68,978,0
|
||||
44,85,11,4,1,49,78,754,0
|
||||
83,60,11,3,1,56,68,1240,0
|
||||
6,85,2,2,1,33,46,793,0
|
||||
99,83,18,4,0,37,81,1559,1
|
||||
87,54,13,2,1,84,26,1671,0
|
||||
27,96,0,1,1,20,55,1332,0
|
||||
44,79,30,1,1,77,43,752,0
|
||||
14,84,26,4,0,13,13,1032,0
|
||||
11,84,28,1,1,43,55,1131,0
|
||||
75,10,19,3,0,94,22,1507,1
|
||||
88,52,20,2,1,17,87,1218,0
|
||||
38,81,14,1,0,86,91,1843,0
|
||||
35,34,12,1,1,36,69,1522,0
|
||||
87,19,16,3,0,66,36,1412,1
|
||||
23,87,5,1,1,69,54,1911,0
|
||||
66,98,17,3,1,81,82,1725,0
|
||||
39,32,29,4,0,39,48,1378,0
|
||||
29,7,15,4,0,57,93,1112,0
|
||||
80,54,7,2,0,37,22,953,0
|
||||
33,70,19,2,1,85,80,797,0
|
||||
81,55,2,2,1,20,10,700,0
|
||||
77,9,29,2,0,10,21,1372,1
|
||||
34,20,4,4,0,54,41,1046,0
|
||||
16,52,28,1,0,18,33,671,0
|
||||
41,47,17,1,0,42,36,1100,0
|
||||
46,25,0,3,0,19,52,590,1
|
||||
89,4,13,3,1,10,14,1500,0
|
||||
88,6,26,2,0,70,27,960,0
|
||||
87,4,20,2,0,28,22,1584,1
|
||||
93,78,21,2,1,94,6,1447,0
|
||||
51,58,20,3,0,82,40,1252,1
|
||||
99,12,21,4,1,83,18,1441,0
|
||||
6,17,11,2,1,100,91,1896,0
|
||||
96,50,24,3,0,39,58,1949,1
|
||||
94,98,14,2,0,29,11,1286,0
|
||||
79,13,21,2,1,76,85,1933,0
|
||||
56,71,28,2,1,33,89,1232,0
|
||||
46,19,26,4,0,52,58,1412,1
|
||||
27,81,28,2,1,77,71,1717,0
|
||||
6,35,22,2,1,76,60,1676,0
|
||||
99,80,29,1,0,13,19,1824,0
|
||||
24,23,22,2,1,10,66,917,0
|
||||
48,91,26,4,0,61,41,1740,1
|
||||
67,71,21,3,1,100,99,1171,0
|
||||
60,29,25,3,0,20,79,1384,1
|
||||
34,65,0,4,0,76,29,1428,0
|
||||
6,56,2,2,1,63,25,1063,0
|
||||
77,31,27,2,1,42,51,1966,0
|
||||
65,28,0,2,0,29,69,1207,0
|
||||
84,75,0,2,0,23,36,644,0
|
||||
10,13,14,2,1,57,2,956,0
|
||||
48,58,8,2,1,69,56,1922,0
|
||||
71,16,27,3,1,100,56,1274,0
|
||||
43,97,29,2,1,30,37,637,0
|
||||
2,91,29,2,0,88,60,1084,0
|
||||
70,67,19,1,0,100,55,859,0
|
||||
63,74,10,2,1,92,69,1108,0
|
||||
88,69,13,4,0,27,38,1041,1
|
||||
78,67,27,4,0,59,28,1402,1
|
||||
58,69,28,3,0,52,23,1360,1
|
||||
79,60,30,4,1,24,38,1318,0
|
||||
88,98,10,1,0,71,30,1906,0
|
||||
90,89,28,1,0,23,17,1499,0
|
||||
31,32,29,4,1,82,45,1735,0
|
||||
57,50,20,1,0,12,94,1701,0
|
||||
20,88,3,2,1,44,94,867,0
|
||||
24,71,3,1,0,40,19,1488,0
|
||||
50,46,2,2,0,70,96,1356,0
|
||||
78,46,11,2,1,99,49,1086,0
|
||||
43,98,10,3,0,12,87,1490,1
|
||||
23,41,12,1,0,94,29,757,0
|
||||
98,37,8,3,0,49,99,663,0
|
||||
84,82,24,3,0,36,79,655,1
|
||||
56,78,16,3,0,34,89,510,0
|
||||
79,39,1,4,1,62,54,1186,0
|
||||
92,31,17,1,1,55,15,671,0
|
||||
4,32,15,3,1,95,60,829,0
|
||||
74,28,16,1,0,52,70,1264,0
|
||||
12,2,28,4,1,21,54,1746,0
|
||||
43,51,16,3,0,67,45,1239,1
|
||||
30,36,14,3,1,63,15,987,0
|
||||
55,46,19,4,1,81,57,1295,0
|
||||
74,95,5,2,1,52,29,1276,0
|
||||
66,64,13,2,0,19,84,1269,1
|
||||
60,73,11,4,0,41,3,1241,1
|
||||
100,90,7,3,1,54,3,537,0
|
||||
84,90,15,2,1,59,16,673,0
|
||||
74,28,20,2,0,17,95,748,1
|
||||
7,63,11,2,0,46,5,734,0
|
||||
61,79,16,3,1,84,56,531,0
|
||||
13,4,0,1,0,73,51,1648,0
|
||||
94,32,3,1,1,13,4,1785,0
|
||||
85,72,14,3,0,10,56,989,1
|
||||
62,70,24,1,1,44,45,1356,0
|
||||
26,11,9,1,0,92,10,761,0
|
||||
78,56,1,1,0,10,99,1925,0
|
||||
85,55,23,4,0,89,83,1690,1
|
||||
34,83,11,1,1,30,74,1388,0
|
||||
69,34,14,4,0,57,60,1498,1
|
||||
91,12,23,1,0,32,43,1081,0
|
||||
23,54,27,2,1,53,54,912,0
|
||||
47,80,24,1,0,23,33,1558,0
|
||||
79,40,27,3,0,13,78,1229,1
|
||||
29,40,11,3,0,96,48,1391,0
|
||||
29,15,22,1,0,22,93,1274,0
|
||||
59,28,1,2,1,22,63,1543,0
|
||||
33,55,5,1,0,32,29,1590,0
|
||||
88,67,2,2,1,61,93,708,0
|
||||
75,41,19,3,1,47,64,1696,0
|
||||
48,53,21,3,1,39,2,1235,0
|
||||
1,96,9,2,0,98,13,982,0
|
||||
10,90,22,2,0,23,12,788,0
|
||||
58,70,6,4,0,96,83,1039,1
|
||||
67,71,19,3,1,90,93,1454,0
|
||||
2,78,8,1,1,62,48,1673,0
|
||||
97,12,19,4,1,97,70,1419,0
|
||||
83,93,5,2,1,73,12,1664,0
|
||||
42,49,4,3,0,39,72,607,1
|
||||
69,52,29,3,1,94,26,1238,0
|
||||
60,84,0,2,0,43,70,1459,1
|
||||
15,27,7,2,1,92,6,1141,0
|
||||
7,54,13,3,1,68,70,1453,0
|
||||
34,38,7,4,0,86,58,1474,0
|
||||
43,40,15,4,1,61,83,1320,0
|
||||
96,66,22,1,1,94,43,1737,0
|
||||
9,26,18,2,1,41,5,735,0
|
||||
94,96,30,4,0,26,47,728,1
|
||||
41,80,8,4,0,34,1,914,1
|
||||
34,3,3,2,0,33,48,1516,0
|
||||
47,73,23,3,0,53,53,746,1
|
||||
19,26,25,3,0,27,45,613,0
|
||||
43,52,14,1,1,90,32,567,0
|
||||
1,0,12,1,1,94,11,971,0
|
||||
52,22,28,2,1,100,24,804,0
|
||||
24,25,13,2,0,97,0,1481,0
|
||||
68,8,1,3,1,39,71,706,0
|
||||
91,12,13,2,0,15,39,844,1
|
||||
53,55,12,1,1,53,17,1288,0
|
||||
70,91,26,1,1,33,24,603,0
|
||||
1,77,14,4,1,88,96,1419,0
|
||||
93,59,5,2,0,43,28,959,1
|
||||
71,27,27,4,1,33,17,1158,0
|
||||
86,72,5,1,0,34,38,1571,0
|
||||
15,84,29,4,0,66,71,1204,0
|
||||
1,16,30,1,0,18,6,1299,0
|
||||
38,34,28,3,0,60,72,1849,0
|
||||
43,94,20,3,1,73,84,530,0
|
||||
28,52,5,3,0,50,0,1811,0
|
||||
4,16,27,1,1,87,72,1745,0
|
||||
60,1,19,2,1,41,31,591,0
|
||||
91,80,18,1,1,63,11,1081,0
|
||||
59,58,5,2,1,24,71,1124,0
|
||||
21,24,14,3,1,17,75,1910,0
|
||||
35,61,12,3,1,31,51,1002,0
|
||||
73,6,14,1,1,45,10,833,0
|
||||
17,79,12,1,0,23,35,530,0
|
||||
18,6,17,4,0,30,97,819,0
|
||||
58,81,18,3,0,14,53,795,1
|
||||
24,18,28,3,0,54,39,1416,0
|
||||
92,63,8,4,0,65,38,556,1
|
||||
1,46,6,4,0,29,14,1268,0
|
||||
83,95,7,1,1,65,99,1100,0
|
||||
77,25,24,1,1,25,41,1527,0
|
||||
6,96,7,2,1,91,24,889,0
|
||||
17,13,24,4,1,84,99,1077,0
|
||||
6,60,11,1,0,25,6,1229,0
|
||||
72,14,0,1,0,82,66,971,0
|
||||
30,39,21,3,1,100,48,624,0
|
|
BIN
src/tree.plk
Normal file
BIN
src/tree.plk
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user