graphserach v0.6.4
This commit is contained in:
parent
d45ec38792
commit
1bdef8cc56
@ -2,7 +2,7 @@
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.8 (AI_Tractor)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (AI_Tractor)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||
</project>
|
42
FindPath.py
42
FindPath.py
@ -28,6 +28,7 @@ def whichStateLookingFor(tractor, TillageUnit):
|
||||
searching_field = "toFertilize"
|
||||
return searching_field
|
||||
|
||||
|
||||
def nearestLookingField(board, tractor, TillageUnit):
|
||||
end_horizontal_index = 0
|
||||
end_vertical_index = 0
|
||||
@ -39,8 +40,10 @@ def nearestLookingField(board, tractor, TillageUnit):
|
||||
end_horizontal_index = field.horizontal_index
|
||||
end_vertical_index = field.vertical_index
|
||||
break
|
||||
|
||||
return end_horizontal_index, end_vertical_index
|
||||
|
||||
|
||||
def graphsearch(tractor, board, TillageUnit, fringe: Queue, explored):
|
||||
start_horizontal_index = tractor.horizontal_index
|
||||
start_vertical_index = tractor.vertical_index
|
||||
@ -59,8 +62,8 @@ def graphsearch(tractor, board, TillageUnit, fringe: Queue, explored):
|
||||
|
||||
if goaltest(elem, end_state):
|
||||
break
|
||||
#TODO
|
||||
#return droga ktora musi pokonac traktor
|
||||
# TODO
|
||||
# return droga ktora musi pokonac traktor
|
||||
else:
|
||||
explored.append(elem)
|
||||
elem = succ(start_state, end_state, tractor)
|
||||
@ -68,36 +71,43 @@ def graphsearch(tractor, board, TillageUnit, fringe: Queue, explored):
|
||||
|
||||
|
||||
def goaltest(elem, end_state):
|
||||
print('element: ',elem,' stan koncowy; ', end_state)
|
||||
if elem == end_state:
|
||||
print("heeee")
|
||||
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def succ(start_state, end_state, tractor):
|
||||
print(tractor.horizontal_index, ' ', tractor.vertical_index)
|
||||
a = input()
|
||||
if start_state[1] < end_state[1]:
|
||||
if tractor.direction == "RIGHT":
|
||||
tractor.drive()
|
||||
print("przesunalem sie w prawo")
|
||||
else:
|
||||
tractor.direction = "RIGHT"
|
||||
print("przesunalem sie w prawo")
|
||||
|
||||
elif start_state[1] > end_state[1]:
|
||||
if tractor.direction == "LEFT":
|
||||
tractor.drive()
|
||||
print("przesunalem sie w lewo")
|
||||
else:
|
||||
tractor.direction = "LEFT"
|
||||
print("przesunalem sie w lewo")
|
||||
else:
|
||||
if start_state[0] < end_state[0]:
|
||||
if tractor.direction == "DOWN":
|
||||
tractor.drive()
|
||||
else:
|
||||
tractor.direction = "DOWN"
|
||||
|
||||
elif start_state[0] < end_state[0]:
|
||||
if tractor.direction == "DOWN":
|
||||
tractor.drive()
|
||||
print("przesunalem sie w dol")
|
||||
elif start_state[0] > end_state[0]:
|
||||
if tractor.direction == "UP":
|
||||
tractor.drive()
|
||||
else:
|
||||
tractor.direction = "UP"
|
||||
else:
|
||||
tractor.direction = "DOWN"
|
||||
elif start_state[0] > end_state[0]:
|
||||
if tractor.direction == "UP":
|
||||
tractor.drive()
|
||||
print("przesunalem sie w gore")
|
||||
else:
|
||||
return tractor.horizontal_index, tractor.horizontal_index
|
||||
tractor.direction = "UP"
|
||||
else:
|
||||
return tractor.horizontal_index, tractor.horizontal_index
|
Loading…
Reference in New Issue
Block a user