sprawdzanie mozliwosci ruchu
This commit is contained in:
parent
c3247c1ef7
commit
a1f3a28daf
@ -2,6 +2,8 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/game.py" beforeDir="false" afterPath="$PROJECT_DIR$/game.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/waiter.py" beforeDir="false" afterPath="$PROJECT_DIR$/waiter.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
@ -24,22 +26,29 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/game.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="140">
|
||||
<caret line="57" column="33" selection-start-line="57" selection-start-column="29" selection-end-line="57" selection-end-column="33" />
|
||||
<state relative-caret-position="1218">
|
||||
<caret line="58" column="66" selection-start-line="58" selection-start-column="66" selection-end-line="58" selection-end-column="66" />
|
||||
<folding>
|
||||
<element signature="e#0#18#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/Images/plytka.png">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="294">
|
||||
<caret line="14" column="59" lean-forward="true" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||
<entry file="file://$PROJECT_DIR$/table.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="252">
|
||||
<caret line="12" column="19" lean-forward="true" selection-start-line="12" selection-start-column="19" selection-end-line="12" selection-end-column="19" />
|
||||
<state relative-caret-position="63">
|
||||
<caret line="3" selection-start-line="3" selection-end-line="3" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -47,8 +56,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/pool.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="189">
|
||||
<caret line="9" column="26" lean-forward="true" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
||||
<state relative-caret-position="168">
|
||||
<caret line="9" column="26" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
@ -56,29 +65,11 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/table.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="420">
|
||||
<caret line="20" column="55" selection-start-line="20" selection-start-column="55" selection-end-line="20" selection-end-column="55" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/orderTable.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="273">
|
||||
<caret line="13" column="32" lean-forward="true" selection-start-line="13" selection-start-column="32" selection-end-line="13" selection-end-column="32" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/1">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="21">
|
||||
<caret line="1" column="8" selection-start-line="1" selection-start-column="8" selection-end-line="1" selection-end-column="8" />
|
||||
<state relative-caret-position="357">
|
||||
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -86,8 +77,8 @@
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="434">
|
||||
<caret line="99" column="8" selection-start-line="99" selection-start-column="8" selection-end-line="99" selection-end-column="8" />
|
||||
<state relative-caret-position="98">
|
||||
<caret line="192" column="16" selection-start-line="192" selection-start-column="16" selection-end-line="192" selection-end-column="16" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
@ -383,13 +374,6 @@
|
||||
<entry file="file://$PROJECT_DIR$/Images/plytka.png">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/table.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="420">
|
||||
<caret line="20" column="55" selection-start-line="20" selection-start-column="55" selection-end-line="20" selection-end-column="55" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/1">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="21">
|
||||
@ -397,10 +381,37 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Images/tlo.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/table.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="63">
|
||||
<caret line="3" selection-start-line="3" selection-end-line="3" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pool.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="168">
|
||||
<caret line="9" column="26" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/orderTable.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="273">
|
||||
<caret line="13" column="32" lean-forward="true" selection-start-line="13" selection-start-column="32" selection-end-line="13" selection-end-column="32" />
|
||||
<state relative-caret-position="357">
|
||||
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="294">
|
||||
<caret line="14" column="59" lean-forward="true" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -411,37 +422,20 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pool.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="189">
|
||||
<caret line="9" column="26" lean-forward="true" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="252">
|
||||
<caret line="12" column="19" lean-forward="true" selection-start-line="12" selection-start-column="19" selection-end-line="12" selection-end-column="19" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Images/tlo.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/game.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="140">
|
||||
<caret line="57" column="33" selection-start-line="57" selection-start-column="29" selection-end-line="57" selection-end-column="33" />
|
||||
<state relative-caret-position="1218">
|
||||
<caret line="58" column="66" selection-start-line="58" selection-start-column="66" selection-end-line="58" selection-end-column="66" />
|
||||
<folding>
|
||||
<element signature="e#0#18#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="434">
|
||||
<caret line="99" column="8" selection-start-line="99" selection-start-column="8" selection-end-line="99" selection-end-column="8" />
|
||||
<state relative-caret-position="98">
|
||||
<caret line="192" column="16" selection-start-line="192" selection-start-column="16" selection-end-line="192" selection-end-column="16" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
game.py
1
game.py
@ -56,6 +56,7 @@ class Game(object):
|
||||
|
||||
self.draw()
|
||||
self.waiter.move(self)
|
||||
print(self.waiter.checkPoss(self, self.waiter.lastStep))
|
||||
pygame.display.flip()
|
||||
#print(self.waiterNumberInGrid)
|
||||
self.fpsClock.tick(10)
|
||||
|
114
waiter.py
114
waiter.py
@ -97,5 +97,117 @@ class Waiter(object):
|
||||
def draw(self):
|
||||
self.rect1 = pygame.Rect(self.x, self.y, 50, 50)
|
||||
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
|
||||
print(self.lastStep)
|
||||
#print(self.lastStep)
|
||||
self.game.screen.blit(self.image, (self.x, self.y))
|
||||
|
||||
|
||||
def isMoveInRange(self, move):
|
||||
if move == "Left":
|
||||
if self.positionX == 0:
|
||||
return False
|
||||
if move == "Right":
|
||||
if self.positionX == 9:
|
||||
return False
|
||||
if move == "Up":
|
||||
if self.positionY == 0:
|
||||
return False
|
||||
if move == "Down":
|
||||
if self.positionY == 9:
|
||||
return False
|
||||
return True
|
||||
|
||||
def checkPoss(self, game, lastOperation):
|
||||
self.grid = game.grid
|
||||
self.lastOperation = lastOperation
|
||||
self.stackMove = []
|
||||
|
||||
if len(self.lastOperation) == 0:
|
||||
if self.isMoveInRange("Up"):
|
||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
||||
if self.collisionObjectUp.type == "gridElement":
|
||||
self.stackMove.append("Up")
|
||||
if self.isMoveInRange("Down"):
|
||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
||||
if self.collisionObjectDown.type == "gridElement":
|
||||
self.stackMove.append("Down")
|
||||
if self.isMoveInRange("Left"):
|
||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
||||
if self.collisionObjectLeft.type == "gridElement":
|
||||
self.stackMove.append("Left")
|
||||
if self.isMoveInRange("Right"):
|
||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
||||
if self.collisionObjectRight.type == "gridElement":
|
||||
self.stackMove.append("Right")
|
||||
return self.stackMove
|
||||
else:
|
||||
self.last = self.lastOperation[-1]
|
||||
if self.last == "Left":
|
||||
if self.isMoveInRange("Up"):
|
||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
||||
if self.collisionObjectUp.type == "gridElement":
|
||||
self.stackMove.append("Up")
|
||||
if self.isMoveInRange("Down"):
|
||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
||||
if self.collisionObjectDown.type == "gridElement":
|
||||
self.stackMove.append("Down")
|
||||
if self.isMoveInRange("Left"):
|
||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
||||
if self.collisionObjectLeft.type == "gridElement":
|
||||
self.stackMove.append("Left")
|
||||
|
||||
return self.stackMove
|
||||
|
||||
if self.last == "Right":
|
||||
if self.isMoveInRange("Up"):
|
||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
||||
if self.collisionObjectUp.type == "gridElement":
|
||||
self.stackMove.append("Up")
|
||||
if self.isMoveInRange("Down"):
|
||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
||||
if self.collisionObjectDown.type == "gridElement":
|
||||
self.stackMove.append("Down")
|
||||
|
||||
if self.isMoveInRange("Right"):
|
||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
||||
if self.collisionObjectRight.type == "gridElement":
|
||||
self.stackMove.append("Right")
|
||||
return self.stackMove
|
||||
|
||||
if self.last == "Up":
|
||||
if self.isMoveInRange("Up"):
|
||||
self.collisionObjectUp = self.grid[self.positionY - 1][self.positionX]
|
||||
if self.collisionObjectUp.type == "gridElement":
|
||||
self.stackMove.append("Up")
|
||||
|
||||
if self.isMoveInRange("Left"):
|
||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
||||
if self.collisionObjectLeft.type == "gridElement":
|
||||
self.stackMove.append("Left")
|
||||
if self.isMoveInRange("Right"):
|
||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
||||
if self.collisionObjectRight.type == "gridElement":
|
||||
self.stackMove.append("Right")
|
||||
return self.stackMove
|
||||
|
||||
if self.last == "Down":
|
||||
|
||||
if self.isMoveInRange("Down"):
|
||||
self.collisionObjectDown = self.grid[self.positionY + 1][self.positionX]
|
||||
if self.collisionObjectDown.type == "gridElement":
|
||||
self.stackMove.append("Down")
|
||||
if self.isMoveInRange("Left"):
|
||||
self.collisionObjectLeft = self.grid[self.positionY][self.positionX - 1]
|
||||
if self.collisionObjectLeft.type == "gridElement":
|
||||
self.stackMove.append("Left")
|
||||
if self.isMoveInRange("Right"):
|
||||
self.collisionObjectRight = self.grid[self.positionY][self.positionX + 1]
|
||||
if self.collisionObjectRight.type == "gridElement":
|
||||
self.stackMove.append("Right")
|
||||
return self.stackMove
|
||||
|
||||
|
||||
def dfsFind(self, game, currentOperation):
|
||||
self.game = game
|
||||
self.grid = game.grid
|
||||
self.currentOperation = currentOperation
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user