generowanie populacji, gen jako koszt obiekt z kosztem przejazdu

This commit is contained in:
tomasz 2020-05-17 15:23:06 +02:00
parent 1e82036602
commit d25c4213de
14 changed files with 340 additions and 178 deletions

View File

@ -2,13 +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/randomBox.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/genetyczny/Gene.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/AStar.py" beforeDir="false" afterPath="$PROJECT_DIR$/AStar.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/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/metody.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/randomBox.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/funkcje.py" afterDir="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" />
@ -17,13 +16,16 @@
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FavoritesManager">
<favorites_list name="AI" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<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="17">
<caret line="94" column="98" selection-start-line="94" selection-start-column="98" selection-end-line="94" selection-end-column="98" />
<state relative-caret-position="725">
<caret line="98" selection-start-line="98" selection-end-line="98" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
@ -31,14 +33,20 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/randomBox.py">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/genetyczny/Gene.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
<state relative-caret-position="136">
<caret line="8" lean-forward="true" selection-start-line="8" selection-end-line="8" />
</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">
<state relative-caret-position="68">
<caret line="4" column="24" lean-forward="true" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" />
</state>
</provider>
</entry>
@ -46,8 +54,8 @@
<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="563">
<caret line="41" selection-start-line="41" selection-end-line="41" />
<state relative-caret-position="612">
<caret line="36" column="24" selection-start-line="36" selection-start-column="24" selection-end-line="36" selection-end-column="24" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
@ -58,8 +66,8 @@
<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="170">
<caret line="19" column="50" selection-start-line="19" selection-start-column="50" selection-end-line="19" selection-end-column="50" />
<state relative-caret-position="442">
<caret line="35" selection-start-line="35" selection-end-line="35" />
<folding>
<element signature="e#0#12#0" expanded="true" />
</folding>
@ -68,19 +76,13 @@
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Mapa/generate.py">
<entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="331">
<caret line="176" column="31" lean-forward="true" selection-start-line="176" selection-start-column="31" selection-end-line="176" selection-end-column="31" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" selection-start-line="4" selection-end-line="4" />
<state>
<caret line="21" column="23" selection-start-line="21" selection-start-column="15" selection-end-line="21" selection-end-column="23" />
<folding>
<element signature="e#0#48#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -88,8 +90,17 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Mapa/shelf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
<caret line="31" column="25" selection-start-line="31" selection-start-column="25" selection-end-line="31" selection-end-column="25" />
<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>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102">
<caret line="6" column="25" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="25" />
</state>
</provider>
</entry>
@ -105,7 +116,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>whereDecisio</find>
<find>toVisit</find>
<find>dra</find>
<find>neuro</find>
@ -120,15 +130,29 @@
<find>regalsik</find>
<find>#</find>
<find>put</find>
<find>random</find>
<find>randomB</find>
<find>search</find>
<find>sear</find>
<find>rando</find>
<find>chi</find>
<find>genera</find>
<find>return</find>
<find>occupied</find>
<find>astarstate</find>
<find>grid</find>
<find>whereDecision</find>
<find>genMa</find>
<find>random</find>
<find>mapfor</find>
<find>tmp</find>
<find>global</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
<entry key="$PROJECT_DIR$" value="podprogram" />
</map>
</option>
</component>
@ -143,21 +167,24 @@
<option value="$PROJECT_DIR$/wheel.py" />
<option value="$PROJECT_DIR$/Data.py" />
<option value="$PROJECT_DIR$/neurons.py" />
<option value="$PROJECT_DIR$/genetyczny/Data.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$/main.py" />
<option value="$PROJECT_DIR$/AStar.py" />
<option value="$PROJECT_DIR$/genetyczny/Data.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/genetyczny/funkcje.py" />
<option value="$PROJECT_DIR$/program.py" />
<option value="$PROJECT_DIR$/genetyczny/Gene1.py" />
<option value="$PROJECT_DIR$/genetyczny/Gene.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="65" />
<option name="y" value="-33" />
<option name="width" value="1620" />
<option name="height" value="1050" />
<option name="x" value="-9" />
<option name="y" value="-9" />
<option name="width" value="1938" />
<option name="height" value="1098" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
@ -320,13 +347,16 @@
<recent_temporary>
<list>
<item itemvalue="Python.main" />
<item itemvalue="Python.neurons" />
<item itemvalue="Python.julian" />
<item itemvalue="Python.generate" />
<item itemvalue="Python.neurons" />
<item itemvalue="Python.AStar" />
</list>
</recent_temporary>
</component>
<component name="StructureViewFactory">
<option name="ACTIVE_ACTIONS" value=",SHOW_INHERITED" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
@ -353,19 +383,19 @@
<frame x="-7" y="-7" width="1550" height="838" extended-state="7" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.27449664" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.4995206" visible="true" weight="0.20671141" />
<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 active="true" anchor="bottom" id="Find" order="1" visible="true" weight="0.32719547" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49932885" weight="0.22237961" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.3753541" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.3286119" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.3286119" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32719547" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49932885" visible="true" weight="0.22096318" />
<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" weight="0.27443105" />
<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.3286119" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50067115" side_tool="true" weight="0.3286119" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50067115" side_tool="true" weight="0.3753541" />
<window_info anchor="bottom" id="Python Console" order="10" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
@ -374,19 +404,19 @@
<window_info anchor="right" id="R Packages" order="4" />
</layout>
<layout-to-restore>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24871466" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.4995206" visible="true" weight="0.26643598" />
<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.3286119" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49932885" visible="true" weight="0.22243528" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.44759208" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.3286119" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.3286119" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32719547" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49932885" weight="0.22176023" />
<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.1968122" />
<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.3286119" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50067115" side_tool="true" weight="0.3286119" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50067115" side_tool="true" weight="0.3753541" />
<window_info anchor="bottom" id="Python Console" order="10" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
@ -399,9 +429,9 @@
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/AStar.py</url>
<line>17</line>
<option name="timeStamp" value="41" />
<url>file://$PROJECT_DIR$/program.py</url>
<line>98</line>
<option name="timeStamp" value="131" />
</line-breakpoint>
</breakpoints>
<default-breakpoints>
@ -417,6 +447,10 @@
<watch expression="all" />
<watch expression="startNode" />
<watch expression="self.map" />
<watch expression="niebezpieczne" />
<watch expression="children[0]" />
<watch expression="__py_debug_temp_var_445341660" />
<watch expression="visited" />
</configuration>
</watches-manager>
</component>
@ -469,33 +503,6 @@
<entry file="file://$PROJECT_DIR$/images/wo.png">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/neurons.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="369">
<caret line="35" column="9" selection-start-line="35" selection-start-column="9" selection-end-line="35" selection-end-column="9" />
<folding>
<element signature="e#0#12#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/whereDecision.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="556">
<caret line="62" selection-start-line="62" selection-end-line="62" />
<folding>
<element signature="e#0#19#0" expanded="true" />
</folding>
</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="174">
<caret line="356" selection-start-line="356" selection-end-line="356" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/images/krp.png">
<provider selected="true" editor-type-id="images" />
</entry>
@ -512,37 +519,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/shelf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
<caret line="31" column="25" selection-start-line="31" selection-start-column="25" selection-end-line="31" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/generate.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="331">
<caret line="176" column="31" lean-forward="true" selection-start-line="176" selection-start-column="31" selection-end-line="176" selection-end-column="31" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/AStarState.py">
<provider selected="true" editor-type-id="text-editor" />
</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="172">
<caret line="311" selection-start-line="311" selection-end-line="311" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/floor.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
@ -550,48 +526,128 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/box.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/randomBox.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="85">
<caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
<state relative-caret-position="138">
<caret line="309" selection-start-line="309" selection-end-line="309" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<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="563">
<caret line="41" selection-start-line="41" selection-end-line="41" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
<state relative-caret-position="138">
<caret line="260" selection-start-line="260" selection-end-line="260" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/AStar.py">
<entry file="file://$PROJECT_DIR$/neurons.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="19" column="50" selection-start-line="19" selection-start-column="50" selection-end-line="19" selection-end-column="50" />
<state relative-caret-position="595">
<caret line="35" column="9" selection-start-line="35" selection-start-column="9" selection-end-line="35" selection-end-column="9" />
<folding>
<element signature="e#0#12#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/site-packages/easygui/boxes/fileopen_box.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="459">
<caret line="27" selection-start-line="27" selection-end-line="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/whereDecision.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1054">
<caret line="62" selection-start-line="62" selection-end-line="62" />
<folding>
<element signature="e#0#19#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<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>
<entry file="file://$PROJECT_DIR$/AStar.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442">
<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/generate.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="952">
<caret line="174" selection-start-line="174" selection-end-line="174" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612">
<caret line="36" column="24" selection-start-line="36" selection-start-column="24" selection-end-line="36" selection-end-column="24" />
<folding>
<element signature="e#0#21#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" lean-forward="true" 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 relative-caret-position="102">
<caret line="6" column="25" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/program.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="94" column="98" selection-start-line="94" selection-start-column="98" selection-end-line="94" selection-end-column="98" />
<state relative-caret-position="725">
<caret line="98" selection-start-line="98" selection-end-line="98" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret line="21" column="23" selection-start-line="21" selection-start-column="15" selection-end-line="21" selection-end-column="23" />
<folding>
<element signature="e#0#48#0" expanded="true" />
</folding>
</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$/genetyczny/Gene.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" lean-forward="true" selection-start-line="8" selection-end-line="8" />
</state>
</provider>
</entry>
</component>
</project>

