1
0
forked from s444399/AI

blad w algorytmie, nie generuje nowych obiektow tylko nadpisuje juz wygenerowane

This commit is contained in:
tomasz 2020-05-18 18:55:18 +02:00
parent ac04e30a96
commit 9c48010c38
12 changed files with 317 additions and 178 deletions

View File

@ -2,12 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="8264ee8d-5217-4cb6-b982-78f67fabc82e" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/genetyczny/genetyczny.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/genetyczny/eee.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mapa/generate.py" beforeDir="false" afterPath="$PROJECT_DIR$/Mapa/generate.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/Data.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/Data.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/Gene.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/Gene.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/funkcje.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/funkcje.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/genetyczny.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/program.py" beforeDir="false" afterPath="$PROJECT_DIR$/program.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -24,8 +24,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/program.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="829">
<caret line="103" column="72" selection-start-line="103" selection-start-column="72" selection-end-line="103" selection-end-column="72" />
<state relative-caret-position="815">
<caret line="94" selection-start-line="94" selection-end-line="94" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
@ -33,15 +33,6 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/AStarState.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" selection-start-line="9" selection-end-line="9" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/Gene.py">
<provider selected="true" editor-type-id="text-editor">
@ -51,6 +42,27 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/AStarState.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" selection-start-line="9" selection-end-line="9" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="731">
<caret line="43" selection-start-line="43" selection-end-line="43" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Mapa/box.py">
<provider selected="true" editor-type-id="text-editor">
@ -61,34 +73,19 @@
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py">
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="595">
<caret line="35" column="26" selection-start-line="35" selection-start-column="26" selection-end-line="35" selection-end-column="26" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/AStar.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="21" selection-start-line="21" selection-end-line="21" />
<folding>
<element signature="e#0#12#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="339">
<caret line="145" selection-start-line="145" selection-end-line="145" />
<state relative-caret-position="424">
<caret line="54" selection-start-line="54" selection-end-line="54" />
<folding>
<element signature="e#0#48#0" expanded="true" />
</folding>
@ -96,20 +93,14 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/genetyczny/genetyczny.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<entry file="file://$PROJECT_DIR$/genetyczny/eee.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="27" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
<state relative-caret-position="408">
<caret line="24" selection-start-line="24" selection-end-line="24" />
<folding>
<element signature="e#0#32#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -125,12 +116,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>regals</find>
<find>isOccupied</find>
<find>print</find>
<find>regal</find>
<find>whee</find>
<find>returnPath</find>
<find>10</find>
<find>regalsik</find>
<find>#</find>
@ -154,6 +139,12 @@
<find>cop</find>
<find>jakLiczycKoszt</find>
<find>jakLiczyc</find>
<find>eve</find>
<find>doW</find>
<find>self</find>
<find>moves</find>
<find>gen</find>
<find>wybierz</find>
<find>fitness</find>
</findStrings>
</component>
@ -178,19 +169,20 @@
<option value="$PROJECT_DIR$/neurons.py" />
<option value="$PROJECT_DIR$/genetyczny/metody.py" />
<option value="$PROJECT_DIR$/genetyczny/randomBox.py" />
<option value="$PROJECT_DIR$/Mapa/generate.py" />
<option value="$PROJECT_DIR$/AStar.py" />
<option value="$PROJECT_DIR$/genetyczny/Gene1.py" />
<option value="$PROJECT_DIR$/genetyczny/Gene.py" />
<option value="$PROJECT_DIR$/genetyczny/funkcje.py" />
<option value="$PROJECT_DIR$/genetyczny/Data.py" />
<option value="$PROJECT_DIR$/program.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/genetyczny/genetyczny.py" />
<option value="$PROJECT_DIR$/genetyczny/Data.py" />
<option value="$PROJECT_DIR$/Mapa/generate.py" />
<option value="$PROJECT_DIR$/program.py" />
<option value="$PROJECT_DIR$/genetyczny/funkcje.py" />
<option value="$PROJECT_DIR$/genetyczny/eee.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="1897" />
<option name="y" value="-9" />
<option name="width" value="1551" />
@ -249,6 +241,27 @@
</option>
</component>
<component name="RunManager" selected="Python.main">
<configuration name="eee" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/genetyczny" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/genetyczny/eee.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="funkcje" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -270,7 +283,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="julian" type="PythonConfigurationType" factoryName="Python" temporary="true">
<configuration name="genetyczny" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -278,11 +291,11 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/genetyczny" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/julian.py" />
<option name="SCRIPT_NAME" value="C:\Users\zwyklak\Desktop\AI\genetyczny\eee.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@ -312,27 +325,6 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="neurons" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/neurons.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="program" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -357,10 +349,10 @@
<recent_temporary>
<list>
<item itemvalue="Python.main" />
<item itemvalue="Python.eee" />
<item itemvalue="Python.genetyczny" />
<item itemvalue="Python.program" />
<item itemvalue="Python.funkcje" />
<item itemvalue="Python.neurons" />
<item itemvalue="Python.julian" />
</list>
</recent_temporary>
</component>
@ -391,17 +383,16 @@
</component>
<component name="ToolWindowManager">
<frame x="1912" y="-8" width="1216" height="1576" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.4995206" visible="true" weight="0.2733564" />
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.4995206" visible="true" weight="0.2733564" />
<window_info id="Structure" order="1" sideWeight="0.5004794" side_tool="true" weight="0.3382353" />
<window_info id="Favorites" order="2" sideWeight="0.5011338" side_tool="true" weight="0.27768165" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.3270963" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32640332" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49932885" weight="0.22037423" />
<window_info anchor="bottom" id="Cvs" order="3" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="4" weight="0.4" />
<window_info anchor="bottom" x="1942" y="641" width="1156" height="277" id="Debug" order="5" sideWeight="0.49932885" visible="true" weight="0.13305613" />
<window_info active="true" anchor="bottom" x="1942" y="641" width="1156" height="277" id="Debug" order="5" sideWeight="0.49932885" visible="true" weight="0.13305613" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.32848233" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32848233" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.32848233" />
@ -438,10 +429,20 @@
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/genetyczny/eee.py</url>
<line>24</line>
<option name="timeStamp" value="190" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/genetyczny/funkcje.py</url>
<line>145</line>
<option name="timeStamp" value="171" />
<line>197</line>
<option name="timeStamp" value="192" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/genetyczny/funkcje.py</url>
<line>40</line>
<option name="timeStamp" value="195" />
</line-breakpoint>
</breakpoints>
<default-breakpoints>
@ -485,13 +486,6 @@
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/julian.py" />
<entry file="file://$PROJECT_DIR$/Mapa/wall.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="11" column="26" selection-start-line="11" selection-start-column="26" selection-end-line="11" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dodatkoweMetody.py" />
<entry file="file://$PROJECT_DIR$/Mapa/unboxOnTheFloor.py">
<provider selected="true" editor-type-id="text-editor">
@ -500,9 +494,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Evencik.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/__init__.py" />
<entry file="file://$PROJECT_DIR$/Mapa/boxOnTheFloor.py">
<provider selected="true" editor-type-id="text-editor" />
@ -536,13 +527,6 @@
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/codecs.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="138">
<caret line="309" selection-start-line="309" selection-end-line="309" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/neurons.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="595">
@ -570,20 +554,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/shelf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="11" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/box.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="24" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/random.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="366">
@ -591,34 +561,27 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="27" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Gene.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102">
<caret line="6" column="16" selection-start-line="6" selection-start-column="16" selection-end-line="6" selection-end-column="16" />
</state>
</provider>
<entry file="file://$PROJECT_DIR$/Evencik.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/generate.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="801">
<caret line="163" column="21" selection-start-line="163" selection-start-column="21" selection-end-line="163" selection-end-column="21" />
<state relative-caret-position="1383">
<caret line="179" lean-forward="true" selection-start-line="179" selection-end-line="179" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<entry file="file://$PROJECT_DIR$/Mapa/shelf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="595">
<caret line="35" column="26" selection-start-line="35" selection-start-column="26" selection-end-line="35" selection-end-column="26" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
<state relative-caret-position="1124">
<caret line="72" selection-start-line="72" selection-end-line="72" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/wall.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="11" selection-start-line="11" selection-end-line="11" />
</state>
</provider>
</entry>
@ -629,40 +592,81 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/AStar.py">
<entry file="file://$PROJECT_DIR$/genetyczny/Gene.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="21" selection-start-line="21" selection-end-line="21" />
<folding>
<element signature="e#0#12#0" expanded="true" />
</folding>
<state relative-caret-position="102">
<caret line="6" column="16" selection-start-line="6" selection-start-column="16" selection-end-line="6" selection-end-column="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/codecs.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="339">
<caret line="145" selection-start-line="145" selection-end-line="145" />
<state relative-caret-position="172">
<caret line="311" selection-start-line="311" selection-end-line="311" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="731">
<caret line="43" selection-start-line="43" selection-end-line="43" />
<folding>
<element signature="e#0#48#0" expanded="true" />
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/program.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="829">
<caret line="103" column="72" selection-start-line="103" selection-start-column="72" selection-end-line="103" selection-end-column="72" />
<state relative-caret-position="815">
<caret line="94" selection-start-line="94" selection-end-line="94" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/genetyczny.py">
<entry file="file://$PROJECT_DIR$/AStar.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
<state relative-caret-position="595">
<caret line="35" selection-start-line="35" selection-end-line="35" />
<folding>
<element signature="e#0#12#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/box.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="24" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/eee.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="408">
<caret line="24" selection-start-line="24" selection-end-line="24" />
<folding>
<element signature="e#0#32#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424">
<caret line="54" selection-start-line="54" selection-end-line="54" />
<folding>
<element signature="e#0#48#0" expanded="true" />
</folding>
</state>
</provider>
</entry>

View File

@ -173,10 +173,10 @@ class Generate:
all[wysokosc-1][szerokosc-3] = 23
all[wysokosc-2][szerokosc-4] = 1
""" Drugi wyjazd
all[wysokosc-2][2] = 2
all[wysokosc-1][2] = 23
all[wysokosc-2][3] = 1
"""
return all

Binary file not shown.

View File

@ -13,6 +13,7 @@ class Data:
self.jakLiczycKoszt = None
self.best = None
self.histZmian = []
self.doWykresu = []
def genMap(self, mapa):
tmpMap =[]

Binary file not shown.

142
genetyczny/eee.py Normal file
View File

@ -0,0 +1,142 @@
from genetyczny.funkcje import *
from easygui import *
from genetyczny.Data import Data
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
def start(data, wheel):
ileGeneracji = 200
ileWPopulacji = 16
fragment = 0.2
mutacja = 0.05
unbox = 3
data.kordyWozka = (wheel.ns, wheel.we)
data.jakLiczycKoszt = unbox
randomPopulation = genRandomPopulation(data, ileWPopulacji)
for i in range(ileGeneracji):
if i == 0:
best2 = dwieNajlepsze(randomPopulation, data)
else:
x = genPopulacje(best2[0], best2[1], ileWPopulacji, fragment, mutacja)
best2 = dwieNajlepsze(x, data)
data.histZmian.append(data.best[1])
break
#rysujWykres(data, ileGeneracji, 1000, 2000)
def ruszWozek(gen,data, moves, wheel):
regalKordy = gen.kordy
unbox = data.unbox[gen.ktoryUnbox]
star = AStar()
mapForAStar = data.astarMap[:]
mapForAStar[regalKordy[0]][regalKordy[1]] = 0
path = star.search([wheel.ns, wheel.we], regalKordy, mapForAStar, 1, 1)
cns = wheel.ns
cwe = wheel.we
value = path[cns][cwe]
while True:
if cns > 0 and path[cns - 1][cwe] == (value + 1):
cns = cns - 1
moves.append(1)
value = value + 1
continue
if cns < (len(mapForAStar) - 1) and path[cns + 1][cwe] == (value + 1):
cns = cns + 1
moves.append(2)
value = value + 1
continue
if cwe > 0 and path[cns][cwe - 1] == (value + 1):
cwe = cwe - 1
moves.append(3)
value = value + 1
continue
if cwe < (len(mapForAStar[0]) - 1) and path[cns][cwe + 1] == (value + 1):
cns = cns + 1
moves.append(4)
value = value + 1
continue
break
mapForAStar[regalKordy[0]][regalKordy[1]] = 1
# wyszukiwanie ścieżki z miejsca podjęcia paczki do regału
# zmienna path posiada macierz oraz kroki podjęte przez wózek
path = star.search([regalKordy[0], regalKordy[1]], unbox, mapForAStar, 1, 1)
#mapForAStar[where[0]][where[1]] = 1
value = path[cns][cwe]
while True:
if cns > 0 and path[cns - 1][cwe] == (value + 1):
cns = cns - 1
moves.append(1)
value = value + 1
continue
if cns < (len(mapForAStar) - 1) and path[cns + 1][cwe] == (value + 1):
cns = cns + 1
moves.append(2)
value = value + 1
continue
if cwe > 0 and path[cns][cwe - 1] == (value + 1):
cwe = cwe - 1
moves.append(3)
value = value + 1
continue
if cwe < (len(mapForAStar[0]) - 1) and path[cns][cwe + 1] == (value + 1):
cwe = cwe + 1
moves.append(4)
value = value + 1
continue
break
def rysujWykres(data, x, yStart, yEnd):
plt.axis([0, x,yStart, yEnd])
for i in range(0, len(data.doWykresu) - 1):
y = data.doWykresu[i]
x = i
plt.scatter(x, y)
plt.pause(0.0001)
plt.show()
def okno():
good = True
fieldValues = multenterbox("Wprowadź warunki początkowe", "Start algorytmu genetycznego", ["Ile chrom. w generacji", "Wielkosc dziedziczonego fragmentu (x>0 and x<1)", "Wartosc mutacji (x>0 and x<1)", "Unbox: (0or 1 or 2 or 2)", "Ile generacji"])
if(fieldValues[0].isnumeric() and (fieldValues[0]!="")):
good = False
elif(good==True):
msgbox("Wartość nie jest liczbą", "Błąd")
good = False
if(fieldValues[1].isnumeric() and (fieldValues[1]!="")):
if((int(fieldValues[1])<=0) and (good==True) and (int(fieldValues[1])>= 1)):
msgbox("Zla wartosc fragmentu")
good = False
elif (good == True):
msgbox("Wartość nie jest liczbą", "Błąd")
good = False
if(fieldValues[2].isnumeric() and (fieldValues[2]!="")):
if((int(fieldValues[1])<=0) and (good==True) and (int(fieldValues[1])>= 1)):
msgbox("Zla wartosc mutacji")
good = False
elif (good == True):
msgbox("Wartość nie jest liczbą", "Błąd")
good = False
if(fieldValues[3].isnumeric() and (fieldValues[3]!="")):
if(((int(fieldValues[3]) != 0) or (int(fieldValues[3]) != 1) or (int(fieldValues[3]) != 2) or (int(fieldValues[3]) != 3)) and (good==True)):
msgbox("Zla wartosc unboxa")
good = False
elif (good == True):
msgbox("Wartość nie jest liczbą", "Błąd")
good = False
if(fieldValues[4].isnumeric() and (fieldValues[4]!="")):
pass
else:
msgbox("Wartość nie jest liczbą", "Błąd")
good = False
if(good == True):
return [fieldValues[0], fieldValues[1], fieldValues[2],fieldValues[3]]

