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