View File

@ -2,7 +2,7 @@ import numpy
from AStarState import AStarState
class AStar:
def returnPath(self, currentNode, grid, flaga):
def returnPath(self, currentNode, grid):
path = []
noRows, noColumns = numpy.shape(grid)
result = [[-1 for i in range(noColumns)] for j in range(noRows)]
@ -41,10 +41,14 @@ class AStar:
if item.g<current.g:
current = item
currentIndeks = indeks
if iterations>max and flaga == 0: #podprojekt genetyczne
return current.g
if iterations>max:
return self.returnPath(current, grid)
visited.append(current)
toVisit.pop(currentIndeks)
if current==endNode and flaga == 0:
return current.g
if current==endNode:
return self.returnPath(current, grid) #zwracanie wagi przejscia
children = []
@ -56,6 +60,11 @@ class AStar:
positions[1] > (noColumns - 1) or
positions[1] < 0):
continue
""" podprojekt genetyczne"""
if grid[positions[0]][positions[1]] == 2 and flaga == 0:
children.append(AStarState(current, positions))
continue
if grid[positions[0]][positions[1]]!=0:
continue
@ -76,3 +85,7 @@ class AStar:
continue
toVisit.append(child)

View File

@ -172,6 +172,7 @@ class Generate:
all[wysokosc-2][szerokosc-3] = 2
all[wysokosc-1][szerokosc-3] = 23
all[wysokosc-2][szerokosc-4] = 1
""" Drugi wyjazd
all[wysokosc-2][2] = 2
all[wysokosc-1][2] = 23

Binary file not shown.

Binary file not shown.

View File

@ -4,5 +4,15 @@
class Data:
def __init__(self):
self.zajeteRegaly = []
self.zajeteRegaly = [] #krotka (x,y)
self.mapa = []
self.unbox = []
self.astarMap = []
def genMap(self, mapa):
tmpMap =[]
tmpMap = mapa.copy()
for regal in self.zajeteRegaly:
tmpMap[regal[0]][regal[1]] = 2
return tmpMap

8
genetyczny/Gene.py Normal file
View File

@ -0,0 +1,8 @@
class Gene:
def __init__(self, poczatkowa, koncowa, name):
self.poczatkowa = poczatkowa
self.koncowa = koncowa
self.koszt = 0
self.name = name

Binary file not shown.

86
genetyczny/funkcje.py Normal file
View File

@ -0,0 +1,86 @@
from Mapa.unboxOnTheFloor import UnboxOnTheFloor
from genetyczny.Gene import Gene
from Mapa.box import Box
from AStar import AStar
import random
def znajdzUnbox(data,mapa):
unboxy = []
iterator = 0
ostatniWiersz = len(mapa) -1
for x in mapa[ostatniWiersz]:
if (isinstance(x, UnboxOnTheFloor)):
unboxy.append((ostatniWiersz, iterator))
iterator += 1
data.unbox = unboxy
def wybierzUnbox(data):
return random.choice(data.unbox)
def policzCost(mapaBoxy, poczatek, koniec):
astar = AStar()
koszt = astar.search(poczatek, koniec, mapaBoxy, 1, 0)
return koszt
def generateChromosome(data, mapaBoxy, wheelxy):
chromosome = []
regaly = data.zajeteRegaly
random.shuffle(regaly)
for r in regaly:
gen0 = Gene(wheelxy,r,"poczatek-regal")
gen0.koszt = policzCost(mapaBoxy, wheelxy, r)
chromosome.append(gen0)
unbox = wybierzUnbox(data)
gen1 = Gene(r,unbox,"regal-unbox")
gen1.koszt = policzCost(mapaBoxy, r, unbox)
chromosome.append(gen1)
return chromosome
def generatePopulation(data, mapaBoxy, wheelxy, ileWPopulacji):
populacja = []
for i in range(ileWPopulacji):
populacja.append(generateChromosome(data, mapaBoxy, wheelxy))
return populacja
def randomBox(mapa, regals, ile):
regals = regals
mapa = mapa
tupleList = []
ileRegalow = len(regals)
iteration = 0
while iteration < ileRegalow and iteration < ile:
regal = random.choice(regals)
if regal in tupleList:
continue
else:
tupleList.append(regal)
iteration+=1
for (i,j,x) in tupleList:
box = Box()
mapa[i][j].put(box)
"""
for t in tupleList:
listaRegalow.append((t[0],t[1]))
data.zajeteRegaly = listaRegalow
"""
return mapa
def znajdzBox(mapa, regals):
zajeteRegaly = []
for (x,y,z) in regals:
shelf = mapa[x][y]
tmp = shelf.occupied
if(tmp == True):
zajeteRegaly.append((x,y))
return zajeteRegaly

View File

@ -1,26 +0,0 @@
from Mapa.shelf import Shelf
from wheel import Wheel
from Mapa.box import Box
import random
def randomBox(data, mapa_, regals_, ile):
regals = regals_
mapa = mapa_
tupleList = []
ileRegalow = len(regals)
iteration = 0
while iteration < ileRegalow and iteration < ile:
regal = random.choice(regals)
if regal in tupleList:
continue
else:
tupleList.append(regal)
iteration+=1
for (i,j,x) in tupleList:
box = Box()
mapa[i][j].put(box)
data.zajeteRegaly = tupleList
return mapa

View File

@ -4,7 +4,7 @@ from Mapa.generate import Generate
from Mapa.floor import Floor
from Mapa.wall import Wall
from Mapa.shelf import Shelf
from genetyczny.randomBox import *
from genetyczny.funkcje import *
from wheel import Wheel
from Mapa.boxOnTheFloor import BoxOnTheFloor
from Mapa.box import Box
@ -25,6 +25,7 @@ class MainWindow:
pygame.display.set_caption('Inteligentny wózek widłowy')
self.clock = pygame.time.Clock()
self.ticks = 0
self.data = Data()
self.moves = []
self.regals = []
self.map = Generate.generate(szerokosc+2, wysokosc+2, kruche, latwopalne, radioaktywne, niebezpieczne)
@ -35,7 +36,7 @@ class MainWindow:
#create
self.wheel = Wheel(self.screen, self.cell)
###
self.data = Data()
#przekladanie wartosci liczbowych z tablicy na mapę obiektow
@ -49,7 +50,7 @@ class MainWindow:
self.mapForAStar[i][j] = 0
elif (self.map[i][j]==23):
self.map[i][j] = UnboxOnTheFloor(self.screen, self.cell, i, j)
self.mapForAStar[i][j] = 1
self.mapForAStar[i][j] = 0
else:
#regals (kordy i,j oraz rodzaj regału)
@ -57,7 +58,14 @@ 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.data, self.map, self.regals, 10)
self.map = randomBox(self.map, self.regals, 10)
self.data.mapa = self.map
znajdzUnbox(self.data,self.map)
self.data.zajeteRegaly = znajdzBox(self.map, self.regals)
tmp = self.mapForAStar[:]
self.data.astarMap = self.data.genMap(tmp)
#################################################
#loop
while True:
@ -82,7 +90,12 @@ class MainWindow:
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):
populacja = generatePopulation(self.data, self.data.astarMap, [self.wheel.ns, self.wheel.we], 100)
if len(self.moves)==0:
self.wheel.move(event, self.map)
elif(event.type==pygame.MOUSEBUTTONDOWN):
@ -92,7 +105,7 @@ class MainWindow:
self.map[0][2] = BoxOnTheFloor(self.screen, self.cell, 0, 2, Box())
star = AStar()
path = star.search([self.wheel.ns, self.wheel.we], [0, 2], self.mapForAStar, 1)
path = star.search([self.wheel.ns, self.wheel.we], [0, 2], self.mapForAStar, 1, 1)
cns = self.wheel.ns
cwe = self.wheel.we
value = path[cns][cwe]
@ -121,7 +134,7 @@ class MainWindow:
self.mapForAStar[where[0]][where[1]] = 0
# 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([0, 2], where, self.mapForAStar, 1)
path = star.search([0, 2], where, self.mapForAStar, 1, 1)
self.mapForAStar[where[0]][where[1]] = 1
value = path[cns][cwe]
while True:
@ -146,6 +159,7 @@ class MainWindow:
value=value+1
continue
break
self.data.zajeteRegaly = znajdzBox(self.map, self.regals)
def draw(self):
self.screen.fill((33,69,108))
for i in range(len(self.map)):