This commit is contained in:
Tomasz Adamczyk 2021-06-13 16:28:40 +02:00
parent 8caab5a3bd
commit 007304c2ac
85 changed files with 321 additions and 31 deletions

View File

@ -3,10 +3,34 @@
<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$/definitions.py" beforeDir="false" afterPath="$PROJECT_DIR$/definitions.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$/resources/neural_network/tiles/tile_01_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_01.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_02.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_03.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_04.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_05.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_06.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_01_07.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_01.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_02.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_03.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_04.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_05.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_06.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_02_07.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_01.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_02.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_03.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_04.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_05.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_06.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_03_07.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_01.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_02.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_03.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_04.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_05.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_06.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_04_07.png" afterDir="false" />
@ -37,6 +61,7 @@
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_07_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_07_08.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_07_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_07_09.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_07_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_07_10.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_01.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_02.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_03.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_04.png" afterDir="false" />
@ -46,6 +71,16 @@
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_08.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_09.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_08_10.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_01.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_01.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_02.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_02.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_03.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_03.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_04.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_04.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_05.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_05.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_06.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_06.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_07.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_07.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_08.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_08.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_09.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_09.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_10.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/neural_network/tiles/tile_09_10.png" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -217,6 +252,11 @@
<workItem from="1622904041533" duration="226000" />
<workItem from="1622904271971" duration="12000" />
<workItem from="1622921561418" duration="3872000" />
<workItem from="1622976899995" duration="1243000" />
<workItem from="1622989814058" duration="2000" />
<workItem from="1623575428375" duration="4887000" />
<workItem from="1623582818543" duration="8926000" />
<workItem from="1623594481441" duration="3000" />
</task>
<servers />
</component>
@ -228,35 +268,35 @@
<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="1622503192333" />
<state x="628" y="343" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1622475063488">
<state x="628" y="343" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1623590970552">
<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/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623590970552" />
<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="1622802726751">
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1623591065954">
<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="1622802726751" />
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623591065954" />
<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="1622925953140">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1623594478725">
<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="1622925953140" />
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623594478725" />
<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="1622925953140">
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1623594478725">
<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="1622925953140" />
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623594478725" />
<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="1622925953140">
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1623594478725">
<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="1622925953140" />
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623594478725" />
<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="1622925953140">
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1623594478725">
<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="1622925953140" />
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623594478725" />
<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="1622903620068">
<screen x="0" y="0" width="1920" height="1080" />
@ -278,11 +318,15 @@
</state>
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1622903620068" />
<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="1622921561189">
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1623582818117">
<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="1622921561189" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623582818117" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1621439087317" />
<state x="615" y="209" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser" timestamp="1623589256933">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state x="615" y="209" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser/0.0.1920.1080/-1920.0.1920.1080@0.0.1920.1080" timestamp="1623589256933" />
<state x="623" y="235" width="672" height="678" key="search.everywhere.popup" timestamp="1622900746217">
<screen x="0" y="0" width="1920" height="1080" />
</state>
@ -303,6 +347,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="1622925873783" 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="1623592389826" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,8 +5,8 @@ pygame.init()
BLOCK_SIZE = 60
BEETROOT = pygame.image.load(os.path.join('resources/images', 'beetroot.png'))
BEETROOT = pygame.transform.scale(BEETROOT, (BLOCK_SIZE, BLOCK_SIZE))
BEETROOTS_ADULT_COST = 4
BEETROOTS_GROW_COST = 10
BEETROOTS_ADULT_COST = None
BEETROOTS_GROW_COST = None
BEETROOTS_GROW_TIME = 5
BEETROOTS_MAXIMUM_STATE = BEETROOTS_GROW_TIME * 3 + 1
BEETROOTS_STAGE_0 = pygame.image.load(os.path.join('resources/images', 'beetroots_stage_0.png'))
@ -19,8 +19,8 @@ BEETROOTS_STAGE_3 = pygame.image.load(os.path.join('resources/images', 'beetroot
BEETROOTS_STAGE_3 = pygame.transform.scale(BEETROOTS_STAGE_3, (BLOCK_SIZE, BLOCK_SIZE))
CARROT = pygame.image.load(os.path.join('resources/images', 'carrot.png'))
CARROT = pygame.transform.scale(CARROT, (BLOCK_SIZE, BLOCK_SIZE))
CARROTS_ADULT_COST = 4
CARROTS_GROW_COST = 10
CARROTS_ADULT_COST = None
CARROTS_GROW_COST = None
CARROTS_GROW_TIME = 5
CARROTS_MAXIMUM_STATE = CARROTS_GROW_TIME * 3 + 1
CARROTS_STAGE_0 = pygame.image.load(os.path.join('resources/images', 'carrots_stage_0.png'))
@ -46,34 +46,34 @@ CART_DIRECTION_WEST = 4
CART_FERTILIZER = 2
CART_FUEL = 200
CART_AMOUNT_OF_SEEDS_EACH_TYPE = 20
CART_MAXIMUM_COLLECTED_PLANTS = 80
CART_MAXIMUM_COLLECTED_PLANTS = 200
CART_WATER_LEVEL = 40
DIRT = pygame.image.load(os.path.join('resources/images', 'dirt.png'))
DIRT = pygame.transform.scale(DIRT, (BLOCK_SIZE, BLOCK_SIZE))
DIRT_COST = 2
DIRT_COST = None
FARMLAND_DRY = pygame.image.load(os.path.join('resources/images', 'farmland_dry.png'))
FARMLAND_DRY = pygame.transform.scale(FARMLAND_DRY, (BLOCK_SIZE, BLOCK_SIZE))
FARMLAND_DRY_COST = 3
FARMLAND_DRY_COST = None
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
FARMLAND_WET_COST = None
FLOWER_DANDELION = pygame.image.load(os.path.join('resources/images', 'flower_dandelion.png'))
FLOWER_DANDELION = pygame.transform.scale(FLOWER_DANDELION, (BLOCK_SIZE, BLOCK_SIZE))
FLOWER_DANDELION_COST = 5
FLOWER_DANDELION_COST = None
FLOWER_DANDELION_GROW_PROBABILITY = 0.01
FLOWER_DANDELION_MAXIMUM_STATE = 1
FONT_COLOR = (255, 255, 255)
FONT_SIZE = 23
FONT = pygame.font.Font(os.path.join('resources/font', 'Minecraft.ttf'), FONT_SIZE)
FPS = 1
FPS = 10
HEIGHT_AMOUNT, WIDTH_AMOUNT = 10, 10
HEIGHT_MAP, WIDTH_MAP = BLOCK_SIZE * HEIGHT_AMOUNT, BLOCK_SIZE * WIDTH_AMOUNT
HEIGHT, WIDTH = HEIGHT_MAP + BLOCK_SIZE, WIDTH_MAP
IMAGE_SIZE_NEURAL_NETWORK = 16
POTATO = pygame.image.load(os.path.join('resources/images', 'potato.png'))
POTATO = pygame.transform.scale(POTATO, (BLOCK_SIZE, BLOCK_SIZE))
POTATOES_ADULT_COST = 4
POTATOES_GROW_COST = 10
POTATOES_ADULT_COST = None
POTATOES_GROW_COST = None
POTATOES_GROW_TIME = 5
POTATOES_MAXIMUM_STATE = POTATOES_GROW_TIME * 3 + 1
POTATOES_STAGE_0 = pygame.image.load(os.path.join('resources/images', 'potatoes_stage_0.png'))
@ -90,11 +90,11 @@ SPONGE_WET = pygame.image.load(os.path.join('resources/images', 'sponge_wet.png'
SPONGE_WET = pygame.transform.scale(SPONGE_WET, (BLOCK_SIZE, BLOCK_SIZE))
STATION = pygame.image.load(os.path.join('resources/images', 'rail_normal.png'))
STATION = pygame.transform.scale(STATION, (BLOCK_SIZE, BLOCK_SIZE))
STATION_COST = 6
STATION_COST = None
WHEAT = pygame.image.load(os.path.join('resources/images', 'wheat.png'))
WHEAT = pygame.transform.scale(WHEAT, (BLOCK_SIZE, BLOCK_SIZE))
WHEAT_ADULT_COST = 4
WHEAT_GROW_COST = 10
WHEAT_ADULT_COST = None
WHEAT_GROW_COST = None
WHEAT_GROW_TIME = 5
WHEAT_MAXIMUM_STATE = WHEAT_GROW_TIME * 7 + 1
WHEAT_STAGE_0 = pygame.image.load(os.path.join('resources/images', 'wheat_stage_0.png'))

180
geneticalgorithm.py Normal file
View File

@ -0,0 +1,180 @@
import astar
import cart
import definitions
import graph
import map
import os
import pickle
import plant
import pygame
import random
import station
import treelearn
def create_genetic_algorithm():
if os.path.exists("resources/genetic_algorithm/optimal.pkl"): #jeżeli drzewo jest zapisane w pliku to odczytaj
astar_costs = pickle.load(open(os.path.join('resources/genetic_algorithm', "optimal.pkl"), "rb"))
definitions.BEETROOTS_ADULT_COST = astar_costs[0]
definitions.BEETROOTS_GROW_COST = astar_costs[1]
definitions.CARROTS_ADULT_COST = astar_costs[2]
definitions.CARROTS_GROW_COST = astar_costs[3]
definitions.DIRT_COST = astar_costs[4]
definitions.FARMLAND_DRY_COST = astar_costs[5]
definitions.FARMLAND_WET_COST = astar_costs[6]
definitions.FLOWER_DANDELION_COST = astar_costs[7]
definitions.POTATOES_ADULT_COST = astar_costs[8]
definitions.POTATOES_GROW_COST = astar_costs[9]
definitions.STATION_COST = astar_costs[10]
definitions.WHEAT_ADULT_COST = astar_costs[11]
definitions.WHEAT_GROW_COST = astar_costs[12]
print(definitions.BEETROOTS_ADULT_COST)
print(definitions.BEETROOTS_GROW_COST)
else:
astar_costs = [definitions.BEETROOTS_ADULT_COST, definitions.BEETROOTS_GROW_COST, definitions.CARROTS_ADULT_COST, definitions.CARROTS_GROW_COST, definitions.DIRT_COST, definitions.FARMLAND_DRY_COST, definitions.FARMLAND_WET_COST, definitions.FLOWER_DANDELION_COST, definitions.POTATOES_ADULT_COST, definitions.POTATOES_GROW_COST, definitions.STATION_COST, definitions.WHEAT_ADULT_COST, definitions.WHEAT_GROW_COST]
astar_costs = make_generations(astar_costs)
pickle.dump(astar_costs, open(os.path.join('resources/genetic_algorithm', "optimal.pkl"), "wb"))
def fitness(astar_costs):
ans = solution(astar_costs)
if ans == 0:
return 0
else:
return 1 / ans
def solution(astar_costs):
definitions.BEETROOTS_ADULT_COST = astar_costs[0]
definitions.BEETROOTS_GROW_COST = astar_costs[1]
definitions.CARROTS_ADULT_COST = astar_costs[2]
definitions.CARROTS_GROW_COST = astar_costs[3]
definitions.DIRT_COST = astar_costs[4]
definitions.FARMLAND_DRY_COST = astar_costs[5]
definitions.FARMLAND_WET_COST = astar_costs[6]
definitions.FLOWER_DANDELION_COST = astar_costs[7]
definitions.POTATOES_ADULT_COST = astar_costs[8]
definitions.POTATOES_GROW_COST = astar_costs[9]
definitions.STATION_COST = astar_costs[10]
definitions.WHEAT_ADULT_COST = astar_costs[11]
definitions.WHEAT_GROW_COST = astar_costs[12]
#tworzenie podstawowych obiektów
map1 = map.Map([])
map1.create_base_map()
move_list = ["rotate_left", "move", "move", "move", "move", "move", "move", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "move", "move", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "rotate_left", "move", "rotate_left", "rotate_left", "rotate_left", "move"] #początkowe ruchy
amount_of_seeds_dict = {"beetroot": definitions.CART_AMOUNT_OF_SEEDS_EACH_TYPE, "carrot": definitions.CART_AMOUNT_OF_SEEDS_EACH_TYPE, "potato": definitions.CART_AMOUNT_OF_SEEDS_EACH_TYPE, "wheat": definitions.CART_AMOUNT_OF_SEEDS_EACH_TYPE}
collected_plants_dict_cart = {"beetroot": 0, "carrot": 0, "potato": 0, "wheat": 0}
collected_plants_dict_station = {"beetroot": 0, "carrot": 0, "potato": 0, "wheat": 0}
fertilizer_dict = {"beetroot": definitions.CART_FERTILIZER, "carrot": definitions.CART_FERTILIZER, "potato": definitions.CART_FERTILIZER, "wheat": definitions.CART_FERTILIZER}
station1 = station.Station(collected_plants_dict_station)
cart1 = cart.Cart(amount_of_seeds_dict, collected_plants_dict_cart, definitions.CART_DIRECTION_WEST, fertilizer_dict, definitions.CART_FUEL, definitions.CART_WATER_LEVEL, 0 * definitions.BLOCK_SIZE, 0 * definitions.BLOCK_SIZE)
cart1_rect = pygame.Rect(cart1.get_x(), cart1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
tree = treelearn.treelearn() #tworzenie drzewa decyzyjnego
decision = [0] #początkowa decyzja o braku powrotu do stacji (0)
grow_flower_dandelion = False
random_movement = False
for run in range(1000): #liczba ruchów wózka
if not move_list: #jeżeli są jakieś ruchy do wykonania w move_list
grow_flower_dandelion = True
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 plant.Plant.if_any_mature_plant(map1) is True: #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, [], plant.Plant.get_closest_mature_plant(istate, map1), 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
if random_movement is True:
cart1.handle_movement_random(cart1_rect) #wykonuj losowe ruchy
if grow_flower_dandelion is True:
plant.Plant.grow_flower_dandelion(map1) #losuj urośnięcie kwiatka dandeliona
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)
plant.Plant.grow_plants(map1) #zwiększ poziom dojrzałości roślin
print("Ile zebrał: ", station1.get_collected_plants("beetroot") + station1.get_collected_plants("carrot") + station1.get_collected_plants("potato") + station1.get_collected_plants("wheat"))
return station1.get_collected_plants("beetroot") + station1.get_collected_plants("carrot") + station1.get_collected_plants("potato") + station1.get_collected_plants("wheat")
def make_generations(astar_costs):
solutions = []
ans = []
for s in range(10): #liczba osobników zerowej generacji
solutions.append((random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10), random.uniform(0, 10)))
for i in range(10): #liczba generacji
ranked_solutions = []
for s in solutions:
ranked_solutions.append((fitness(s), s))
ranked_solutions.sort()
print(f"=== Gen {i + 1} best solution ===")
#print(f"=== Gen {i} best solutions ===")
print(ranked_solutions[0])
ans.append(ranked_solutions[0])
print(ans)
#można dodać warunek stopu
best_solutions = ranked_solutions[:4] #najlepsze 4 osobniki w danej generacji
elements1 = []
elements2 = []
elements3 = []
elements4 = []
elements5 = []
elements6 = []
elements7 = []
elements8 = []
elements9 = []
elements10 = []
elements11 = []
elements12 = []
elements13 = []
for s in best_solutions:
elements1.append(s[1][0])
elements2.append(s[1][1])
elements3.append(s[1][2])
elements4.append(s[1][3])
elements5.append(s[1][4])
elements6.append(s[1][5])
elements7.append(s[1][6])
elements8.append(s[1][7])
elements9.append(s[1][8])
elements10.append(s[1][9])
elements11.append(s[1][10])
elements12.append(s[1][11])
elements13.append(s[1][12])
new_gen = []
for i in range(10): # liczba osobników w kolejnej generacji
e1 = random.choice(elements1) * random.uniform(0.99, 1.01) # mutacje
e2 = random.choice(elements2) * random.uniform(0.99, 1.01)
e3 = random.choice(elements3) * random.uniform(0.99, 1.01)
e4 = random.choice(elements4) * random.uniform(0.99, 1.01)
e5 = random.choice(elements5) * random.uniform(0.99, 1.01)
e6 = random.choice(elements6) * random.uniform(0.99, 1.01)
e7 = random.choice(elements7) * random.uniform(0.99, 1.01)
e8 = random.choice(elements8) * random.uniform(0.99, 1.01)
e9 = random.choice(elements9) * random.uniform(0.99, 1.01)
e10 = random.choice(elements10) * random.uniform(0.99, 1.01)
e11 = random.choice(elements11) * random.uniform(0.99, 1.01)
e12 = random.choice(elements12) * random.uniform(0.99, 1.01)
e13 = random.choice(elements13) * random.uniform(0.99, 1.01)
new_gen.append((e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13))
solutions = new_gen
ans.sort()
astar_costs[0] = ans[0][1][0]
astar_costs[1] = ans[0][1][1]
astar_costs[2] = ans[0][1][2]
astar_costs[3] = ans[0][1][3]
astar_costs[4] = ans[0][1][4]
astar_costs[5] = ans[0][1][5]
astar_costs[6] = ans[0][1][6]
astar_costs[7] = ans[0][1][7]
astar_costs[8] = ans[0][1][8]
astar_costs[9] = ans[0][1][9]
astar_costs[10] = ans[0][1][10]
astar_costs[11] = ans[0][1][11]
astar_costs[12] = ans[0][1][12]
return astar_costs

View File

@ -1,4 +1,5 @@
import definitions
import graph
import random
class Plant:
def __init__(self, name, state):
@ -13,6 +14,55 @@ class Plant:
def set_state(self, state):
self.state = state
@staticmethod
def get_closest_mature_plant(istate, map): # TO DO, pobiera współrzędne najbliższej dojrzałej rośliny od miejsca, w którym znajduje się traktor
x = None #x'owa pola
y = None #y'kowa pola
min = None
for i in range(definitions.WIDTH_AMOUNT):
for j in range(definitions.HEIGHT_AMOUNT):
field = map.fields[i][j]
if field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() == definitions.BEETROOTS_MAXIMUM_STATE:
if min is None:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
else:
if len((graph.graphsearch([], [], (x, y), istate, graph.succ))) < min:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
elif field.get_plant().get_name() == "carrot" and field.get_plant().get_state() == definitions.CARROTS_MAXIMUM_STATE:
if min is None:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
else:
if len((graph.graphsearch([], [], (x, y), istate, graph.succ))) < min:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
elif field.get_plant().get_name() == "potato" and field.get_plant().get_state() == definitions.POTATOES_MAXIMUM_STATE:
if min is None:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
else:
if len((graph.graphsearch([], [], (x, y), istate, graph.succ))) < min:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
if min is None:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
else:
if len((graph.graphsearch([], [], (x, y), istate, graph.succ))) < min:
x = i
y = j
min = len((graph.graphsearch([], [], (x, y), istate, graph.succ)))
return x, y
@staticmethod
def grow_flower_dandelion(map): #metoda statyczna, losująca czy na danym polu ma urosnąć kwiat dandelion
for i in range(definitions.WIDTH_AMOUNT):
for j in range(definitions.HEIGHT_AMOUNT):
@ -35,3 +85,17 @@ 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.