najbliższe pole
@ -20,7 +20,6 @@
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_04.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_05.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_06.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_07.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_01.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_02.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_03.png" afterDir="false" />
|
||||
@ -37,7 +36,6 @@
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_07.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_08.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_09.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_10.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_06_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_06_01.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_06_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_06_02.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_06_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_06_03.png" afterDir="false" />
|
||||
@ -233,6 +231,8 @@
|
||||
<workItem from="1622535418118" duration="3519000" />
|
||||
<workItem from="1622539085394" duration="24000" />
|
||||
<workItem from="1622539306453" duration="4588000" />
|
||||
<workItem from="1622544012547" duration="1597000" />
|
||||
<workItem from="1622545712675" duration="82000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -254,25 +254,25 @@
|
||||
</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="1622536049152" />
|
||||
<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="1622543931828">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1622545794822">
|
||||
<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="1622543931828" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622545794822" />
|
||||
<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="1622543931827">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1622545794822">
|
||||
<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="1622543931827" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622545794822" />
|
||||
<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="1622543931827">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1622545794822">
|
||||
<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="1622543931827" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622545794822" />
|
||||
<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="1622543931827">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1622545794822">
|
||||
<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="1622543931827" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622545794822" />
|
||||
<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="1622538962724">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
@ -294,10 +294,10 @@
|
||||
</state>
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622538962724" />
|
||||
<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="1622539085140">
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1622545712780">
|
||||
<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="1622539085140" />
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622545712780" />
|
||||
<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="1622494466933">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
@ -319,6 +319,6 @@
|
||||
<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="1622543817734" 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="1622545719029" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
</component>
|
||||
</project>
|
@ -54,7 +54,7 @@ FARMLAND_DRY_COST = 3
|
||||
FARMLAND_WET = pygame.image.load(os.path.join('resources/images', 'farmland_wet.png'))
|
||||
FARMLAND_WET = pygame.transform.scale(FARMLAND_WET, (BLOCK_SIZE, BLOCK_SIZE))
|
||||
FARMLAND_WET_COST = 1
|
||||
FPS = 10
|
||||
FPS = 1
|
||||
POTATOES_ADULT_COST = 4
|
||||
POTATOES_GROW_COST = 10
|
||||
POTATOES_GROW_TIME = 5
|
||||
|
@ -4,6 +4,7 @@ from torch.optim import Adam
|
||||
from torch.utils.data import DataLoader
|
||||
from torchvision.transforms import transforms
|
||||
import glob
|
||||
import graph
|
||||
import os
|
||||
import pathlib
|
||||
import torch
|
||||
@ -95,13 +96,10 @@ def create_neural_network(): #tworzenie sieci neuronowej
|
||||
model.load_state_dict(checkpoint)
|
||||
model.eval()
|
||||
return classes, model
|
||||
def predfield(cart_direction, cart_x, cart_y, classes, model): #zwraca najbliższe miejsce pola z wyrośniętą rośliną na podstawie wykrywania obrazu
|
||||
def predfield(classes, istate, model): #zwraca najbliższe 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')
|
||||
cart_x = int(cart_x) #x'owa wózka
|
||||
cart_y = int(cart_y) #y'owa wózka
|
||||
additional_rotate_moves = 0
|
||||
x = None #x'owa pola
|
||||
y = None #y'kowa pola
|
||||
min = None
|
||||
@ -122,7 +120,8 @@ def predfield(cart_direction, cart_x, cart_y, classes, model): #zwraca najbliżs
|
||||
y = 9
|
||||
else:
|
||||
y = y - 1
|
||||
min = abs(cart_x - x) + abs(cart_y - y) + additional_rotate_moves
|
||||
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
|
||||
print(min)
|
||||
else:
|
||||
temp_x = img_name[18]
|
||||
temp_y = img_name[15]
|
||||
@ -136,15 +135,13 @@ def predfield(cart_direction, cart_x, cart_y, classes, model): #zwraca najbliżs
|
||||
temp_y = 9
|
||||
else:
|
||||
temp_y = temp_y - 1
|
||||
if abs(cart_x - temp_x) + abs(cart_y - temp_y) + additional_rotate_moves < min:
|
||||
if len((graph.graphsearch([], [], (temp_x, temp_y), istate, graph.succ))) < min:
|
||||
min = len((graph.graphsearch([], [], (temp_x, temp_y), istate, graph.succ)))
|
||||
x = temp_x
|
||||
y = temp_y
|
||||
min = abs(cart_x - x) + abs(cart_y - y) + additional_rotate_moves
|
||||
if x == None and y == None: #jeżeli nie ma wyrośniętej rośliny to zwróć False
|
||||
if x == None and y == None: #jeżeli nie ma wyrośniętej rośliny to zwróć fałsz
|
||||
return False
|
||||
else:
|
||||
print(x, y)
|
||||
print(min)
|
||||
return x, y
|
||||
def prediction1(classes, img_path, model, transformer): #zwraca predykcję dla danego obrazka
|
||||
image = Image.open(img_path).convert('RGB')
|
||||
|
6
py.py
@ -38,11 +38,11 @@ def main():
|
||||
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 neuralnetwork.predfield(cart1.get_direction(), cart1.get_x() / definitions.BLOCK_SIZE, cart1.get_y() / definitions.BLOCK_SIZE, classes, model) is not False: #jeżeli istnieje jakaś dojrzała roślina
|
||||
random_movement = False
|
||||
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 neuralnetwork.predfield(classes, istate, model) is not False: #jeżeli istnieje jakaś dojrzała roślina
|
||||
random_movement = False
|
||||
if decision == [0]: #jeżeli decyzja jest 0 (brak powrotu do stacji) to uprawiaj pole
|
||||
move_list = (astar.graphsearch([], astar.f, [], neuralnetwork.predfield(cart1.get_direction(), cart1.get_x() / definitions.BLOCK_SIZE, cart1.get_y() / definitions.BLOCK_SIZE, classes, model), istate, map1, graph.succ)) #lista z ruchami, które należy po kolei wykonać, astar
|
||||
move_list = (astar.graphsearch([], astar.f, [], neuralnetwork.predfield(classes, istate, 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
|
||||
else:
|
||||
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |