Compare commits

...

60 Commits

Author SHA1 Message Date
366716a32b Merge pull request 'Merge master with genetic_algorithms branch' (#29) from genetic_algorithms into master
Reviewed-on: #29
2024-06-09 18:40:57 +02:00
99c709d271 Merge pull request 'Merge genetic_algorithms with final_show branch' (#28) from final_show into genetic_algorithms
Reviewed-on: #28
2024-06-09 18:40:24 +02:00
b78f7f5ee7 Merge pull request 'Merge genetic2 to final_show' (#27) from genetic2 into final_show
Reviewed-on: #27
2024-06-09 18:39:27 +02:00
eb2529831a This: -added goaltressure in bfs3 call in App.py -changed def value for randomGT in BFS3 in bfs.py -added more context to readme.txt 2024-06-09 18:33:50 +02:00
d61b585827 Corrected GeneticAlgorithm2 and made a GeneticAlgorithm3 and generated fields using them. Made GeneticAccuracy to check the performance of the algorithms. 2024-06-08 23:25:08 +02:00
6c86eebd89 genetic algorithm 2 with a value of None 2024-06-07 18:41:55 +02:00
da1bfe1d8f This: -changed readme.txt 2024-06-07 15:29:26 +02:00
4339284c4b This: -changed label for decision -changed goaltressure for BFS3 2024-06-07 15:01:15 +02:00
tafit0902
51a5b13669 ladowanie pola z pliku GA, rozpoznawanie zdjec na polu, decyzja o podlaniu 2024-06-07 00:02:36 +02:00
0becd1b1f6 Made genetic algorithm and made a field using it. 2024-06-06 08:35:36 +02:00
eb9744f52f Merge pull request 'refactor' (#26) from refactor into master
Reviewed-on: #26
2024-06-04 13:25:07 +02:00
ea6a9f5204 Merge pull request 'neural_network' (#25) from neural_network into refactor
Reviewed-on: #25
2024-06-04 13:23:15 +02:00
7a3c30bd2f Added some trained models. 2024-06-04 13:18:15 +02:00
53ec8e993e Merge pull request 'Merge with model for 2 crops only' (#23) from neural_network_two_crops into neural_network
Reviewed-on: #23
2024-06-04 12:45:15 +02:00
24724fb8b7 This: -added trained model for 2 crops -added way to choose which model should we use 2024-06-04 12:40:39 +02:00
16302f4d6c Merge pull request 'Merge old branches to refactor due to merge it with master' (#22) from tree into refactor
Reviewed-on: #22
2024-06-04 11:36:13 +02:00
6959afe81a Merge pull request 'This: -small refactor in print' (#21) from tree_tractor_move into tree
Reviewed-on: #21
2024-06-04 11:32:36 +02:00
58e958ac44 This: -small refactor in print 2024-06-04 11:32:07 +02:00
38c1adb054 This: -improved printing of results -fixed a bug where picking tomato fertilizer caused crash -added trained model_500_hidden.pth trained with 500 hidden layers 2024-05-27 09:01:51 +02:00
ccd1cb2359 Trained the model. 2024-05-26 18:41:55 +02:00
5d7b68fdd6 This: -removed model.pth from git tracking for now -added corn to dataset 2024-05-26 14:46:12 +02:00
34bfe78218 This: -fixed line where device for training was always cuda device 2024-05-26 14:39:05 +02:00
26c99ddc55 This: -enchanced image dataset -fixed a bug where images where not loaded -fixed a bug where tractor wasnt moving -fixed a bug where training on gpu caused a crash 2024-05-26 13:58:48 +02:00
tafit0902
d2abac6ebd roslina umiera po zlym nawiezieniu 2024-05-26 01:55:40 +02:00
tafit0902
de0740d34b losowanie bez powtorzen, poprawki w wyswieltaniu konsoli 2024-05-26 01:37:01 +02:00
tafit0902
3c6e79a1fd losowanie zdjecia dla slotu, poruszanie sie traktora, uzycie sieci 2024-05-26 01:08:47 +02:00
tafit0902
f38a52e135 dodanie podstaw sieci nuronowej 2024-05-25 02:00:19 +02:00
971746a0f8 This: -improved quality of tree visualization -fixed a bug where season cycle was not working properly 2024-05-12 22:53:41 +02:00
afae656d76 dodatkowe dane 2024-05-12 21:39:01 +02:00
9ebac46bef This: -fixed a bug where tractor_water_level and move delay was called in wrong place 2024-05-12 17:34:27 +02:00
0b494d694d This: -removed unused move in tree_move -changed display to table form in terminal -small refactoring due to code clean 2024-05-12 14:59:23 +02:00
3713ccc8ff This: -made graph bigger 2024-05-12 13:58:57 +02:00
tafit0902
7a14a94b1e traktor porusza sie po polu i decyduje czy podlac na podstawie drzewa decyzyjnego 2024-05-11 22:05:02 +02:00
7c7a485d6b Made an algorithm to generate data (treeData.py) 2024-05-11 18:30:14 +02:00
d2d7a98a84 This: -changed decision from int to string values 2024-05-11 14:30:29 +02:00
b377c5ea24 This: -added tree.png to .gitignore to prevent mistakes 2024-05-11 14:21:26 +02:00
12d2ba0d81 This: -added tree saving to .png file -added usage of decision tree -added way to get current status of all conditions -small improvements -switched off road and mud generation -changed order in .csv file to more logical 2024-05-11 14:18:40 +02:00
48b159ae02 This: -switched diseases from string to int values 2024-05-11 13:31:06 +02:00
de69592612 This: -turned off gas station drawing 2024-05-11 13:25:36 +02:00
51fe19a071 This: -switched data for tree from strings to int -broke weather atributte to temperature and rain -added waterLevel for tractor 2024-05-11 13:24:09 +02:00
f8a3156678 This: -renamed tree.py to Drzewo.py -added dataTree.csv -added basic function connected to decision tree -added required packages to readme.txt 2024-05-10 19:41:13 +02:00
e6c86e7856 This: -added readme file 2024-05-10 18:39:26 +02:00
01a3d1864b This: -added Tree.py 2024-05-10 18:34:52 +02:00
feeca26892 This: -added weather cycle 2024-05-10 18:33:38 +02:00
2b3170d10c This: -refactor few lines to disable Astar related functions and behaviour 2024-05-10 17:47:05 +02:00
d0e8a47da1 Merge pull request 'astar_temp' (#19) from astar_temp into master
Reviewed-on: #19
2024-05-10 17:34:47 +02:00
d150e9c21d Made function to test speed of A*.
Changed heuristic2.
2024-04-29 14:05:26 +02:00
c0fe5766b0 fix: brakowalo total_cost przy wylowywaniu A_star2 w App.py 2024-04-28 13:17:08 +02:00
92c893c917 This: -added road.jpg 2024-04-28 12:59:28 +02:00
7c50b44417 This: -fixed cost sum in A* -added cost of direction change for A*2 -added function to change image of visited tile -added display of total cost 2024-04-28 12:58:58 +02:00
e448c80739 This: -simplified cost taking for A* 2024-04-28 11:51:47 +02:00
eb17e42686 Merge branch 'losowanie_celu' into astar_temp 2024-04-28 11:21:09 +02:00
af15a10048 Dodanie wypisywanie kosztu do AStar1 i ustawiono staly koszt obrotu 2024-04-27 20:09:12 +02:00
tafit0902
702eff581a cel jest losowany w osobnej funkcji, dodano zdjecie stacji benzynowej jako cel trakotra 2024-04-27 00:59:48 +02:00
03434fdb79 Did heuristic2 and A_star2.
Fixed coordinate bug.
2024-04-26 16:32:50 +02:00
637b7567b4 Pierwsza wersja AStar 2024-04-25 22:56:18 +02:00
2017b89aa4 Merge pull request 'New surfaces were made (mud, dirt, stone).' (#18) from introduction_astar into astar
Reviewed-on: #18
2024-04-25 20:51:56 +02:00
ae462e2920 New surfaces were made (mud, dirt, stone).
Renamed from bfs2 to bfs3.
Added koszt to Stan and it's set automatically.
Added some ideas about A*.
2024-04-24 22:16:34 +02:00
ab14a34ecf Merge pull request 'BFS' (#17) from BFS into master
Reviewed-on: #17
2024-04-24 17:44:08 +02:00
da6b3ef067 Merge pull request 'snake_move' (#16) from snake_move into BFS
Reviewed-on: #16
2024-04-24 17:41:46 +02:00
41 changed files with 12124 additions and 71 deletions

5
.gitignore vendored
View File

@ -1,2 +1,5 @@
__pycache__/
.idea/
.idea/
tree.png
dataset/
dataset.zip

284
AStar.py Normal file
View File

@ -0,0 +1,284 @@
"""
f(n) = g(n) + h(n)
g(n) = dotychczasowy koszt -> dodać currentCost w Node lub brać koszt na nowo przy oddtawrzaniu ścieżki
h(n) = abs(state['x'] - goalTreassure[0]) + abs(state['y'] - goalTreassure[1]) -> odległość Manhatan -> można zrobić jeszcze drugą wersje gdzie mnoży się razy 5.5 ze wzgledu na średni koszt przejścia
Należy zaimplementować kolejkę priorytetową oraz zaimplementować algorytm przeszukiwania grafu stanów z uwzględnieniem kosztu za pomocą przerobienia algorytmu przeszukiwania grafu stanów
"""
import random
import pygame
import Node
import BFS
from displayControler import NUM_X, NUM_Y
from Pole import stoneList
from queue import PriorityQueue
def getRandomGoalTreasure():
while True:
goalTreasure = (random.randint(0, NUM_X - 1), random.randint(0, NUM_Y - 1)) # Współrzędne celu
if goalTreasure not in stoneList:
break
return goalTreasure
def heuristic(state, goal):
# Oblicz odległość Manhattanowską między aktualnym stanem a celem
manhattan_distance = abs(state['x'] - goal[0]) + abs(state['y'] - goal[1])
return manhattan_distance
'''def get_cost_for_plant(plant_name):
plant_costs = {
"pszenica": 7,
"kukurydza": 9,
"ziemniak": 2,
"slonecznik": 5,
"borowka": 3,
"winogrono": 4,
"mud": 15,
"dirt": 0,
}
if plant_name in plant_costs:
return plant_costs[plant_name]
else:
# Jeśli nazwa rośliny nie istnieje w słowniku, zwróć domyślną wartość
return 0
'''
def A_star(istate, pole, goalTreasure):
# goalTreasure = (random.randint(0,NUM_X-1), random.randint(0,NUM_Y-1))
# #jeśli chcemy używać random musimy wykreslić sloty z kamieniami, ponieważ tez mogą się wylosować i wtedy traktor w ogóle nie rusza
#lub zrobić to jakoś inaczej, np. funkcja szukająca najmniej nawodnionej rośliny
# przeniesione wyżej do funkcji getRandomGoalTreasure, wykorzystywana jest w App.py
# while True:
# goalTreasure = (random.randint(0, NUM_X - 1), random.randint(0, NUM_Y - 1)) # Współrzędne celu
# if goalTreasure not in stoneList:
# break
fringe = PriorityQueue() # Kolejka priorytetowa dla wierzchołków do rozpatrzenia
explored = [] # Lista odwiedzonych stanów
obrot = 1
# Tworzenie węzła początkowego
x = Node.Node(istate)
x.g = 0
x.h = heuristic(x.state, goalTreasure)
fringe.put((x.g + x.h, x)) # Dodanie węzła do kolejki
total_cost = 0
while not fringe.empty():
_, elem = fringe.get() # Pobranie węzła z najniższym priorytetem
if BFS.goalTest3(elem.state, goalTreasure): # Sprawdzenie, czy osiągnięto cel
path = []
cost_list=[]
while elem.parent is not None: # Odtworzenie ścieżki
path.append([elem.parent, elem.action])
elem = elem.parent
for node, action in path:
# Obliczanie kosztu ścieżki dla każdego pola i wyświetlanie
plant_cost = get_plant_name_and_cost_from_coordinates(node.state['x'],node.state['y'], pole)
if action == "left" or action == "right": # Liczenie kosztu tylko dla pól nie będących obrotami
total_cost += obrot
cost_list.append(obrot)
else:
total_cost += plant_cost
cost_list.append(plant_cost)
return path,cost_list,total_cost
explored.append(elem.state)
for resp in succ3A(elem.state):
child_state = resp[1]
if child_state not in explored:
child = Node.Node(child_state)
child.parent = elem
child.action = resp[0]
# Pobranie nazwy rośliny z danego slotu na podstawie współrzędnych
plant_cost = get_plant_name_and_cost_from_coordinates(child_state['x'], child_state['y'], pole)
# Pobranie kosztu dla danej rośliny
#plant_cost = get_cost_for_plant(plant_name)
if child.action == "left" or child.action == "right":
child.g = elem.g + obrot
else:
child.g = elem.g + plant_cost
# Obliczenie heurystyki dla dziecka
child.h = heuristic(child.state, goalTreasure)
in_fringe = False
for priority, item in fringe.queue:
if item.state == child.state:
in_fringe = True
if priority > child.g + child.h:
# Jeśli znaleziono węzeł w kolejce o gorszym priorytecie, zastąp go nowym
fringe.queue.remove((priority, item))
fringe.put((child.g + child.h, child))
break
if not in_fringe:
# Jeśli stan dziecka nie jest w kolejce, dodaj go do kolejki
fringe.put((child.g + child.h, child))
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
return False
def get_plant_name_and_cost_from_coordinates(x, y, pole):
if (x, y) in pole.slot_dict: # Sprawdzenie, czy podane współrzędne znajdują się na polu
slot = pole.slot_dict[(x, y)] # Pobranie slotu na podstawie współrzędnych
if slot.plant: # Sprawdzenie, czy na slocie znajduje się roślina
return slot.plant.stan.koszt # Zwrócenie nazwy rośliny na slocie
else:
return 0 # jeśli na slocie nie ma rośliny
else:
return 0 # jeśli podane współrzędne są poza polem
#to ogólnie identyczna funkcja jak w BFS ale nie chciałam tam ruszać, żeby przypadkiem nie zapsuć do BFS,
#tylko musiałam dodac sprawdzenie kolizji, bo traktor brał sloty z Y których nie ma na planszy
def succ3A(state):
resp = []
if state["direction"] == "N":
if state["y"] > 0 and (state['x'], state["y"] - 1) not in stoneList:
resp.append(["forward", {'x': state["x"], 'y': state["y"]-1, 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "E"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "W"}])
elif state["direction"] == "S":
if state["y"] < NUM_Y - 1 and (state['x'], state["y"] + 1) not in stoneList:
resp.append(["forward", {'x': state["x"], 'y': state["y"]+1, 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "W"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "E"}])
elif state["direction"] == "E":
if state["x"] < NUM_X - 1 and (state['x'] + 1, state["y"]) not in stoneList:
resp.append(["forward", {'x': state["x"]+1, 'y': state["y"], 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "S"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "N"}])
else: #state["direction"] == "W"
if state["x"] > 0 and (state['x'] - 1, state["y"]) not in stoneList:
resp.append(["forward", {'x': state["x"]-1, 'y': state["y"], 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "N"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "S"}])
return resp
def heuristic2(state, goal):
# Oblicz odległość Manhattanowską między aktualnym stanem a celem
manhattan_distance = (abs(state['x'] - goal[0]) + abs(state['y'] - goal[1])) * 2.5
return manhattan_distance
def A_star2(istate, pole, goalTreasure):
# goalTreasure = (random.randint(0,NUM_X-1), random.randint(0,NUM_Y-1))
# #jeśli chcemy używać random musimy wykreslić sloty z kamieniami, ponieważ tez mogą się wylosować i wtedy traktor w ogóle nie rusza
#lub zrobić to jakoś inaczej, np. funkcja szukająca najmniej nawodnionej rośliny
# przeniesione wyżej do funkcji getRandomGoalTreasure, wykorzystywana jest w App.py
# while True:
# goalTreasure = (random.randint(0, NUM_X - 1), random.randint(0, NUM_Y - 1)) # Współrzędne celu
# if goalTreasure not in stoneList:
# break
fringe = PriorityQueue() # Kolejka priorytetowa dla wierzchołków do rozpatrzenia
explored = [] # Lista odwiedzonych stanów
obrot = 1
# Tworzenie węzła początkowego
x = Node.Node(istate)
x.g = 0
x.h = heuristic2(x.state, goalTreasure)
fringe.put((x.g + x.h, x)) # Dodanie węzła do kolejki
total_cost=0
while not fringe.empty():
_, elem = fringe.get() # Pobranie węzła z najniższym priorytetem
if BFS.goalTest3(elem.state, goalTreasure): # Sprawdzenie, czy osiągnięto cel
path = []
cost_list=[]
while elem.parent is not None: # Odtworzenie ścieżki
path.append([elem.parent, elem.action])
elem = elem.parent
for node, action in path:
# Obliczanie kosztu ścieżki dla każdego pola i wyświetlanie
plant_cost = get_plant_name_and_cost_from_coordinates(node.state['x'],node.state['y'], pole)
if action == "left" or action == "right": # Liczenie kosztu tylko dla pól nie będących obrotami
total_cost += obrot
cost_list.append(obrot)
else:
total_cost += plant_cost
cost_list.append(plant_cost)
return path,cost_list,total_cost
explored.append(elem.state)
for resp in succ3A(elem.state):
child_state = resp[1]
if child_state not in explored:
child = Node.Node(child_state)
child.parent = elem
child.action = resp[0]
# Pobranie nazwy rośliny z danego slotu na podstawie współrzędnych
plant_cost = get_plant_name_and_cost_from_coordinates(child_state['x'], child_state['y'], pole)
if child.action == "left" or child.action == "right":
child.g = elem.g + obrot
else:
child.g = elem.g + plant_cost
# Obliczenie heurystyki dla dziecka
child.h = heuristic2(child.state, goalTreasure)
in_fringe = False
for priority, item in fringe.queue:
if item.state == child.state:
in_fringe = True
if priority > child.g + child.h:
# Jeśli znaleziono węzeł w kolejce o gorszym priorytecie, zastąp go nowym
fringe.queue.remove((priority, item))
fringe.put((child.g + child.h, child))
break
if not in_fringe:
# Jeśli stan dziecka nie jest w kolejce, dodaj go do kolejki
fringe.put((child.g + child.h, child))
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
return False
"""
TO TEST SPEED OF ASTAR
test_speed = False
if test_speed:
time1 = 0
time2 = 0
cost1 = 0
cost2 = 0
for i in range(500):
print(i)
start = time.time()
aStarRoot, cost_list, total_cost = AStar.A_star({'x': 0, 'y': 0, 'direction': "E"}, pole, goalTreasure)
end = time.time()
time1 += end - start
cost1 += total_cost
start = time.time()
aStarRoot2, cost_list, total_cost = AStar.A_star2({'x': 0, 'y': 0, 'direction': "E"}, pole, goalTreasure)
end = time.time()
time2 += end - start
cost2 += total_cost
print(time1, time2)
print(float(cost1 / 1000), float(cost2 / 1000))
"""

105
App.py

File diff suppressed because one or more lines are too long

29
BFS.py
View File

@ -3,6 +3,7 @@ import random
import pygame
import Node
from displayControler import NUM_X, NUM_Y
from Pole import stoneList
def goalTest1(hIndex):
@ -93,31 +94,31 @@ def BFS1(istate):
def goalTest2(state, goalTreassure):
def goalTest3(state, goalTreassure):
if state["x"] == goalTreassure[0] and state["y"] == goalTreassure[1]:
return True
return False
def succ2(state):
def succ3(state):
resp = []
if state["direction"] == "N":
if state["y"] > 0:
if state["y"] > 0 and (state['x'], state["y"] - 1) not in stoneList:
resp.append(["forward", {'x': state["x"], 'y': state["y"]-1, 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "E"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "W"}])
elif state["direction"] == "S":
if state["y"] < NUM_Y:
if state["y"] < NUM_Y - 1 and (state['x'], state["y"] + 1) not in stoneList:
resp.append(["forward", {'x': state["x"], 'y': state["y"]+1, 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "W"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "E"}])
elif state["direction"] == "E":
if state["x"] < NUM_X:
if state["x"] < NUM_X - 1 and (state['x'] + 1, state["y"]) not in stoneList:
resp.append(["forward", {'x': state["x"]+1, 'y': state["y"], 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "S"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "N"}])
else: #state["zwrot"] == "W"
if state["x"] > 0:
if state["x"] > 0 and (state['x'] - 1, state["y"]) not in stoneList:
resp.append(["forward", {'x': state["x"]-1, 'y': state["y"], 'direction': state["direction"]}])
resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "N"}])
resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "S"}])
@ -125,15 +126,19 @@ def succ2(state):
return resp
def check2(tab, state):
def check3(tab, state):
for i in tab:
if i.state == state:
return False
return True
def BFS2(istate):
goalTreassuere = (random.randint(0,NUM_X-1), random.randint(0,NUM_Y-1))
def BFS3(istate,GT):
randomGT=False
if(randomGT==True):
goalTreassuere = (random.randint(0,NUM_X-1), random.randint(0,NUM_Y-1))
else:
goalTreassuere=GT
print(goalTreassuere)
fringe = []
explored = []
@ -148,7 +153,7 @@ def BFS2(istate):
elem = fringe.pop(0)
if goalTest2(elem.state, goalTreassuere):
if goalTest3(elem.state, goalTreassuere):
x = elem
tab = []
while x.parent != None:
@ -158,8 +163,8 @@ def BFS2(istate):
explored.append(elem)
for resp in succ2(elem.state):
if check2(fringe, resp[1]) and check2(explored, resp[1]):
for resp in succ3(elem.state):
if check3(fringe, resp[1]) and check3(explored, resp[1]):
x = Node.Node(resp[1])
x.parent = elem
x.action = resp[0]

49
Climate.py Normal file
View File

@ -0,0 +1,49 @@
#THESE DICTIONARIES ARE USED FOR DISPLAY AND FOR DOCUMENTATION PURPOSES
seasons={
0:"zima",
1:"wiosna",
2:"lato",
3:"jesien"}
time={
0:"rano",
1:"poludnie",
2:"wieczor",
3:"noc"}
rain={
0:"brak",
1:"lekki deszcz",
2:"normalny deszcz",
3:"ulewa"
}
temperature={
0:"bardzo zimno",
1:"zimno",
2:"przecietnie",
3:"cieplo",
4:"upal",}
def getNextSeason(season):
if(season==3):
return 0
else:
return season+1
def getNextTime(currentTime):
if(currentTime==3):
return 0
else:
return currentTime+1
def getAmount(type):
if(type=="seasons"):
return len(seasons)
if(type=="rain"):
return len(rain)
if(type=="time"):
return len(time)
if(type=="temperature"):
return len(temperature)

47
Condition.py Normal file
View File

@ -0,0 +1,47 @@
import random
import Climate
import Ui
class Condition:
def __init__(self):
self.season=self.setRandomSeason()
self.currentTime=self.setRandomTime()
self.rain=self.setRandomRain()
self.temperature=self.setRandomRain()
self.clock=0
def setRandomSeason(self):
return self.randomizer(Climate.getAmount("seasons"))
def setRandomTime(self):
return self.randomizer(Climate.getAmount("time"))
def setRandomRain(self):
return self.randomizer(Climate.getAmount("rain"))
def setRandomTemperature(self):
return self.randomizer(Climate.getAmount("temperature"))
def randomizer(self,max):
return random.randint(0,max-1)
def cycle(self):
if(self.clock==11):
self.currentTime=0
self.rain=self.setRandomRain()
self.temperature=self.setRandomTemperature()
self.season=Climate.getNextSeason(self.season)
self.clock=0
return
else:
self.currentTime=Climate.getNextTime(self.currentTime)
self.rain=self.setRandomRain()
self.temperature=self.setRandomTemperature()
self.clock=self.clock+1
def return_condition(self):
return [self.temperature,self.rain,self.season,self.currentTime]
def getCondition(self):
return ([Climate.temperature[self.temperature],Climate.rain[self.rain],Climate.seasons[self.season],Climate.time[self.currentTime]])

9219
Data/dataTree.csv Normal file

File diff suppressed because it is too large Load Diff

248
Data/dataTree2.csv Normal file
View File

@ -0,0 +1,248 @@
plant_water_level,growth,disease,fertility,tractor_water_level,temperature,rain,season,current_time,action
1,20,0,40,60,2,0,2,1,1
20,40,0,40,60,2,0,2,1,1
87,20,0,40,60,2,0,2,1,0
27,43,1,40,60,2,0,2,1,0
89,56,1,40,60,2,1,1,1,0
67,100,1,37,55,1,3,3,3,0
67,40,1,87,90,4,0,1,0,0
1,20,0,40,60,2,0,0,1,0
20,40,0,40,60,2,0,0,1,0
87,20,0,56,45,2,0,0,2,0
27,43,1,40,60,2,0,0,3,0
89,56,1,40,89,2,1,0,1,0
67,100,1,37,55,1,3,0,3,0
67,40,1,87,90,4,0,0,0,0
1,100,0,45,20,2,0,2,1,0
20,100,0,40,34,0,1,2,0,0
87,100,0,56,60,2,0,1,1,0
27,100,0,89,67,1,2,2,2,0
89,100,0,40,60,2,1,1,1,0
76,100,0,37,55,1,3,3,3,0
67,100,0,87,90,4,0,1,0,0
1,20,0,40,0,2,0,2,1,0
20,40,0,40,0,2,0,2,1,0
87,20,0,40,0,2,0,2,1,0
27,43,1,40,0,2,0,2,1,0
89,56,1,40,0,2,1,1,1,0
67,100,1,37,0,1,3,3,3,0
67,40,1,87,0,4,0,1,0,0
1,20,0,40,0,2,0,0,1,0
20,40,0,40,0,2,0,0,1,0
87,20,0,56,0,2,0,0,2,0
27,43,1,40,0,2,0,0,3,0
89,56,1,40,0,2,1,0,1,0
67,100,1,37,0,1,3,0,3,0
67,40,1,87,0,4,0,0,0,0
1,100,0,45,0,2,0,2,1,0
20,100,0,40,0,0,1,2,0,0
87,100,0,56,0,2,0,1,1,0
27,100,0,89,0,1,2,2,2,0
89,100,0,40,0,2,1,1,1,0
76,100,0,37,0,1,3,3,3,0
67,100,0,87,0,4,0,1,0,0
1,45,0,56,44,2,1,1,1,1
20,55,0,43,34,2,0,2,2,1
15,23,0,23,26,2,1,3,3,1
45,67,0,12,67,3,0,1,0,1
59,88,0,34,87,3,0,2,1,1
32,32,0,32,90,3,0,3,2,1
44,43,0,19,27,2,0,1,3,1
33,11,0,28,76,2,0,2,0,1
54,90,0,44,5,3,0,3,1,1
21,76,0,50,25,3,1,1,2,1
29,64,0,38,36,2,0,2,3,1
11,54,0,65,44,3,1,1,2,1
23,55,0,34,43,3,0,2,1,1
51,32,0,32,62,3,1,3,3,1
54,76,0,21,76,2,0,1,2,1
95,88,0,43,78,2,0,2,1,0
23,23,0,23,9,2,0,3,3,1
44,34,0,91,72,3,0,1,0,1
33,11,0,82,67,3,0,2,2,1
45,9,0,44,50,2,0,3,3,1
21,67,0,50,52,2,1,1,0,1
92,46,0,83,63,3,0,2,1,0
20,55,1,43,34,0,0,2,2,0
15,23,1,23,26,0,1,3,3,0
45,67,1,12,67,0,0,1,0,0
59,88,1,34,87,0,0,2,1,0
32,32,0,32,90,0,0,3,2,0
44,43,0,19,27,4,0,1,3,0
33,11,0,28,76,4,0,2,0,0
54,90,0,44,5,4,0,3,1,0
21,76,0,50,25,4,1,1,2,0
29,64,0,38,36,4,0,2,3,0
11,54,0,65,44,0,1,1,2,0
23,55,0,34,43,0,0,2,1,0
51,32,0,32,62,0,1,3,3,0
80,76,1,39,7,3,0,1,0,0
98,77,0,15,91,1,3,2,3,0
3,48,1,73,41,2,2,0,3,0
20,15,1,97,87,4,1,2,1,0
93,6,0,37,0,0,1,0,1,0
4,31,0,1,5,2,3,1,2,0
42,52,0,33,19,3,2,3,0,0
76,43,0,77,18,4,0,0,3,0
31,13,1,21,42,0,1,2,3,0
96,65,1,63,35,1,3,3,2,0
29,39,0,40,37,3,3,0,0,0
82,53,0,55,9,0,1,3,2,0
21,35,0,58,1,1,2,2,0,0
92,98,0,69,16,3,0,0,1,0
34,23,0,95,2,2,3,0,3,0
36,28,0,62,22,0,1,1,1,0
66,88,1,10,85,3,1,2,3,0
53,51,0,79,90,2,2,3,2,0
9,74,0,60,4,4,1,2,3,1
17,0,0,38,58,1,2,3,0,0
12,76,0,50,25,3,1,1,2,1
92,64,0,38,36,2,0,2,3,0
11,54,0,65,44,3,1,1,2,1
32,55,0,34,43,3,0,2,1,1
15,32,0,32,62,3,1,3,3,1
45,76,0,21,76,2,0,1,2,1
59,88,0,43,78,2,0,2,1,1
32,23,0,23,9,2,0,3,3,1
14,34,0,91,72,3,0,1,0,1
13,11,0,82,67,3,0,2,2,1
45,9,0,44,50,2,0,3,3,1
21,67,0,50,52,2,1,1,0,1
92,46,0,83,63,3,0,2,1,0
2,40,1,34,43,1,3,2,2,0
51,32,1,32,62,2,1,3,3,0
54,76,1,21,76,3,0,1,0,0
98,38,0,50,44,4,0,1,0,0
63,7,0,93,79,2,0,2,1,1
91,59,0,94,24,4,0,3,2,0
11,49,0,54,76,2,0,1,3,1
33,31,0,59,39,3,0,1,3,1
28,50,0,26,0,4,0,2,2,0
54,83,0,36,0,3,0,2,1,0
49,78,0,68,0,2,0,3,2,0
59,21,0,43,100,1,0,3,2,1
1,30,0,52,100,2,0,0,3,0
60,9,0,40,40,3,0,0,3,0
85,94,0,87,85,4,0,1,3,0
79,68,0,56,90,1,0,2,2,1
75,22,0,25,95,1,0,3,2,1
100,51,0,33,12,0,0,2,2,0
90,70,0,71,81,0,0,2,1,0
47,26,0,6,78,4,0,1,1,1
14,89,0,70,18,4,0,1,0,1
99,19,0,74,91,2,0,3,0,0
18,48,0,15,32,2,0,3,0,1
5,57,0,14,34,0,1,1,3,1
22,67,0,9,5,0,1,2,2,0
95,81,0,46,86,1,1,3,1,0
39,65,0,84,0,1,1,0,0,0
84,75,0,30,0,2,1,1,1,0
86,41,0,2,67,2,1,2,2,0
64,53,0,53,47,1,1,3,3,1
69,61,0,0,73,2,1,0,0,0
94,40,1,0,18,3,1,1,2,0
62,82,1,20,50,4,1,2,3,0
57,1,1,17,92,0,1,3,2,0
80,35,1,58,45,0,0,3,1,0
30,47,1,8,47,1,0,2,1,0
82,32,0,99,39,1,3,1,3,0
20,84,0,0,51,2,3,2,3,0
42,88,0,0,54,2,2,2,0,0
66,45,0,91,10,3,2,1,0,0
81,14,0,19,55,3,0,1,2,1
74,37,0,88,78,4,0,3,2,1
89,99,0,100,60,4,0,3,3,0
15,20,0,45,11,0,0,1,3,1
92,28,0,85,90,2,0,1,1,0
55,4,0,13,95,2,0,2,1,1
2,6,0,35,0,2,0,2,0,0
61,56,0,90,0,2,0,3,0,0
76,11,0,61,10,3,0,3,1,1
26,80,0,57,9,3,0,1,2,1
40,44,0,81,8,3,0,2,3,1
50,66,0,23,7,3,0,3,0,1
48,15,0,77,6,2,0,0,1,0
11,54,0,65,44,3,3,1,2,0
23,55,0,34,43,3,3,2,1,0
51,32,0,32,62,3,3,3,3,0
54,76,0,21,76,2,3,1,2,0
95,88,0,43,78,2,3,2,1,0
23,23,0,23,9,2,3,3,3,0
44,34,0,91,72,3,3,1,0,0
33,11,0,82,67,3,3,2,2,0
45,9,0,44,50,2,3,3,3,0
21,67,0,50,52,2,3,1,0,0
92,46,0,83,63,3,3,2,1,0
20,55,1,43,34,0,3,2,2,0
15,23,1,23,26,0,3,3,3,0
45,67,1,12,67,0,3,1,0,0
59,88,1,34,87,0,3,2,1,0
32,32,0,32,90,0,3,3,2,0
1,60,0,55,11,0,1,0,0,1
2,70,0,44,12,1,1,0,1,1
3,44,0,11,13,2,1,0,2,1
4,55,0,34,66,3,0,0,3,1
5,66,0,90,77,0,0,1,2,1
6,22,0,89,88,0,0,2,2,1
7,1,0,45,9,0,1,2,3,1
8,2,0,34,22,3,1,2,3,1
9,3,0,56,34,3,1,0,1,1
10,6,0,78,5,3,0,3,1,1
11,8,0,36,67,2,0,0,0,1
12,59,0,57,23,2,1,1,0,1
13,67,0,29,34,1,1,0,1,1
14,20,0,30,90,1,1,2,2,1
15,21,0,66,89,0,1,3,3,1
44,100,0,91,72,3,3,1,0,0
33,100,0,82,67,3,3,2,2,0
45,100,0,44,50,2,3,3,3,0
21,100,0,50,52,2,3,1,0,0
92,100,0,83,63,3,3,2,1,0
20,100,1,43,34,0,3,2,2,0
15,100,1,23,26,0,3,3,3,0
45,100,1,12,67,0,3,1,0,0
59,100,1,34,87,0,3,2,1,0
32,100,0,32,90,0,3,3,2,0
1,100,0,55,11,0,1,0,0,0
2,100,0,44,12,1,1,0,1,0
3,100,0,11,13,2,1,0,2,0
4,100,0,34,66,3,0,0,3,0
5,100,0,90,77,0,0,1,2,0
6,100,0,89,88,0,0,2,2,0
7,100,0,45,9,0,1,2,3,0
8,100,0,34,22,3,1,2,3,0
9,100,0,56,34,3,1,0,1,0
10,100,0,78,5,3,0,3,1,0
11,100,0,36,67,2,0,0,0,0
12,100,0,57,23,2,1,1,0,0
13,100,0,29,34,1,1,0,1,0
14,100,0,30,90,1,1,2,2,0
15,100,0,66,89,0,1,3,3,0
1,6,0,5,10,4,1,1,3,1
2,7,0,4,20,4,1,2,2,1
3,4,0,11,30,4,1,3,1,1
4,5,0,43,5,2,0,1,2,1
5,6,0,9,17,2,0,2,1,1
6,2,0,98,18,4,0,3,1,1
7,11,0,54,19,4,1,0,2,1
8,20,0,43,22,4,1,1,1,1
9,30,0,65,43,4,1,2,3,1
10,60,0,87,50,1,0,3,3,1
11,80,0,63,76,1,0,0,2,1
12,95,0,75,32,1,1,1,1,1
13,76,0,30,43,2,1,2,0,1
14,2,0,92,9,2,1,3,0,1
1,6,0,5,10,4,3,1,3,0
2,7,0,4,20,4,3,2,2,0
3,4,0,11,30,4,3,3,1,0
4,5,0,43,5,2,3,1,2,0
5,6,0,9,17,2,3,2,1,0
6,2,0,98,18,4,3,3,1,0
7,11,0,54,19,4,3,0,2,0
8,20,0,43,22,4,3,1,1,0
9,30,0,65,43,4,3,2,3,0
10,60,0,87,50,1,3,3,3,0
11,80,0,63,76,1,3,0,2,0
12,95,0,75,32,1,3,1,1,0
13,76,0,30,43,2,3,2,0,0
14,2,0,92,9,2,3,3,0,0
1 plant_water_level growth disease fertility tractor_water_level temperature rain season current_time action
2 1 20 0 40 60 2 0 2 1 1
3 20 40 0 40 60 2 0 2 1 1
4 87 20 0 40 60 2 0 2 1 0
5 27 43 1 40 60 2 0 2 1 0
6 89 56 1 40 60 2 1 1 1 0
7 67 100 1 37 55 1 3 3 3 0
8 67 40 1 87 90 4 0 1 0 0
9 1 20 0 40 60 2 0 0 1 0
10 20 40 0 40 60 2 0 0 1 0
11 87 20 0 56 45 2 0 0 2 0
12 27 43 1 40 60 2 0 0 3 0
13 89 56 1 40 89 2 1 0 1 0
14 67 100 1 37 55 1 3 0 3 0
15 67 40 1 87 90 4 0 0 0 0
16 1 100 0 45 20 2 0 2 1 0
17 20 100 0 40 34 0 1 2 0 0
18 87 100 0 56 60 2 0 1 1 0
19 27 100 0 89 67 1 2 2 2 0
20 89 100 0 40 60 2 1 1 1 0
21 76 100 0 37 55 1 3 3 3 0
22 67 100 0 87 90 4 0 1 0 0
23 1 20 0 40 0 2 0 2 1 0
24 20 40 0 40 0 2 0 2 1 0
25 87 20 0 40 0 2 0 2 1 0
26 27 43 1 40 0 2 0 2 1 0
27 89 56 1 40 0 2 1 1 1 0
28 67 100 1 37 0 1 3 3 3 0
29 67 40 1 87 0 4 0 1 0 0
30 1 20 0 40 0 2 0 0 1 0
31 20 40 0 40 0 2 0 0 1 0
32 87 20 0 56 0 2 0 0 2 0
33 27 43 1 40 0 2 0 0 3 0
34 89 56 1 40 0 2 1 0 1 0
35 67 100 1 37 0 1 3 0 3 0
36 67 40 1 87 0 4 0 0 0 0
37 1 100 0 45 0 2 0 2 1 0
38 20 100 0 40 0 0 1 2 0 0
39 87 100 0 56 0 2 0 1 1 0
40 27 100 0 89 0 1 2 2 2 0
41 89 100 0 40 0 2 1 1 1 0
42 76 100 0 37 0 1 3 3 3 0
43 67 100 0 87 0 4 0 1 0 0
44 1 45 0 56 44 2 1 1 1 1
45 20 55 0 43 34 2 0 2 2 1
46 15 23 0 23 26 2 1 3 3 1
47 45 67 0 12 67 3 0 1 0 1
48 59 88 0 34 87 3 0 2 1 1
49 32 32 0 32 90 3 0 3 2 1
50 44 43 0 19 27 2 0 1 3 1
51 33 11 0 28 76 2 0 2 0 1
52 54 90 0 44 5 3 0 3 1 1
53 21 76 0 50 25 3 1 1 2 1
54 29 64 0 38 36 2 0 2 3 1
55 11 54 0 65 44 3 1 1 2 1
56 23 55 0 34 43 3 0 2 1 1
57 51 32 0 32 62 3 1 3 3 1
58 54 76 0 21 76 2 0 1 2 1
59 95 88 0 43 78 2 0 2 1 0
60 23 23 0 23 9 2 0 3 3 1
61 44 34 0 91 72 3 0 1 0 1
62 33 11 0 82 67 3 0 2 2 1
63 45 9 0 44 50 2 0 3 3 1
64 21 67 0 50 52 2 1 1 0 1
65 92 46 0 83 63 3 0 2 1 0
66 20 55 1 43 34 0 0 2 2 0
67 15 23 1 23 26 0 1 3 3 0
68 45 67 1 12 67 0 0 1 0 0
69 59 88 1 34 87 0 0 2 1 0
70 32 32 0 32 90 0 0 3 2 0
71 44 43 0 19 27 4 0 1 3 0
72 33 11 0 28 76 4 0 2 0 0
73 54 90 0 44 5 4 0 3 1 0
74 21 76 0 50 25 4 1 1 2 0
75 29 64 0 38 36 4 0 2 3 0
76 11 54 0 65 44 0 1 1 2 0
77 23 55 0 34 43 0 0 2 1 0
78 51 32 0 32 62 0 1 3 3 0
79 80 76 1 39 7 3 0 1 0 0
80 98 77 0 15 91 1 3 2 3 0
81 3 48 1 73 41 2 2 0 3 0
82 20 15 1 97 87 4 1 2 1 0
83 93 6 0 37 0 0 1 0 1 0
84 4 31 0 1 5 2 3 1 2 0
85 42 52 0 33 19 3 2 3 0 0
86 76 43 0 77 18 4 0 0 3 0
87 31 13 1 21 42 0 1 2 3 0
88 96 65 1 63 35 1 3 3 2 0
89 29 39 0 40 37 3 3 0 0 0
90 82 53 0 55 9 0 1 3 2 0
91 21 35 0 58 1 1 2 2 0 0
92 92 98 0 69 16 3 0 0 1 0
93 34 23 0 95 2 2 3 0 3 0
94 36 28 0 62 22 0 1 1 1 0
95 66 88 1 10 85 3 1 2 3 0
96 53 51 0 79 90 2 2 3 2 0
97 9 74 0 60 4 4 1 2 3 1
98 17 0 0 38 58 1 2 3 0 0
99 12 76 0 50 25 3 1 1 2 1
100 92 64 0 38 36 2 0 2 3 0
101 11 54 0 65 44 3 1 1 2 1
102 32 55 0 34 43 3 0 2 1 1
103 15 32 0 32 62 3 1 3 3 1
104 45 76 0 21 76 2 0 1 2 1
105 59 88 0 43 78 2 0 2 1 1
106 32 23 0 23 9 2 0 3 3 1
107 14 34 0 91 72 3 0 1 0 1
108 13 11 0 82 67 3 0 2 2 1
109 45 9 0 44 50 2 0 3 3 1
110 21 67 0 50 52 2 1 1 0 1
111 92 46 0 83 63 3 0 2 1 0
112 2 40 1 34 43 1 3 2 2 0
113 51 32 1 32 62 2 1 3 3 0
114 54 76 1 21 76 3 0 1 0 0
115 98 38 0 50 44 4 0 1 0 0
116 63 7 0 93 79 2 0 2 1 1
117 91 59 0 94 24 4 0 3 2 0
118 11 49 0 54 76 2 0 1 3 1
119 33 31 0 59 39 3 0 1 3 1
120 28 50 0 26 0 4 0 2 2 0
121 54 83 0 36 0 3 0 2 1 0
122 49 78 0 68 0 2 0 3 2 0
123 59 21 0 43 100 1 0 3 2 1
124 1 30 0 52 100 2 0 0 3 0
125 60 9 0 40 40 3 0 0 3 0
126 85 94 0 87 85 4 0 1 3 0
127 79 68 0 56 90 1 0 2 2 1
128 75 22 0 25 95 1 0 3 2 1
129 100 51 0 33 12 0 0 2 2 0
130 90 70 0 71 81 0 0 2 1 0
131 47 26 0 6 78 4 0 1 1 1
132 14 89 0 70 18 4 0 1 0 1
133 99 19 0 74 91 2 0 3 0 0
134 18 48 0 15 32 2 0 3 0 1
135 5 57 0 14 34 0 1 1 3 1
136 22 67 0 9 5 0 1 2 2 0
137 95 81 0 46 86 1 1 3 1 0
138 39 65 0 84 0 1 1 0 0 0
139 84 75 0 30 0 2 1 1 1 0
140 86 41 0 2 67 2 1 2 2 0
141 64 53 0 53 47 1 1 3 3 1
142 69 61 0 0 73 2 1 0 0 0
143 94 40 1 0 18 3 1 1 2 0
144 62 82 1 20 50 4 1 2 3 0
145 57 1 1 17 92 0 1 3 2 0
146 80 35 1 58 45 0 0 3 1 0
147 30 47 1 8 47 1 0 2 1 0
148 82 32 0 99 39 1 3 1 3 0
149 20 84 0 0 51 2 3 2 3 0
150 42 88 0 0 54 2 2 2 0 0
151 66 45 0 91 10 3 2 1 0 0
152 81 14 0 19 55 3 0 1 2 1
153 74 37 0 88 78 4 0 3 2 1
154 89 99 0 100 60 4 0 3 3 0
155 15 20 0 45 11 0 0 1 3 1
156 92 28 0 85 90 2 0 1 1 0
157 55 4 0 13 95 2 0 2 1 1
158 2 6 0 35 0 2 0 2 0 0
159 61 56 0 90 0 2 0 3 0 0
160 76 11 0 61 10 3 0 3 1 1
161 26 80 0 57 9 3 0 1 2 1
162 40 44 0 81 8 3 0 2 3 1
163 50 66 0 23 7 3 0 3 0 1
164 48 15 0 77 6 2 0 0 1 0
165 11 54 0 65 44 3 3 1 2 0
166 23 55 0 34 43 3 3 2 1 0
167 51 32 0 32 62 3 3 3 3 0
168 54 76 0 21 76 2 3 1 2 0
169 95 88 0 43 78 2 3 2 1 0
170 23 23 0 23 9 2 3 3 3 0
171 44 34 0 91 72 3 3 1 0 0
172 33 11 0 82 67 3 3 2 2 0
173 45 9 0 44 50 2 3 3 3 0
174 21 67 0 50 52 2 3 1 0 0
175 92 46 0 83 63 3 3 2 1 0
176 20 55 1 43 34 0 3 2 2 0
177 15 23 1 23 26 0 3 3 3 0
178 45 67 1 12 67 0 3 1 0 0
179 59 88 1 34 87 0 3 2 1 0
180 32 32 0 32 90 0 3 3 2 0
181 1 60 0 55 11 0 1 0 0 1
182 2 70 0 44 12 1 1 0 1 1
183 3 44 0 11 13 2 1 0 2 1
184 4 55 0 34 66 3 0 0 3 1
185 5 66 0 90 77 0 0 1 2 1
186 6 22 0 89 88 0 0 2 2 1
187 7 1 0 45 9 0 1 2 3 1
188 8 2 0 34 22 3 1 2 3 1
189 9 3 0 56 34 3 1 0 1 1
190 10 6 0 78 5 3 0 3 1 1
191 11 8 0 36 67 2 0 0 0 1
192 12 59 0 57 23 2 1 1 0 1
193 13 67 0 29 34 1 1 0 1 1
194 14 20 0 30 90 1 1 2 2 1
195 15 21 0 66 89 0 1 3 3 1
196 44 100 0 91 72 3 3 1 0 0
197 33 100 0 82 67 3 3 2 2 0
198 45 100 0 44 50 2 3 3 3 0
199 21 100 0 50 52 2 3 1 0 0
200 92 100 0 83 63 3 3 2 1 0
201 20 100 1 43 34 0 3 2 2 0
202 15 100 1 23 26 0 3 3 3 0
203 45 100 1 12 67 0 3 1 0 0
204 59 100 1 34 87 0 3 2 1 0
205 32 100 0 32 90 0 3 3 2 0
206 1 100 0 55 11 0 1 0 0 0
207 2 100 0 44 12 1 1 0 1 0
208 3 100 0 11 13 2 1 0 2 0
209 4 100 0 34 66 3 0 0 3 0
210 5 100 0 90 77 0 0 1 2 0
211 6 100 0 89 88 0 0 2 2 0
212 7 100 0 45 9 0 1 2 3 0
213 8 100 0 34 22 3 1 2 3 0
214 9 100 0 56 34 3 1 0 1 0
215 10 100 0 78 5 3 0 3 1 0
216 11 100 0 36 67 2 0 0 0 0
217 12 100 0 57 23 2 1 1 0 0
218 13 100 0 29 34 1 1 0 1 0
219 14 100 0 30 90 1 1 2 2 0
220 15 100 0 66 89 0 1 3 3 0
221 1 6 0 5 10 4 1 1 3 1
222 2 7 0 4 20 4 1 2 2 1
223 3 4 0 11 30 4 1 3 1 1
224 4 5 0 43 5 2 0 1 2 1
225 5 6 0 9 17 2 0 2 1 1
226 6 2 0 98 18 4 0 3 1 1
227 7 11 0 54 19 4 1 0 2 1
228 8 20 0 43 22 4 1 1 1 1
229 9 30 0 65 43 4 1 2 3 1
230 10 60 0 87 50 1 0 3 3 1
231 11 80 0 63 76 1 0 0 2 1
232 12 95 0 75 32 1 1 1 1 1
233 13 76 0 30 43 2 1 2 0 1
234 14 2 0 92 9 2 1 3 0 1
235 1 6 0 5 10 4 3 1 3 0
236 2 7 0 4 20 4 3 2 2 0
237 3 4 0 11 30 4 3 3 1 0
238 4 5 0 43 5 2 3 1 2 0
239 5 6 0 9 17 2 3 2 1 0
240 6 2 0 98 18 4 3 3 1 0
241 7 11 0 54 19 4 3 0 2 0
242 8 20 0 43 22 4 3 1 1 0
243 9 30 0 65 43 4 3 2 3 0
244 10 60 0 87 50 1 3 3 3 0
245 11 80 0 63 76 1 3 0 2 0
246 12 95 0 75 32 1 3 1 1 0
247 13 76 0 30 43 2 3 2 0 0
248 14 2 0 92 9 2 3 3 0 0

29
Drzewo.py Normal file
View File

@ -0,0 +1,29 @@
from sklearn import tree as skltree
import pandas,os
import matplotlib.pyplot as plt
atributes=['plant_water_level','growth','disease','fertility','tractor_water_level','temperature','rain','season','current_time'] #Columns in CSV file has to be in the same order
class Drzewo:
def __init__(self):
self.tree=self.treeLearn()
def treeLearn(self):
csvdata=pandas.read_csv('Data/dataTree2.csv')
#csvdata = pandas.read_csv('Data/dataTree2.csv')
x=csvdata[atributes]
decision=csvdata['action']
self.tree=skltree.DecisionTreeClassifier()
self.tree=self.tree.fit(x.values,decision)
def plotTree(self):
plt.figure(figsize=(20,30))
skltree.plot_tree(self.tree,filled=True,feature_names=atributes)
plt.title("Drzewo decyzyjne wytrenowane na przygotowanych danych: ")
plt.savefig('tree.png')
#plt.show()
def makeDecision(self,values):
action=self.tree.predict([values]) #0- nie podlewac, 1-podlewac
if(action==[0]):
return "Nie"
if(action==[1]):
return "Tak"

139
GeneticAccuracy.py Normal file
View File

@ -0,0 +1,139 @@
import json
import random
from displayControler import NUM_Y, NUM_X
iterat = 2500
population = 120
roulette = True
plants = ['corn', 'potato', 'tomato', 'carrot']
initial_yields = {'corn': 38, 'potato': 40, 'tomato': 43, 'carrot': 45}
yield_reduction = {
'corn': {'corn': -4.5, 'potato': -3, 'tomato': -7, 'carrot': -7},
'potato': {'corn': -7, 'potato': -5, 'tomato': -10, 'carrot': -6},
'tomato': {'corn': -4, 'potato': -5, 'tomato': -7, 'carrot': -7},
'carrot': {'corn': -11, 'potato': -5, 'tomato': -4, 'carrot'