mniej screenshotów
@ -2,27 +2,18 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen.jpg" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/definitions.py" beforeDir="false" afterPath="$PROJECT_DIR$/definitions.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/neuralnetwork.py" beforeDir="false" afterPath="$PROJECT_DIR$/neuralnetwork.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_01.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_02.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_03.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_04.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_05.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_06.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_07.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_08.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_09.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_01_10.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_01.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_02.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_03.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_04.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_05.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_06.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_07.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_08.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_09.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_02_10.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_01.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_02.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_03.png" afterDir="false" />
|
||||
@ -30,8 +21,6 @@
|
||||
<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_03_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_09.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_03_10.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" />
|
||||
@ -39,8 +28,6 @@
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_05.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_06.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_07.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_09.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_04_10.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_01.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_02.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_05_03.png" afterDir="false" />
|
||||
@ -81,8 +68,6 @@
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_08_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_08_08.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_08_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_08_09.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_08_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_08_10.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_05.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_06.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_07.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_08.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/sliced/screen_09_09.png" afterDir="false" />
|
||||
@ -247,6 +232,7 @@
|
||||
<workItem from="1622499624637" duration="5901000" />
|
||||
<workItem from="1622535418118" duration="3519000" />
|
||||
<workItem from="1622539085394" duration="24000" />
|
||||
<workItem from="1622539306453" duration="4588000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -268,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="1622539108694">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1622543931828">
|
||||
<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="1622539108694" />
|
||||
<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@0.0.1920.1080" timestamp="1621429389327" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1622539108694">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1622543931827">
|
||||
<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="1622539108694" />
|
||||
<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@0.0.1920.1080" timestamp="1621429389327" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1622539108694">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1622543931827">
|
||||
<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="1622539108694" />
|
||||
<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@0.0.1920.1080" timestamp="1621429389326" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1622539108694">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1622543931827">
|
||||
<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="1622539108694" />
|
||||
<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@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" />
|
||||
@ -333,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="1622539089888" 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$" />
|
||||
</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 = 1
|
||||
FPS = 10
|
||||
POTATOES_ADULT_COST = 4
|
||||
POTATOES_GROW_COST = 10
|
||||
POTATOES_GROW_TIME = 5
|
||||
|
@ -95,32 +95,57 @@ def create_neural_network(): #tworzenie sieci neuronowej
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
if x is None and y is None:
|
||||
x = img_name[18]
|
||||
y = img_name[15]
|
||||
x = int(x)
|
||||
y = int(y)
|
||||
if x == 0:
|
||||
x = 9
|
||||
else:
|
||||
x = x - 1
|
||||
if y == 0:
|
||||
y = 9
|
||||
else:
|
||||
y = y - 1
|
||||
min = abs(cart_x - x) + abs(cart_y - y) + additional_rotate_moves
|
||||
else:
|
||||
x = x - 1
|
||||
if y == 0:
|
||||
y = 9
|
||||
else:
|
||||
y = y - 1
|
||||
temp_x = img_name[18]
|
||||
temp_y = img_name[15]
|
||||
temp_x = int(temp_x)
|
||||
temp_y = int(temp_y)
|
||||
if temp_x == 0:
|
||||
temp_x = 9
|
||||
else:
|
||||
temp_x = temp_x - 1
|
||||
if temp_y == 0:
|
||||
temp_y = 9
|
||||
else:
|
||||
temp_y = temp_y - 1
|
||||
if abs(cart_x - temp_x) + abs(cart_y - temp_y) + additional_rotate_moves < min:
|
||||
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
|
||||
return False
|
||||
else:
|
||||
return y, x
|
||||
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')
|
||||
image_tensor = transformer(image).float()
|
||||
|
25
py.py
@ -26,6 +26,7 @@ def main():
|
||||
tree = treelearn.treelearn() #tworzenie drzewa decyzyjnego
|
||||
decision = [0] #początkowa decyzja o braku powrotu do stacji (0)
|
||||
classes, model = neuralnetwork.create_neural_network() #uczenie sieci neuronowej
|
||||
random_movement = False
|
||||
run = True
|
||||
while run: #pętla główna programu
|
||||
clock.tick(definitions.FPS)
|
||||
@ -33,18 +34,22 @@ def main():
|
||||
if event.type == pygame.QUIT:
|
||||
run = False
|
||||
map1.draw_window(cart1, cart1_rect)
|
||||
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, [], 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
|
||||
if not move_list: #jeżeli są jakieś ruchy do wykonania w move_list
|
||||
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 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
|
||||
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:
|
||||
random_movement = True
|
||||
elif move_list: #jeżeli move_list nie jest pusta
|
||||
cart1.handle_movement(cart1_rect, move_list.pop(0)) #wykonaj kolejny ruch oraz zdejmij ten ruch z początku listy
|
||||
else:
|
||||
if random_movement is not False:
|
||||
cart1.handle_movement_random(cart1_rect) #wykonuj losowe ruchy
|
||||
cart1.do_work(cart1_rect, map1, station1) #wykonaj pracę na danym polu
|
||||
decision = treelearn.make_decision(cart1.get_all_amount_of_seeds(), cart1.get_all_collected_plants(), cart1.get_all_fertilizer(), cart1.get_fuel(), tree, cart1.get_water_level()) #podejmij decyzję czy wracać do stacji (0 : NIE, 1 : TAK)
|
||||
|
Before Width: | Height: | Size: 7.5 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.7 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.7 KiB After Width: | Height: | Size: 6.6 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: 6.6 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.7 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.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 5.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: 5.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.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.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.1 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 |
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.2 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 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: 5.2 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 5.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: 5.3 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 5.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.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 |
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: 5.3 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.6 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 |