View File

@ -150,6 +150,7 @@ def dwieNajlepsze(populacja, data):
data.best = (pierwsza[:],bestValue)
elif(data.best[1] > bestValue):
data.best = (pierwsza[:],bestValue)
data.doWykresu.append(bestValue)
tmpPopulacja.pop(bestChromIndex)
chromFitness.pop(bestChromIndex)

View File

@ -1 +0,0 @@

View File

@ -15,6 +15,7 @@ from neurons import Neurons
from whereDecision import WhereDecision
from Evencik import Evencik
from genetyczny.Data import Data
from genetyczny.eee import *
class MainWindow:
def __init__(self, szerokosc, wysokosc, kruche, latwopalne, radioaktywne, niebezpieczne):
@ -58,7 +59,7 @@ class MainWindow:
self.map[i][j] = Shelf(self.screen, self.cell, i, j, (self.map[i][j]-3)%4, (self.map[i][j]-3)//4)
self.mapForAStar[i][j] = 1
self.map = randomBox(self.map, self.regals, 25)
self.map = randomBox(self.map, self.regals, 5)
updateMap(self.data, self.map, self.mapForAStar, self.regals)
generateGeny(self.data)
@ -81,31 +82,22 @@ class MainWindow:
self.wheel.move(Evencik(pygame.K_LEFT), self.map)
elif (self.moves[0]==4):
self.wheel.move(Evencik(pygame.K_RIGHT), self.map)
self.moves.pop(0)
def events(self):
for event in pygame.event.get():
if(event.type==pygame.QUIT):
sys.exit()
"""
elif(event.type == pygame.K_p):
print("eee")
"""
elif(event.type==pygame.KEYDOWN):
self.data.kordyWozka = (self.wheel.ns, self.wheel.we)
self.data.jakLiczycKoszt = 1
randomPopulation = genRandomPopulation(self.data, 5)
for i in range(100):
if i == 0:
best2 = dwieNajlepsze(randomPopulation, self.data)
else:
x = genPopulacje(best2[0], best2[1], 5, 0.2, 0.3)
best2 = dwieNajlepsze(x, self.data)
self.data.histZmian.append(self.data.best[1])
if len(self.moves)==0:
if event.key == pygame.K_g:
start(self.data,self.wheel)
for gen in self.data.best[0]:
ruszWozek(gen,self.data, self.moves, self.wheel)
elif len(self.moves)==0:
self.wheel.move(event, self.map)
elif(event.type==pygame.MOUSEBUTTONDOWN):
if (type(self.map[0][2]) == Floor):
whatIsIt = self.neurons.whatIsIt(easygui.fileopenbox("Wybierz zdjęcie paczki", "Wybierz zdjęcie paczki", filetypes = [["*.jpg", "*.jpeg", "*.png", "Pliki graficzne"]]))