działający
0
.gitignore
vendored
Normal file
@ -3,13 +3,9 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/astar.py" beforeDir="false" afterPath="$PROJECT_DIR$/astar.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cart.py" beforeDir="false" afterPath="$PROJECT_DIR$/cart.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/graph.py" beforeDir="false" afterPath="$PROJECT_DIR$/graph.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/neuralnetwork.py" beforeDir="false" afterPath="$PROJECT_DIR$/neuralnetwork.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/plant.py" beforeDir="false" afterPath="$PROJECT_DIR$/plant.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/treelearn.py" beforeDir="false" afterPath="$PROJECT_DIR$/treelearn.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -161,6 +157,13 @@
|
||||
<workItem from="1622471028909" duration="34000" />
|
||||
<workItem from="1622471098158" duration="2320000" />
|
||||
<workItem from="1622474297862" duration="2475000" />
|
||||
<workItem from="1622482225447" duration="322000" />
|
||||
<workItem from="1622483723661" duration="2000" />
|
||||
<workItem from="1622484196227" duration="4095000" />
|
||||
<workItem from="1622490223156" duration="88000" />
|
||||
<workItem from="1622490315073" duration="1038000" />
|
||||
<workItem from="1622491366806" duration="5374000" />
|
||||
<workItem from="1622499624637" duration="5901000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -168,65 +171,69 @@
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="414" y="195" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1622365181713">
|
||||
<state x="414" y="195" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1622503192333">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="414" y="195" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622365181713" />
|
||||
<state x="414" y="195" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622503192333" />
|
||||
<state x="628" y="343" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1622475063488">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="628" y="343" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622475063488" />
|
||||
<state x="628" y="343" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1920.1080@0.0.1920.1080" timestamp="1621109431051" />
|
||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1622413487618">
|
||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1622503875969">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622413487618" />
|
||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622503875969" />
|
||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1621429221570" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1622477545943">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1622505570694">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622477545943" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622505570694" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1621429389327" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1622477545943">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1622505570694">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622477545943" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622505570694" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1621429389327" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1622477545943">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1622505570694">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622477545943" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622505570694" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1621429389326" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1622477545943">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1622505570694">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622477545943" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622505570694" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1621429389327" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1619289752045">
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1622496797346">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622496797346" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1619289752045" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.center" timestamp="1619289752045">
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.center" timestamp="1622496797346">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.center/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622496797346" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.center/0.0.1920.1080@0.0.1920.1080" timestamp="1619289752045" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.left" timestamp="1619289752045">
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.left" timestamp="1622496797346">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.left/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622496797346" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.left/0.0.1920.1080@0.0.1920.1080" timestamp="1619289752045" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.right" timestamp="1619289752045">
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.right" timestamp="1622496797346">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622496797346" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1619289752045" />
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1622474297784">
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1622499624475">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622474297784" />
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622499624475" />
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1621439087317" />
|
||||
<state x="623" y="235" width="672" height="678" key="search.everywhere.popup" timestamp="1622475419309">
|
||||
<state x="623" y="235" width="672" height="678" key="search.everywhere.popup" timestamp="1622494466933">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="623" y="235" width="672" height="678" key="search.everywhere.popup/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622475419309" />
|
||||
<state x="623" y="235" width="672" height="678" key="search.everywhere.popup/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622494466933" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
@ -240,7 +247,9 @@
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/SmartCart$copy.coverage" NAME="copy Coverage Results" MODIFIED="1622503170538" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/SmartCart$glue.coverage" NAME="glue Coverage Results" MODIFIED="1622501306368" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1622469837941" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/SmartCart$py.coverage" NAME="py Coverage Results" MODIFIED="1622475876802" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/SmartCart$py.coverage" NAME="py Coverage Results" MODIFIED="1622505478603" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
</component>
|
||||
</project>
|
@ -4,12 +4,12 @@ from torch.optim import Adam
|
||||
from torch.utils.data import DataLoader
|
||||
from torchvision.transforms import transforms
|
||||
import glob
|
||||
import numpy as np
|
||||
import os
|
||||
import pathlib
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
import torchvision
|
||||
transformer1 = transforms.Compose([transforms.Resize((150, 150)), transforms.ToTensor(), transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])])
|
||||
class ConvNet(nn.Module):
|
||||
def __init__(self, num_classes=6):
|
||||
super(ConvNet, self).__init__()
|
||||
@ -36,34 +36,27 @@ class ConvNet(nn.Module):
|
||||
output = output.view(-1, 32 * 75 * 75)
|
||||
output = self.fc(output)
|
||||
return output
|
||||
def create_neural_network():
|
||||
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
def create_neural_network(): #tworzenie sieci neuronowej
|
||||
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') #użyj cuda jeśli możliwe
|
||||
transformer = transforms.Compose([transforms.Resize((150, 150)), transforms.RandomHorizontalFlip(), transforms.ToTensor(), transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])])
|
||||
train_path = os.path.join('resources/neural_network/train/')
|
||||
test_path = os.path.join('resources/neural_network/test/')
|
||||
pred_path = os.path.join('resources/neural_network/pred/')
|
||||
train_path = os.path.join('resources/neural_network/train/') #ścieżka do obrazków do treningu
|
||||
test_path = os.path.join('resources/neural_network/test/') #ścieżka do obrazków do testu
|
||||
train_loader = DataLoader(torchvision.datasets.ImageFolder(train_path, transform=transformer), batch_size=64, shuffle=True)
|
||||
test_loader = DataLoader(torchvision.datasets.ImageFolder(test_path, transform=transformer), batch_size=32, shuffle=True)
|
||||
root = pathlib.Path(train_path)
|
||||
classes = sorted([j.name.split('/')[-1] for j in root.iterdir()])
|
||||
if os.path.exists("resources/neural_network/checkpoint.model"):
|
||||
if os.path.exists("resources/neural_network/checkpoint.model"): #jeżeli istnieje model to wczytaj
|
||||
checkpoint = torch.load(os.path.join('resources/neural_network', 'checkpoint.model'))
|
||||
model = ConvNet(num_classes=6)
|
||||
model.load_state_dict(checkpoint)
|
||||
model.eval()
|
||||
transformer1 = transforms.Compose([transforms.Resize((150, 150)), transforms.ToTensor(), transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])])
|
||||
images_path = glob.glob(pred_path+'/*.jpg')
|
||||
pred_dict = {}
|
||||
for i in images_path:
|
||||
pred_dict[i[i.rfind('/') + 1:]] = prediction1(classes, i, model, transformer1)
|
||||
print(pred_dict)
|
||||
else:
|
||||
else: #w przeciwnym razie utwórz nowy model
|
||||
model = ConvNet(num_classes=6).to(device)
|
||||
optimizer = Adam(model.parameters(), lr=0.001, weight_decay=0.0001)
|
||||
loss_function = nn.CrossEntropyLoss()
|
||||
num_epochs = 10
|
||||
train_count = len(glob.glob(train_path + '/**/*.jpg'))
|
||||
test_count = len(glob.glob(test_path + '/**/*.jpg'))
|
||||
train_count = len(glob.glob(train_path + '/**/*.png')) #liczba obrazków treningowych
|
||||
test_count = len(glob.glob(test_path + '/**/*.png')) #liczba obrazków testowych
|
||||
best_accuracy = 0.0
|
||||
for epoch in range(num_epochs):
|
||||
model.train()
|
||||
@ -97,8 +90,39 @@ def create_neural_network():
|
||||
if test_accuracy > best_accuracy:
|
||||
torch.save(model.state_dict(), 'resources/neural_network/checkpoint.model')
|
||||
best_accuracy = test_accuracy
|
||||
def prediction1(classes, img_path, model, transformer):
|
||||
image = Image.open(img_path)
|
||||
checkpoint = torch.load(os.path.join('resources/neural_network', 'checkpoint.model'))
|
||||
model = ConvNet(num_classes=6)
|
||||
model.load_state_dict(checkpoint)
|
||||
model.eval()
|
||||
return classes, model
|
||||
def predfield(classes, model): #zwraca miejsce pola z wyrośniętą rośliną na podstawie wykrywania obrazu
|
||||
pred_path = os.path.join('resources/neural_network/sliced/') #ścieżka do obrazków do sprawdzenia
|
||||
pred_dict = {}
|
||||
images_path = glob.glob(pred_path + '/*.png')
|
||||
x = None #x'owa pola
|
||||
y = None#y'kowa pola
|
||||
for i in images_path: #dodajemy pocięte obrazki do listy i ustawiamy im przewidywaną metkę
|
||||
pred_dict[i[i.rfind('/') + 1:]] = prediction1(classes, i, model, transformer1)
|
||||
for img_name, field in pred_dict.items():
|
||||
if field != "random": #jeżeli metka nie jest 'random' to przypisz do x'a i y'a miejsce wyrośniętej rośliny
|
||||
x = img_name[15]
|
||||
y = img_name[18]
|
||||
x = int(x)
|
||||
y = int(y)
|
||||
if x == 0:
|
||||
x = 9
|
||||
else:
|
||||
x = x - 1
|
||||
if y == 0:
|
||||
y = 9
|
||||
else:
|
||||
y = y - 1
|
||||
if x == None and y == None: #jeżeli nie ma wyrośniętej rośliny to zwróć False
|
||||
return False
|
||||
else:
|
||||
return y, x
|
||||
def prediction1(classes, img_path, model, transformer): #zwraca predykcję dla danego obrazka
|
||||
image = Image.open(img_path).convert('RGB')
|
||||
image_tensor = transformer(image).float()
|
||||
image_tensor = image_tensor.unsqueeze_(0)
|
||||
if torch.cuda.is_available():
|
||||
|
38
plant.py
@ -12,30 +12,6 @@ class Plant:
|
||||
def set_state(self, state):
|
||||
self.state = state
|
||||
@staticmethod
|
||||
def get_mature_plant(map): #pobiera współrzędne jakiejś dojrzałej rośliny
|
||||
x = -1
|
||||
y = -1
|
||||
for i in range(definitions.WIDTH_AMOUNT):
|
||||
for j in range(definitions.HEIGHT_AMOUNT):
|
||||
field = map.get_fields()[i][j]
|
||||
if field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() == definitions.BEETROOTS_MAXIMUM_STATE:
|
||||
x = i
|
||||
y = j
|
||||
elif field.get_plant().get_name() == "carrot" and field.get_plant().get_state() == definitions.CARROTS_MAXIMUM_STATE:
|
||||
x = i
|
||||
y = j
|
||||
elif field.get_plant().get_name() == "potato" and field.get_plant().get_state() == definitions.POTATOES_MAXIMUM_STATE:
|
||||
x = i
|
||||
y = j
|
||||
|
||||
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
|
||||
x = i
|
||||
y = j
|
||||
if x == -1 and y == -1:
|
||||
return False
|
||||
else:
|
||||
return x, y
|
||||
@staticmethod
|
||||
def grow_plants(map): #metoda statyczna, która zwiększa pole state (etap rozwoju rośliny) dla danej rośliny na danym polu o 1
|
||||
for i in range(definitions.WIDTH_AMOUNT):
|
||||
for j in range(definitions.HEIGHT_AMOUNT):
|
||||
@ -48,17 +24,3 @@ class Plant:
|
||||
field.get_plant().set_state(field.get_plant().get_state() + 1)
|
||||
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.WHEAT_MAXIMUM_STATE:
|
||||
field.get_plant().set_state(field.get_plant().get_state() + 1)
|
||||
@staticmethod
|
||||
def if_any_mature_plant(map): #sprawdza czy na polu występuje choć jedna dojrzała roślina, jeśli tak zwraca prawdę, w przeciwnym razie zwraca fałsz
|
||||
for i in range(definitions.WIDTH_AMOUNT):
|
||||
for j in range(definitions.HEIGHT_AMOUNT):
|
||||
field = map.get_fields()[i][j]
|
||||
if field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() == definitions.BEETROOTS_MAXIMUM_STATE:
|
||||
return True
|
||||
elif field.get_plant().get_name() == "carrot" and field.get_plant().get_state() == definitions.CARROTS_MAXIMUM_STATE:
|
||||
return True
|
||||
elif field.get_plant().get_name() == "potato" and field.get_plant().get_state() == definitions.POTATOES_MAXIMUM_STATE:
|
||||
return True
|
||||
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
|
||||
return True
|
||||
return False
|
13
py.py
@ -2,8 +2,10 @@ import astar
|
||||
import cart
|
||||
import definitions
|
||||
import graph
|
||||
import image_slicer
|
||||
import map
|
||||
import neuralnetwork
|
||||
import os
|
||||
import plant
|
||||
import pygame
|
||||
import station
|
||||
@ -23,7 +25,7 @@ def main():
|
||||
clock = pygame.time.Clock()
|
||||
tree = treelearn.treelearn() #tworzenie drzewa decyzyjnego
|
||||
decision = [0] #początkowa decyzja o braku powrotu do stacji (0)
|
||||
#neuralnetwork.create_neural_network()
|
||||
classes, model = neuralnetwork.create_neural_network() #uczenie sieci neuronowej
|
||||
run = True
|
||||
while run: #pętla główna programu
|
||||
clock.tick(definitions.FPS)
|
||||
@ -31,10 +33,13 @@ def main():
|
||||
if event.type == pygame.QUIT:
|
||||
run = False
|
||||
map1.draw_window(cart1, cart1_rect)
|
||||
if not move_list and plant.Plant.if_any_mature_plant(map1) is True: #jeżeli są jakieś ruchy do wykonania w move_list oraz istnieje jakaś dojrzała roślina
|
||||
istate = graph.Istate(cart1.get_direction(), cart1.get_x() / definitions.BLOCK_SIZE, cart1.get_y() / definitions.BLOCK_SIZE) #stan początkowy wózka (jego orientacja oraz jego aktualne współrzędne)
|
||||
pygame.image.save(pygame.display.get_surface(), os.path.join('resources/neural_network/sliced/', 'screen.jpg')) #zrzut obecnego ekranu
|
||||
image_slicer.slice(os.path.join('resources/neural_network/sliced/', 'screen.jpg'), 100) #pocięcie ekranu na sto części
|
||||
os.remove('resources/neural_network/sliced/screen.jpg')
|
||||
if not move_list and neuralnetwork.predfield(classes, model) is not False: #jeżeli są jakieś ruchy do wykonania w move_list oraz istnieje jakaś dojrzała roślina
|
||||
istate = graph.Istate(cart1.get_direction(), cart1.get_x() / definitions.BLOCK_SIZE, cart1.get_y() / definitions.BLOCK_SIZE) #stan początkowy wózka (jego orientacja oraz jego aktualne miejsce)
|
||||
if decision == [0]: #jeżeli decyzja jest 0 (brak powrotu do stacji) to uprawiaj pole
|
||||
move_list = (astar.graphsearch([], astar.f, [], plant.Plant.get_mature_plant(map1), istate, map1, graph.succ)) #lista z ruchami, które należy po kolei wykonać, astar
|
||||
move_list = (astar.graphsearch([], astar.f, [], neuralnetwork.predfield(classes, model), istate, map1, graph.succ)) #lista z ruchami, które należy po kolei wykonać, astar
|
||||
else: #jeżeli decyzja jest 1 (powrót do stacji) to wróć do stacji uzupełnić zapasy
|
||||
move_list = (graph.graphsearch([], [], (0, 0), istate, graph.succ)) #lista z ruchami, które należy po kolei wykonać, graphsearch
|
||||
elif move_list: #jeżeli move_list nie jest pusta
|
||||
|
BIN
resources/neural_network/checkpoint.model
Normal file
BIN
resources/neural_network/pred/0.png
Normal file
After Width: | Height: | Size: 700 B |
BIN
resources/neural_network/pred/1.png
Normal file
After Width: | Height: | Size: 712 B |
BIN
resources/neural_network/pred/10.png
Normal file
After Width: | Height: | Size: 610 B |
BIN
resources/neural_network/pred/11.png
Normal file
After Width: | Height: | Size: 145 B |
BIN
resources/neural_network/pred/12.png
Normal file
After Width: | Height: | Size: 590 B |
BIN
resources/neural_network/pred/13.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
resources/neural_network/pred/14.png
Normal file
After Width: | Height: | Size: 518 B |
BIN
resources/neural_network/pred/15.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
resources/neural_network/pred/16.png
Normal file
After Width: | Height: | Size: 700 B |
BIN
resources/neural_network/pred/17.png
Normal file
After Width: | Height: | Size: 712 B |
BIN
resources/neural_network/pred/18.png
Normal file
After Width: | Height: | Size: 769 B |
BIN
resources/neural_network/pred/19.png
Normal file
After Width: | Height: | Size: 726 B |
BIN
resources/neural_network/pred/2.png
Normal file
After Width: | Height: | Size: 769 B |
BIN
resources/neural_network/pred/20.png
Normal file
After Width: | Height: | Size: 793 B |
BIN
resources/neural_network/pred/21.png
Normal file
After Width: | Height: | Size: 692 B |
BIN
resources/neural_network/pred/22.png
Normal file
After Width: | Height: | Size: 726 B |
BIN
resources/neural_network/pred/23.png
Normal file
After Width: | Height: | Size: 752 B |
BIN
resources/neural_network/pred/24.png
Normal file
After Width: | Height: | Size: 788 B |
BIN
resources/neural_network/pred/25.png
Normal file
After Width: | Height: | Size: 777 B |
BIN
resources/neural_network/pred/26.png
Normal file
After Width: | Height: | Size: 804 B |
BIN
resources/neural_network/pred/27.png
Normal file
After Width: | Height: | Size: 801 B |
BIN
resources/neural_network/pred/28.png
Normal file
After Width: | Height: | Size: 813 B |
BIN
resources/neural_network/pred/3.png
Normal file
After Width: | Height: | Size: 793 B |
BIN
resources/neural_network/pred/4.png
Normal file
After Width: | Height: | Size: 700 B |
BIN
resources/neural_network/pred/5.png
Normal file
After Width: | Height: | Size: 712 B |
BIN
resources/neural_network/pred/6.png
Normal file
After Width: | Height: | Size: 769 B |
BIN
resources/neural_network/pred/7.png
Normal file
After Width: | Height: | Size: 785 B |
BIN
resources/neural_network/pred/8.png
Normal file
After Width: | Height: | Size: 266 B |
BIN
resources/neural_network/pred/9.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
resources/neural_network/sliced/screen_01_01.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
resources/neural_network/sliced/screen_01_02.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_01_03.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_01_04.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_01_05.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_01_06.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_01_07.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_01_08.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_01_09.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_01_10.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_02_01.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
resources/neural_network/sliced/screen_02_02.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_02_03.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_02_04.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_02_05.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_02_06.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_02_07.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_02_08.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_02_09.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_02_10.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_03_01.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
resources/neural_network/sliced/screen_03_02.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
resources/neural_network/sliced/screen_03_03.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
resources/neural_network/sliced/screen_03_04.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_03_05.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_03_06.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_03_07.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_03_08.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_03_09.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_03_10.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_04_01.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
resources/neural_network/sliced/screen_04_02.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
resources/neural_network/sliced/screen_04_03.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_04_04.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_04_05.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_04_06.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_04_07.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_04_08.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_04_09.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_04_10.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_01.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_02.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_03.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
resources/neural_network/sliced/screen_05_04.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_05.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_06.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_07.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_08.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_09.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_05_10.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_06_01.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_06_02.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_06_03.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_06_04.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_06_05.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_06_06.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_06_07.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_06_08.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
resources/neural_network/sliced/screen_06_09.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_06_10.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_07_01.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
resources/neural_network/sliced/screen_07_02.png
Normal file
After Width: | Height: | Size: 6.7 KiB |