debugowanie
This commit is contained in:
parent
32d7317af5
commit
7baf7dadb3
@ -3,12 +3,8 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
|
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/fringe.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/graph.py" beforeDir="false" afterPath="$PROJECT_DIR$/graph.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/graph.py" beforeDir="false" afterPath="$PROJECT_DIR$/graph.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/harvest.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/istate.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/tractor.py" beforeDir="false" afterPath="$PROJECT_DIR$/tractor.py" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -111,6 +107,8 @@
|
|||||||
<workItem from="1617982355911" duration="241000" />
|
<workItem from="1617982355911" duration="241000" />
|
||||||
<workItem from="1617984929356" duration="612000" />
|
<workItem from="1617984929356" duration="612000" />
|
||||||
<workItem from="1617992640419" duration="8178000" />
|
<workItem from="1617992640419" duration="8178000" />
|
||||||
|
<workItem from="1618001458885" duration="787000" />
|
||||||
|
<workItem from="1618042095757" duration="3541000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -122,44 +120,62 @@
|
|||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617994393023" />
|
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617994393023" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.bottom" timestamp="1618001369741">
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1618045669923">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669923" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.center" timestamp="1618001369741">
|
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1618045669923">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669923" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.left" timestamp="1618001369741">
|
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1618045669923">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669923" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.right" timestamp="1618001369741">
|
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1618045669923">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669923" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1618001369741">
|
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1618045669918">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="364" key="GridCell.Tab.1.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669918" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.center" timestamp="1618001369741">
|
<state width="1879" height="364" key="GridCell.Tab.1.center" timestamp="1618045669918">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.center/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="364" key="GridCell.Tab.1.center/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669918" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.left" timestamp="1618001369741">
|
<state width="1879" height="364" key="GridCell.Tab.1.left" timestamp="1618045669918">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.left/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="364" key="GridCell.Tab.1.left/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669918" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.right" timestamp="1618001369741">
|
<state width="1879" height="364" key="GridCell.Tab.1.right" timestamp="1618045669918">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1618001369741" />
|
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1618045669918" />
|
||||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617992641722">
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1618042189818">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617992641722" />
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1618042189818" />
|
||||||
|
</component>
|
||||||
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager>
|
||||||
|
<breakpoints>
|
||||||
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
|
<url>file://$PROJECT_DIR$/graph.py</url>
|
||||||
|
<line>75</line>
|
||||||
|
<option name="timeStamp" value="7" />
|
||||||
|
</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>
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1618001250511" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1618045588811" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
Binary file not shown.
36
graph.py
36
graph.py
@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import tractor
|
import tractor
|
||||||
class Node:
|
class Node:
|
||||||
def __init__(self, action, direction, parent, x, y):
|
def __init__(self, action, direction, parent, x, y):
|
||||||
@ -61,19 +62,29 @@ def goal_test(elem, goaltest):
|
|||||||
return False
|
return False
|
||||||
def succ(elem):
|
def succ(elem):
|
||||||
actions_list = []
|
actions_list = []
|
||||||
actions_list.append(("rotate_left", (elem.get_x(), elem.get_y())))
|
temp = copy.copy(elem.get_direction())
|
||||||
actions_list.append(("rotate_right", (elem.get_x(), elem.get_y())))
|
if temp == 1:
|
||||||
|
temp = 4
|
||||||
|
else:
|
||||||
|
temp = temp - 1
|
||||||
|
actions_list.append(("rotate_left", (temp, elem.get_x(), elem.get_y())))
|
||||||
|
temp = copy.copy(elem.get_direction())
|
||||||
|
if temp == 4:
|
||||||
|
temp = 1
|
||||||
|
else:
|
||||||
|
temp = temp + 1
|
||||||
|
actions_list.append(("rotate_right", (temp, elem.get_x(), elem.get_y())))
|
||||||
if tractor.Tractor.is_move_allowed_succ(elem) == "x + 1":
|
if tractor.Tractor.is_move_allowed_succ(elem) == "x + 1":
|
||||||
actions_list.append(("move", (elem.set_x(elem.get_x() + 1), elem.get_y())))
|
actions_list.append(("move", (elem.get_direction(), elem.set_x(elem.get_x() + 1), elem.get_y())))
|
||||||
elif tractor.Tractor.is_move_allowed_succ(elem) == "y - 1":
|
elif tractor.Tractor.is_move_allowed_succ(elem) == "y - 1":
|
||||||
actions_list.append(("move", (elem.get_x(), elem.set_y(elem.get_y() - 1))))
|
actions_list.append(("move", (elem.get_direction(), elem.get_x(), elem.set_y(elem.get_y() - 1))))
|
||||||
elif tractor.Tractor.is_move_allowed_succ(elem) == "y + 1":
|
elif tractor.Tractor.is_move_allowed_succ(elem) == "y + 1":
|
||||||
actions_list.append(("move", (elem.set_x(elem.get_x()), elem.set_y(elem.get_y() + 1))))
|
actions_list.append(("move", (elem.get_direction(), elem.get_x(), elem.set_y(elem.get_y() + 1))))
|
||||||
elif tractor.Tractor.is_move_allowed_succ(elem) == "x - 1":
|
elif tractor.Tractor.is_move_allowed_succ(elem) == "x - 1":
|
||||||
actions_list.append(("move", (elem.set_x(elem.get_x() - 1), elem.get_y())))
|
actions_list.append(("move", (elem.get_direction(), elem.set_x(elem.get_x() - 1), elem.get_y())))
|
||||||
return actions_list
|
return actions_list
|
||||||
def graphsearch(fringe, explored, istate, succ, goaltest):
|
def graphsearch(fringe, explored, istate, succ, goaltest):
|
||||||
node = Node(None, istate.get_direction(), None, istate.get_x(), istate.get_y())
|
node = Node(None, istate.get_direction(), None, istate.get_x(), istate.get_y()) #może None coś nie gra
|
||||||
#fringe.add_to_fringe(node)
|
#fringe.add_to_fringe(node)
|
||||||
fringe.append(node)
|
fringe.append(node)
|
||||||
while True:
|
while True:
|
||||||
@ -81,16 +92,17 @@ def graphsearch(fringe, explored, istate, succ, goaltest):
|
|||||||
return False
|
return False
|
||||||
#elem = fringe.get_element_from_fringe_pop()
|
#elem = fringe.get_element_from_fringe_pop()
|
||||||
elem = fringe.pop(0)
|
elem = fringe.pop(0)
|
||||||
|
temp = copy.copy(elem) #żeby explored w for succ() nie zmieniało
|
||||||
if goal_test(elem, goaltest) is True:
|
if goal_test(elem, goaltest) is True:
|
||||||
return explored
|
return explored
|
||||||
explored.append(elem)
|
explored.append(elem)
|
||||||
for (action, state) in succ(elem):
|
for (action, state) in succ(temp):
|
||||||
if state not in fringe and state not in explored:
|
if state not in fringe and state not in explored:
|
||||||
x = Node(action, elem.get_direction(), elem, state[0], state[1])
|
x = Node(action, state[0], elem, state[1], state[2])
|
||||||
print(state[0])
|
print(state[0])
|
||||||
print(state[1])
|
print(state[1])
|
||||||
|
print(state[2])
|
||||||
print(x.get_action())
|
print(x.get_action())
|
||||||
print(x.get_direction())
|
#print(x.get_direction())
|
||||||
print(x.get_parent())
|
#print(x.get_parent())
|
||||||
|
|
||||||
fringe.append(x)
|
fringe.append(x)
|
4
py.py
4
py.py
@ -14,7 +14,7 @@ def main():
|
|||||||
collected_plants_dict = {"beetroot": 0, "carrot": 0, "potato": 0, "wheat": 0}
|
collected_plants_dict = {"beetroot": 0, "carrot": 0, "potato": 0, "wheat": 0}
|
||||||
fertilizer_dict = {"beetroot": definitions.TRACTOR_FERTILIZER, "carrot": definitions.TRACTOR_FERTILIZER, "potato": definitions.TRACTOR_FERTILIZER, "wheat": definitions.TRACTOR_FERTILIZER}
|
fertilizer_dict = {"beetroot": definitions.TRACTOR_FERTILIZER, "carrot": definitions.TRACTOR_FERTILIZER, "potato": definitions.TRACTOR_FERTILIZER, "wheat": definitions.TRACTOR_FERTILIZER}
|
||||||
station1 = station.Station(collected_plants_dict)
|
station1 = station.Station(collected_plants_dict)
|
||||||
tractor1 = tractor.Tractor(amount_of_seeds_dict, collected_plants_dict, definitions.TRACTOR_DIRECTION_SOUTH, fertilizer_dict, definitions.TRACTOR_FUEL, definitions.TRACTOR_WATER_LEVEL, 0, 0)
|
tractor1 = tractor.Tractor(amount_of_seeds_dict, collected_plants_dict, definitions.TRACTOR_DIRECTION_EAST, fertilizer_dict, definitions.TRACTOR_FUEL, definitions.TRACTOR_WATER_LEVEL, 0, 0)
|
||||||
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
|
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
run = True
|
run = True
|
||||||
@ -23,7 +23,7 @@ def main():
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
run = False
|
run = False
|
||||||
istate = graph.Istate(definitions.TRACTOR_DIRECTION_SOUTH, 0, 0)
|
istate = graph.Istate(definitions.TRACTOR_DIRECTION_EAST, 0, 0)
|
||||||
istate1 = graph.Istate(None, 4, 4)
|
istate1 = graph.Istate(None, 4, 4)
|
||||||
print(graph.graphsearch([], [], istate, graph.succ, istate1))
|
print(graph.graphsearch([], [], istate, graph.succ, istate1))
|
||||||
map1.draw_window(tractor1, tractor1_rect)
|
map1.draw_window(tractor1, tractor1_rect)
|
||||||
|
Loading…
Reference in New Issue
Block a user