Zmienione self; nadal nie dziala
This commit is contained in:
parent
9cd93b8047
commit
8da63cae25
@ -17,20 +17,17 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/order.py">
|
<entry file="file://$PROJECT_DIR$/order.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="-7">
|
||||||
<caret line="6" selection-start-line="6" selection-end-line="6" />
|
<caret line="6" selection-start-line="6" selection-end-line="6" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="true">
|
||||||
<entry file="file://$PROJECT_DIR$/game.py">
|
<entry file="file://$PROJECT_DIR$/game.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="1475">
|
<state relative-caret-position="286">
|
||||||
<caret line="59" column="26" selection-start-line="59" selection-start-column="19" selection-end-line="59" selection-end-column="26" />
|
<caret line="56" column="52" lean-forward="true" selection-start-line="56" selection-start-column="52" selection-end-line="56" selection-end-column="52" />
|
||||||
<folding>
|
|
||||||
<element signature="e#0#18#0" expanded="true" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -38,7 +35,7 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="308">
|
||||||
<caret line="14" column="59" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
|
<caret line="14" column="59" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -47,7 +44,7 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/table.py">
|
<entry file="file://$PROJECT_DIR$/table.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="308">
|
||||||
<caret line="14" column="15" selection-start-line="14" selection-start-column="15" selection-end-line="14" selection-end-column="15" />
|
<caret line="14" column="15" selection-start-line="14" selection-start-column="15" selection-end-line="14" selection-end-column="15" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -56,7 +53,7 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/pool.py">
|
<entry file="file://$PROJECT_DIR$/pool.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="198">
|
||||||
<caret line="9" column="26" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
<caret line="9" column="26" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#13#0" expanded="true" />
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
@ -68,19 +65,26 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/orderTable.py">
|
<entry file="file://$PROJECT_DIR$/orderTable.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="-7">
|
||||||
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
|
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file pinned="false" current-in-tab="true">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="402">
|
<state relative-caret-position="-1225">
|
||||||
<caret line="249" column="18" lean-forward="true" selection-start-line="249" selection-start-column="18" selection-end-line="249" selection-end-column="18" />
|
<caret line="175" column="27" selection-start-line="175" selection-start-column="27" selection-end-line="175" selection-end-column="27" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#13#0" expanded="true" />
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
|
<element signature="e#546#709#0" />
|
||||||
|
<element signature="e#758#1456#0" />
|
||||||
|
<element signature="e#1495#2175#0" />
|
||||||
|
<element signature="e#2213#2975#0" />
|
||||||
|
<element signature="e#3409#3781#0" />
|
||||||
|
<element signature="e#3825#4033#0" />
|
||||||
|
<element signature="e#4080#4470#0" />
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -95,6 +99,11 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="FindInProjectRecents">
|
||||||
|
<findStrings>
|
||||||
|
<find>self.last</find>
|
||||||
|
</findStrings>
|
||||||
|
</component>
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="PREVIOUS_COMMIT_AUTHORS">
|
<option name="PREVIOUS_COMMIT_AUTHORS">
|
||||||
<list>
|
<list>
|
||||||
@ -103,6 +112,9 @@
|
|||||||
</option>
|
</option>
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="HierarchyBrowserManager">
|
||||||
|
<option name="SORT_ALPHABETICALLY" value="true" />
|
||||||
|
</component>
|
||||||
<component name="IdeDocumentHistory">
|
<component name="IdeDocumentHistory">
|
||||||
<option name="CHANGED_PATHS">
|
<option name="CHANGED_PATHS">
|
||||||
<list>
|
<list>
|
||||||
@ -114,8 +126,8 @@
|
|||||||
<option value="$PROJECT_DIR$/table.py" />
|
<option value="$PROJECT_DIR$/table.py" />
|
||||||
<option value="$PROJECT_DIR$/orderTable.py" />
|
<option value="$PROJECT_DIR$/orderTable.py" />
|
||||||
<option value="$PROJECT_DIR$/pool.py" />
|
<option value="$PROJECT_DIR$/pool.py" />
|
||||||
<option value="$PROJECT_DIR$/game.py" />
|
|
||||||
<option value="$PROJECT_DIR$/waiter.py" />
|
<option value="$PROJECT_DIR$/waiter.py" />
|
||||||
|
<option value="$PROJECT_DIR$/game.py" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@ -257,11 +269,11 @@
|
|||||||
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
|
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
|
||||||
<editor active="true" />
|
<editor active="true" />
|
||||||
<layout>
|
<layout>
|
||||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18124342" />
|
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18336888" />
|
||||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||||
<window_info id="Favorites" order="2" side_tool="true" />
|
<window_info id="Favorites" order="2" side_tool="true" />
|
||||||
<window_info anchor="bottom" id="Message" order="0" />
|
<window_info anchor="bottom" id="Message" order="0" />
|
||||||
<window_info anchor="bottom" id="Find" order="1" />
|
<window_info anchor="bottom" id="Find" order="1" weight="0.32936078" />
|
||||||
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49894625" visible="true" weight="0.29577464" />
|
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49894625" visible="true" weight="0.29577464" />
|
||||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.3997833" />
|
<window_info anchor="bottom" id="Debug" order="3" weight="0.3997833" />
|
||||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||||
@ -270,7 +282,7 @@
|
|||||||
<window_info anchor="bottom" id="Version Control" order="7" sideWeight="0.49947312" weight="0.32936078" />
|
<window_info anchor="bottom" id="Version Control" order="7" sideWeight="0.49947312" weight="0.32936078" />
|
||||||
<window_info anchor="bottom" id="Terminal" order="8" weight="0.32936078" />
|
<window_info anchor="bottom" id="Terminal" order="8" weight="0.32936078" />
|
||||||
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50105375" side_tool="true" weight="0.32936078" />
|
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50105375" side_tool="true" weight="0.32936078" />
|
||||||
<window_info anchor="bottom" id="Python Console" order="10" />
|
<window_info anchor="bottom" id="Python Console" order="10" weight="0.32936078" />
|
||||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
<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" />
|
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||||
@ -318,6 +330,34 @@
|
|||||||
<MESSAGE value="Lada i skromne kolizje" />
|
<MESSAGE value="Lada i skromne kolizje" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Lada i skromne kolizje" />
|
<option name="LAST_COMMIT_MESSAGE" value="Lada i skromne kolizje" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager>
|
||||||
|
<breakpoints>
|
||||||
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
|
<url>file://$PROJECT_DIR$/waiter.py</url>
|
||||||
|
<line>284</line>
|
||||||
|
<option name="timeStamp" value="36" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
|
<url>file://$PROJECT_DIR$/game.py</url>
|
||||||
|
<line>54</line>
|
||||||
|
<option name="timeStamp" value="37" />
|
||||||
|
</line-breakpoint>
|
||||||
|
</breakpoints>
|
||||||
|
<default-breakpoints>
|
||||||
|
<breakpoint type="python-exception">
|
||||||
|
<properties notifyOnTerminate="true" exception="BaseException">
|
||||||
|
<option name="notifyOnTerminate" value="true" />
|
||||||
|
</properties>
|
||||||
|
</breakpoint>
|
||||||
|
</default-breakpoints>
|
||||||
|
</breakpoint-manager>
|
||||||
|
<watches-manager>
|
||||||
|
<configuration name="PythonConfigurationType">
|
||||||
|
<watch expression="grid" />
|
||||||
|
</configuration>
|
||||||
|
</watches-manager>
|
||||||
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/sprites/olaf.py">
|
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/sprites/olaf.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
@ -329,13 +369,6 @@
|
|||||||
<entry file="file://$PROJECT_DIR$/Images/waiter.jpg">
|
<entry file="file://$PROJECT_DIR$/Images/waiter.jpg">
|
||||||
<provider selected="true" editor-type-id="images" />
|
<provider selected="true" editor-type-id="images" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="168">
|
|
||||||
<caret line="1134" selection-start-line="1134" selection-end-line="1134" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/_pydev_imps/_pydev_execfile.py">
|
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/_pydev_imps/_pydev_execfile.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="289">
|
<state relative-caret-position="289">
|
||||||
@ -386,28 +419,21 @@
|
|||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/order.py">
|
<entry file="file://$PROJECT_DIR$/order.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="-7">
|
||||||
<caret line="6" selection-start-line="6" selection-end-line="6" />
|
<caret line="6" selection-start-line="6" selection-end-line="6" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state>
|
|
||||||
<caret line="14" column="59" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/table.py">
|
<entry file="file://$PROJECT_DIR$/table.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="308">
|
||||||
<caret line="14" column="15" selection-start-line="14" selection-start-column="15" selection-end-line="14" selection-end-column="15" />
|
<caret line="14" column="15" selection-start-line="14" selection-start-column="15" selection-end-line="14" selection-end-column="15" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/pool.py">
|
<entry file="file://$PROJECT_DIR$/pool.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="198">
|
||||||
<caret line="9" column="26" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
<caret line="9" column="26" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#13#0" expanded="true" />
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
@ -417,30 +443,55 @@
|
|||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/orderTable.py">
|
<entry file="file://$PROJECT_DIR$/orderTable.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="-7">
|
||||||
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
|
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/game.py">
|
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="1475">
|
<state relative-caret-position="308">
|
||||||
<caret line="59" column="26" selection-start-line="59" selection-start-column="19" selection-end-line="59" selection-end-column="26" />
|
<caret line="14" column="59" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
|
||||||
<folding>
|
</state>
|
||||||
<element signature="e#0#18#0" expanded="true" />
|
</provider>
|
||||||
</folding>
|
</entry>
|
||||||
|
<entry file="file://$USER_HOME$/.PyCharmCE2018.3/system/python_stubs/-258859485/builtins.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="299">
|
||||||
|
<caret line="3704" column="8" selection-start-line="3704" selection-start-column="8" selection-end-line="3704" selection-end-column="8" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="448">
|
||||||
|
<caret line="1740" selection-start-line="1740" selection-end-line="1740" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="402">
|
<state relative-caret-position="-1225">
|
||||||
<caret line="249" column="18" lean-forward="true" selection-start-line="249" selection-start-column="18" selection-end-line="249" selection-end-column="18" />
|
<caret line="175" column="27" selection-start-line="175" selection-start-column="27" selection-end-line="175" selection-end-column="27" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#13#0" expanded="true" />
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
|
<element signature="e#546#709#0" />
|
||||||
|
<element signature="e#758#1456#0" />
|
||||||
|
<element signature="e#1495#2175#0" />
|
||||||
|
<element signature="e#2213#2975#0" />
|
||||||
|
<element signature="e#3409#3781#0" />
|
||||||
|
<element signature="e#3825#4033#0" />
|
||||||
|
<element signature="e#4080#4470#0" />
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/game.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="286">
|
||||||
|
<caret line="56" column="52" lean-forward="true" selection-start-line="56" selection-start-column="52" selection-end-line="56" selection-end-column="52" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
BIN
__pycache__/DFS.cpython-37.pyc
Normal file
BIN
__pycache__/DFS.cpython-37.pyc
Normal file
Binary file not shown.
BIN
__pycache__/gridAndWaiter.cpython-37.pyc
Normal file
BIN
__pycache__/gridAndWaiter.cpython-37.pyc
Normal file
Binary file not shown.
Binary file not shown.
12
game.py
12
game.py
@ -5,6 +5,7 @@ from gridElement import GridElement
|
|||||||
from pygame.math import Vector2
|
from pygame.math import Vector2
|
||||||
from orderTable import OrderTable
|
from orderTable import OrderTable
|
||||||
from pool import Pool
|
from pool import Pool
|
||||||
|
import copy
|
||||||
|
|
||||||
class Game(object):
|
class Game(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -47,7 +48,14 @@ class Game(object):
|
|||||||
if i == self.x-1:
|
if i == self.x-1:
|
||||||
self.grid.append(list(self.row))
|
self.grid.append(list(self.row))
|
||||||
self.row.clear()
|
self.row.clear()
|
||||||
self.waiter.dfsFind(self, self.waiter.lastStep, 1)
|
#copyGrid = copy.copy(self.grid)
|
||||||
|
#copyGrid = []
|
||||||
|
#kopia = copy.deepcopy(self.grid[9][4])
|
||||||
|
kopia = [[num for num in line] for line in self.grid]
|
||||||
|
self.waiter.dfsFind(kopia, [], 2)
|
||||||
|
#print("Prawdziwa pozycja kelnera: {0}, {1} ", self.waiter.positionX, self.waiter.positionY)
|
||||||
|
#print(self.waiter.findWaiter(self.grid[:]))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
@ -56,7 +64,7 @@ class Game(object):
|
|||||||
|
|
||||||
self.draw()
|
self.draw()
|
||||||
self.waiter.move(self)
|
self.waiter.move(self)
|
||||||
print(self.waiter.checkPoss(self, self.waiter.lastStep))
|
#print(self.waiter.checkPoss(self.grid, self.waiter.lastStep))
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
#print(self.waiterNumberInGrid)
|
#print(self.waiterNumberInGrid)
|
||||||
self.fpsClock.tick(10)
|
self.fpsClock.tick(10)
|
||||||
|
370
waiter.py
370
waiter.py
@ -16,66 +16,87 @@ class Waiter(object):
|
|||||||
self.image.set_colorkey((255, 255, 255))
|
self.image.set_colorkey((255, 255, 255))
|
||||||
self.type = "waiter"
|
self.type = "waiter"
|
||||||
self.lastStep = []
|
self.lastStep = []
|
||||||
|
self.allPath = []
|
||||||
|
|
||||||
|
|
||||||
def moveLeft(self, game):
|
def findWaiter(self, grid):
|
||||||
if self.positionX != 0:
|
for y in range(10):
|
||||||
collisionObject = game.grid[self.positionY][self.positionX - 1]
|
for x in range(10):
|
||||||
|
if grid[y][x].type =="waiter":
|
||||||
|
#print(x,y)
|
||||||
|
return [x, y]
|
||||||
|
|
||||||
|
|
||||||
|
def moveLeft(self, grid):
|
||||||
|
|
||||||
|
position = self.findWaiter(grid)
|
||||||
|
positionX = position[0]
|
||||||
|
positionY = position[1]
|
||||||
|
if positionX != 0:
|
||||||
|
collisionObject = grid[positionY][positionX - 1]
|
||||||
if collisionObject.type == "gridElement":
|
if collisionObject.type == "gridElement":
|
||||||
game.grid[self.positionY][self.positionX - 1].x += 50
|
grid[positionY][positionX - 1].x += 50
|
||||||
game.grid[self.positionY][self.positionX].x -= 50
|
grid[positionY][positionX].x -= 50
|
||||||
game.grid[self.positionY][self.positionX - 1], \
|
grid[positionY][positionX - 1], \
|
||||||
game.grid[self.positionY][self.positionX] = \
|
grid[positionY][positionX] = \
|
||||||
game.grid[self.positionY][self.positionX], \
|
grid[positionY][positionX], \
|
||||||
game.grid[self.positionY][self.positionX - 1]
|
grid[positionY][positionX - 1]
|
||||||
self.positionX -= 1
|
|
||||||
#print(self.positionX)
|
#print(self.positionX)
|
||||||
self.lastStep.append("Left")
|
return grid
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
def moveRight(self, game):
|
def moveRight(self, grid):
|
||||||
if self.positionX != game.x-1:
|
|
||||||
collisionObject = game.grid[self.positionY][self.positionX + 1]
|
position = self.findWaiter(grid)
|
||||||
|
positionX = position[0]
|
||||||
|
positionY = position[1]
|
||||||
|
if positionX != 9:
|
||||||
|
collisionObject = grid[positionY][positionX + 1]
|
||||||
if collisionObject.type == "gridElement":
|
if collisionObject.type == "gridElement":
|
||||||
game.grid[self.positionY][self.positionX + 1].x -= 50
|
grid[positionY][positionX + 1].x -= 50
|
||||||
game.grid[self.positionY][self.positionX].x += 50
|
grid[positionY][positionX].x += 50
|
||||||
game.grid[self.positionY][self.positionX + 1], \
|
grid[positionY][positionX + 1], \
|
||||||
game.grid[self.positionY][self.positionX] = \
|
grid[positionY][positionX] = \
|
||||||
game.grid[self.positionY][self.positionX], \
|
grid[positionY][positionX], \
|
||||||
game.grid[self.positionY][self.positionX + 1]
|
grid[positionY][positionX + 1]
|
||||||
self.positionX += 1
|
|
||||||
#print(self.positionX)
|
# print(self.positionX)
|
||||||
self.lastStep.append("Right")
|
return grid
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def moveUp(self, game):
|
def moveUp(self, grid):
|
||||||
if self.positionY != 0:
|
position = self.findWaiter(grid)
|
||||||
collisionObject = game.grid[self.positionY - 1][self.positionX]
|
positionX = position[0]
|
||||||
|
positionY = position[1]
|
||||||
|
if positionY != 0:
|
||||||
|
collisionObject = grid[positionY - 1][positionX]
|
||||||
if collisionObject.type == "gridElement":
|
if collisionObject.type == "gridElement":
|
||||||
game.grid[self.positionY - 1][self.positionX].y += 50
|
grid[positionY - 1][positionX].y += 50
|
||||||
game.grid[self.positionY][self.positionX].y -= 50
|
grid[positionY][positionX].y -= 50
|
||||||
game.grid[self.positionY - 1][self.positionX], \
|
grid[positionY - 1][positionX], \
|
||||||
game.grid[self.positionY][self.positionX] = \
|
grid[positionY][positionX] = \
|
||||||
game.grid[self.positionY][self.positionX], \
|
grid[positionY][positionX], \
|
||||||
game.grid[self.positionY - 1][self.positionX]
|
grid[positionY - 1][positionX]
|
||||||
self.positionY -= 1
|
return grid
|
||||||
self.lastStep.append("Up")
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def moveDown(self, game):
|
def moveDown(self, grid):
|
||||||
if self.positionY != game.y-1:
|
position = self.findWaiter(grid)
|
||||||
collisionObject = game.grid[self.positionY + 1][self.positionX]
|
positionX = position[0]
|
||||||
|
positionY = position[1]
|
||||||
|
if positionY != 9:
|
||||||
|
collisionObject = grid[positionY + 1][positionX]
|
||||||
if collisionObject.type == "gridElement":
|
if collisionObject.type == "gridElement":
|
||||||
game.grid[self.positionY + 1][self.positionX].y -= 50
|
grid[positionY + 1][positionX].y -= 50
|
||||||
game.grid[self.positionY][self.positionX].y += 50
|
grid[positionY][positionX].y += 50
|
||||||
game.grid[self.positionY + 1][self.positionX], \
|
grid[positionY + 1][positionX], \
|
||||||
game.grid[self.positionY][self.positionX] = \
|
grid[positionY][positionX] = \
|
||||||
game.grid[self.positionY][self.positionX], \
|
grid[positionY][positionX], \
|
||||||
game.grid[self.positionY + 1][self.positionX]
|
grid[positionY + 1][positionX]
|
||||||
self.positionY += 1
|
return grid
|
||||||
self.lastStep.append("Down")
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -85,16 +106,17 @@ class Waiter(object):
|
|||||||
keys = pygame.key.get_pressed()
|
keys = pygame.key.get_pressed()
|
||||||
|
|
||||||
if keys[pygame.K_LEFT]:
|
if keys[pygame.K_LEFT]:
|
||||||
self.moveLeft(game)
|
self.moveLeft(game.grid)
|
||||||
if keys[pygame.K_RIGHT]:
|
if keys[pygame.K_RIGHT]:
|
||||||
self.moveRight(game)
|
self.moveRight(game.grid)
|
||||||
if keys[pygame.K_UP]:
|
if keys[pygame.K_UP]:
|
||||||
self.moveUp(game)
|
self.moveUp(game.grid)
|
||||||
if keys[pygame.K_DOWN]:
|
if keys[pygame.K_DOWN]:
|
||||||
self.moveDown(game)
|
self.moveDown(game.grid)
|
||||||
if keys[pygame.K_s]:
|
if keys[pygame.K_s]:
|
||||||
game.showGrid(game.grid)
|
game.showGrid(game.grid)
|
||||||
|
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.rect1 = pygame.Rect(self.x, self.y, 50, 50)
|
self.rect1 = pygame.Rect(self.x, self.y, 50, 50)
|
||||||
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
|
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
|
||||||
@ -102,150 +124,162 @@ class Waiter(object):
|
|||||||
self.game.screen.blit(self.image, (self.x, self.y))
|
self.game.screen.blit(self.image, (self.x, self.y))
|
||||||
|
|
||||||
|
|
||||||
def isMoveInRange(self, move):
|
def isMoveInRange(self, move, grid):
|
||||||
|
position = self.findWaiter(grid)
|
||||||
|
positionX = position[0]
|
||||||
|
positionY = position[1]
|
||||||
|
|
||||||
if move == "Left":
|
if move == "Left":
|
||||||
if self.positionX == 0:
|
if positionX == 0:
|
||||||
return False
|
return False
|
||||||
if move == "Right":
|
if move == "Right":
|
||||||
if self.positionX == 9:
|
if positionX == 9:
|
||||||
return False
|
return False
|
||||||
if move == "Up":
|
if move == "Up":
|
||||||
if self.positionY == 0:
|
if positionY == 0:
|
||||||
return False
|
return False
|
||||||
if move == "Down":
|
if move == "Down":
|
||||||
if self.positionY == 9:
|
if positionY == 9:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def checkPoss(self, game, lastOperation):
|
def checkPoss(self, grid, lastOperation):
|
||||||
self.grid = game.grid
|
|
||||||
self.lastOperation = lastOperation
|
|
||||||
self.stackMove = []
|
|
||||||
|
|
||||||
if len(self.lastOperation) == 0:
|
stackMove = []
|
||||||
if self.isMoveInRange("Up"):
|
|
||||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
position = self.findWaiter(grid)
|
||||||
if self.collisionObjectUp.type == "gridElement":
|
positionX = position[0]
|
||||||
self.stackMove.append("Up")
|
positionY = position[1]
|
||||||
if self.isMoveInRange("Down"):
|
|
||||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
if len(lastOperation) == 0:
|
||||||
if self.collisionObjectDown.type == "gridElement":
|
if self.isMoveInRange("Up", grid):
|
||||||
self.stackMove.append("Down")
|
collisionObjectUp = grid[positionY - 1][positionX]
|
||||||
if self.isMoveInRange("Left"):
|
if collisionObjectUp.type == "gridElement":
|
||||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
stackMove.append("Up")
|
||||||
if self.collisionObjectLeft.type == "gridElement":
|
if self.isMoveInRange("Down", grid):
|
||||||
self.stackMove.append("Left")
|
collisionObjectDown = grid[positionY + 1][positionX]
|
||||||
if self.isMoveInRange("Right"):
|
if collisionObjectDown.type == "gridElement":
|
||||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
stackMove.append("Down")
|
||||||
if self.collisionObjectRight.type == "gridElement":
|
if self.isMoveInRange("Left", grid):
|
||||||
self.stackMove.append("Right")
|
collisionObjectLeft = grid[positionY][positionX - 1]
|
||||||
return self.stackMove
|
if collisionObjectLeft.type == "gridElement":
|
||||||
|
stackMove.append("Left")
|
||||||
|
if self.isMoveInRange("Right", grid):
|
||||||
|
collisionObjectRight = grid[positionY][positionX + 1]
|
||||||
|
if collisionObjectRight.type == "gridElement":
|
||||||
|
stackMove.append("Right")
|
||||||
|
return stackMove
|
||||||
else:
|
else:
|
||||||
self.last = self.lastOperation[-1]
|
last = lastOperation[-1]
|
||||||
if self.last == "Left":
|
if last == "Left":
|
||||||
if self.isMoveInRange("Up"):
|
if self.isMoveInRange("Up", grid):
|
||||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
collisionObjectUp = grid[positionY - 1][positionX]
|
||||||
if self.collisionObjectUp.type == "gridElement":
|
if collisionObjectUp.type == "gridElement":
|
||||||
self.stackMove.append("Up")
|
stackMove.append("Up")
|
||||||
if self.isMoveInRange("Down"):
|
if self.isMoveInRange("Down", grid):
|
||||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
collisionObjectDown = grid[positionY + 1][positionX]
|
||||||
if self.collisionObjectDown.type == "gridElement":
|
if collisionObjectDown.type == "gridElement":
|
||||||
self.stackMove.append("Down")
|
stackMove.append("Down")
|
||||||
if self.isMoveInRange("Left"):
|
if self.isMoveInRange("Left", grid):
|
||||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
collisionObjectLeft = grid[positionY][positionX - 1]
|
||||||
if self.collisionObjectLeft.type == "gridElement":
|
if collisionObjectLeft.type == "gridElement":
|
||||||
self.stackMove.append("Left")
|
stackMove.append("Left")
|
||||||
|
|
||||||
return self.stackMove
|
return stackMove
|
||||||
|
|
||||||
if self.last == "Right":
|
if last == "Right":
|
||||||
if self.isMoveInRange("Up"):
|
if self.isMoveInRange("Up", grid):
|
||||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
collisionObjectUp = grid[positionY - 1][positionX]
|
||||||
if self.collisionObjectUp.type == "gridElement":
|
if collisionObjectUp.type == "gridElement":
|
||||||
self.stackMove.append("Up")
|
stackMove.append("Up")
|
||||||
if self.isMoveInRange("Down"):
|
if self.isMoveInRange("Down", grid):
|
||||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
collisionObjectDown = grid[positionY + 1][positionX]
|
||||||
if self.collisionObjectDown.type == "gridElement":
|
if collisionObjectDown.type == "gridElement":
|
||||||
self.stackMove.append("Down")
|
stackMove.append("Down")
|
||||||
|
|
||||||
if self.isMoveInRange("Right"):
|
if self.isMoveInRange("Right", grid):
|
||||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
collisionObjectRight = grid[positionY][positionX + 1]
|
||||||
if self.collisionObjectRight.type == "gridElement":
|
if collisionObjectRight.type == "gridElement":
|
||||||
self.stackMove.append("Right")
|
stackMove.append("Right")
|
||||||
return self.stackMove
|
return stackMove
|
||||||
|
|
||||||
if self.last == "Up":
|
if last == "Up":
|
||||||
if self.isMoveInRange("Up"):
|
if self.isMoveInRange("Up", grid):
|
||||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
collisionObjectUp = grid[positionY - 1][positionX]
|
||||||
if self.collisionObjectUp.type == "gridElement":
|
if collisionObjectUp.type == "gridElement":
|
||||||
self.stackMove.append("Up")
|
stackMove.append("Up")
|
||||||
|
|
||||||
if self.isMoveInRange("Left"):
|
if self.isMoveInRange("Left", grid):
|
||||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
collisionObjectLeft = grid[positionY][positionX - 1]
|
||||||
if self.collisionObjectLeft.type == "gridElement":
|
if collisionObjectLeft.type == "gridElement":
|
||||||
self.stackMove.append("Left")
|
stackMove.append("Left")
|
||||||
if self.isMoveInRange("Right"):
|
if self.isMoveInRange("Right", grid):
|
||||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
collisionObjectRight = grid[positionY][positionX + 1]
|
||||||
if self.collisionObjectRight.type == "gridElement":
|
if collisionObjectRight.type == "gridElement":
|
||||||
self.stackMove.append("Right")
|
stackMove.append("Right")
|
||||||
return self.stackMove
|
return stackMove
|
||||||
|
|
||||||
if self.last == "Down":
|
if last == "Down":
|
||||||
|
|
||||||
if self.isMoveInRange("Down"):
|
if self.isMoveInRange("Down", grid):
|
||||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
collisionObjectDown = grid[positionY + 1][positionX]
|
||||||
if self.collisionObjectDown.type == "gridElement":
|
if collisionObjectDown.type == "gridElement":
|
||||||
self.stackMove.append("Down")
|
stackMove.append("Down")
|
||||||
if self.isMoveInRange("Left"):
|
if self.isMoveInRange("Left", grid):
|
||||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
collisionObjectLeft = grid[positionY][positionX - 1]
|
||||||
if self.collisionObjectLeft.type == "gridElement":
|
if collisionObjectLeft.type == "gridElement":
|
||||||
self.stackMove.append("Left")
|
stackMove.append("Left")
|
||||||
if self.isMoveInRange("Right"):
|
if self.isMoveInRange("Right", grid):
|
||||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
collisionObjectRight = grid[positionY][positionX + 1]
|
||||||
if self.collisionObjectRight.type == "gridElement":
|
if collisionObjectRight.type == "gridElement":
|
||||||
self.stackMove.append("Right")
|
stackMove.append("Right")
|
||||||
return self.stackMove
|
return stackMove
|
||||||
|
|
||||||
|
|
||||||
def dfsFind(self, game, currentOperation, idTable):
|
def dfsFind(self, grid, currentOperation, idTable):
|
||||||
self.game = game
|
|
||||||
self.grid = game.grid
|
|
||||||
self.currentOperation = currentOperation
|
|
||||||
print("Sprawdzam czy stolik")
|
print("Sprawdzam czy stolik")
|
||||||
if self.isMoveInRange("Up"):
|
position = self.findWaiter(grid)
|
||||||
if self.grid[self.positionY - 1][self.positionX].type == "table":
|
positionX = position[0]
|
||||||
if self.grid[self.positionY - 1][self.positionX].id == idTable:
|
positionY = position[1]
|
||||||
return self.currentOperation
|
|
||||||
if self.isMoveInRange("Down"):
|
if self.isMoveInRange("Up", grid):
|
||||||
if self.grid[self.positionY + 1][self.positionX].type == "table":
|
if grid[positionY - 1][positionX].type == "table":
|
||||||
if self.grid[self.positionY + 1][self.positionX].id == idTable:
|
if grid[positionY - 1][positionX].id == idTable:
|
||||||
return self.currentOperation
|
self.allPath.append(currentOperation)
|
||||||
if self.isMoveInRange("Left"):
|
return 0
|
||||||
if self.grid[self.positionY][self.positionX - 1].type == "table":
|
if self.isMoveInRange("Down", grid):
|
||||||
if self.grid[self.positionY][self.positionX - 1].id == idTable:
|
if grid[positionY + 1][positionX].type == "table":
|
||||||
return self.currentOperation
|
if grid[positionY + 1][positionX].id == idTable:
|
||||||
if self.isMoveInRange("Right"):
|
self.allPath.append(currentOperation)
|
||||||
if self.grid[self.positionY][self.positionX + 1].type == "table":
|
return 0
|
||||||
if self.grid[self.positionY][self.positionX + 1].id == idTable:
|
if self.isMoveInRange("Left", grid):
|
||||||
return self.currentOperation
|
if grid[positionY][positionX - 1].type == "table":
|
||||||
print("Sprawdzilem nie stolik")
|
if grid[positionY][positionX - 1].id == idTable:
|
||||||
|
self.allPath.append(currentOperation)
|
||||||
|
return 0
|
||||||
|
if self.isMoveInRange("Right", grid):
|
||||||
|
if grid[positionY][positionX + 1].type == "table":
|
||||||
|
if grid[positionY][positionX + 1].id == idTable:
|
||||||
|
self.allPath.append(currentOperation)
|
||||||
|
return 0
|
||||||
|
print("Sprawdzilem nie jest to stolik")
|
||||||
steps = []
|
steps = []
|
||||||
steps.append(self.checkPoss(self.game, self.currentOperation))
|
steps.append(self.checkPoss(grid, currentOperation))
|
||||||
|
print("Naszymi mozliwosciami sa ", steps)
|
||||||
step = steps[-1]
|
step = steps[-1]
|
||||||
print(step[-1])
|
print("Wybieram : ", step[-1])
|
||||||
if step[-1] == "Left":
|
if step[-1] == "Left":
|
||||||
self.moveLeft(self.game)
|
self.moveLeft(grid)
|
||||||
self.currentOperation.append("Left")
|
currentOperation.append("Left")
|
||||||
if step[-1] == "Right":
|
if step[-1] == "Right":
|
||||||
self.moveRight(self.game)
|
self.moveRight(grid)
|
||||||
self.currentOperation.append("Right")
|
currentOperation.append("Right")
|
||||||
if step[-1] == "Up":
|
if step[-1] == "Up":
|
||||||
self.moveUp(self.game)
|
self.moveUp(grid)
|
||||||
self.currentOperation.append("Up")
|
currentOperation.append("Up")
|
||||||
if step[-1] == "Down":
|
if step[-1] == "Down":
|
||||||
self.moveDown(self.game)
|
self.moveDown(grid)
|
||||||
self.currentOperation.append("Down")
|
currentOperation.append("Down")
|
||||||
game.draw()
|
|
||||||
time.sleep(.500)
|
self.dfsFind(grid[:], currentOperation[:], idTable)
|
||||||
pygame.display.flip()
|
|
||||||
self.dfsFind(self.game, self.currentOperation, idTable)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user