Compare commits

...

2 Commits

Author SHA1 Message Date
b15eaec8be Working on circles 2024-10-03 08:07:52 -04:00
8a35e51d21 CircleAlgo first Part 2024-10-02 08:15:02 -04:00

View File

@@ -48,6 +48,7 @@ var move_check3 = 0
var move_check5 = 0
var Move_Check6 = 0
var Move_Check7 = 0
var Move_Check4 = 0
var Move_Check9 = 0
var Cicling = false
var CircleIntsMax = 0
@@ -68,6 +69,7 @@ var InvertionArray = []
var CordsDump = []
var FullCount = 0
var Done = 0
var Root = []
func _input(event):
if Current_Position != TargetCord:
@@ -178,15 +180,11 @@ func Circling():
if Been_There_Array.size() > 3:
if move_check5 != move:
if Intersections.find(Current_Position) != Intersections.size()-1 and Intersections.find(Current_Position) != -1 and Been_There_Array[-2] == false and Been_There_Array[-3] == false:
# var holder = []
# for n in (move - BackTrack_Array[-1]):
# holder.push_back(LogDump[n])
#holder.push_front(Prev_dir_Opp)
#print(holder)
print("Circling")
Cicling = true
#ndividual_Steps.push_front(holder)
#CircleRootsAndInts()
Root = Current_Position
print("The Root is equal to: ",Root, " and its position in int array is: ", Intersections.find(Root))
print("There are ", Intersections.size() - Intersections.find(Root), " Intersections")
HowManyIntsInCircle()
if CircleInts == 0:
print("This Circle is exhausted go back")
@@ -194,9 +192,10 @@ func Circling():
for n in CircleIntsMax:
Individual_Steps.pop_front()
GoBack(Individual_Steps[0])
if CircleInts != 0:
print("Go back to circle part :(")
#FirstCirclePart()
FirstCirclePart()
move_check5 = move
func HowManyIntsInCircle():
@@ -210,30 +209,30 @@ func HowManyIntsInCircle():
print(CircleInts)
func FirstCirclePart():
var count = CircleInts
var Skipping_array = []
print(Tree_Array)
for nums in Intersections.size() - Intersections.find(Root):
if nums > 0:
Skipping_array.push_back((Intersections.find(Root) - nums) + 1)
print(Skipping_array)
for x in Skipping_array:
print(x)
if Tree_Array[x] == 1:
print("Skip")
GoToParts()
if count == 0 and Current_Position == Intersections_from_root[0]:
Cicling = false
Intersection_Tree()
Ordered_Commands_Backward.clear()
print("Ignoreeeeeee")
for takeout in CircleInts + 1:
Individual_Steps.pop_front()
Tree_Array.pop_back()
print("Goin back")
print(Individual_Steps)
GoBack(Individual_Steps[0])
CircleCompleted = true
#** Returning if it needs more work or not
return false
else:
print("Go To")
elif count != 0 and Current_Position == Intersections_from_root[0]:
GoBack(Individual_Steps[0])
Individual_Steps.pop_front()
print("Number Of Ints: ", CircleInts)
print(Individual_Steps)
#** Returning if it needs more work or not
return true
func GoToParts():
var holder = []
for n in (CircleManualDistance()):
#holder.push_back(LogDump[n])
holder.push_front(Prev_dir_Opp)
print(holder)
print(LogDump)
#GoBack(holder)
func CircleRootsAndInts():
if Cicling == true:
@@ -242,12 +241,11 @@ func CircleRootsAndInts():
Intersections_from_root.push_back(Current_Position)
var Duplicate = Intersections_from_root.duplicate(true)
Intersections_from_root = Duplicate
print(Intersections_from_root)
func DeadEndCircles():
if Cicling == true:
if Detail_Dict.Type == "Dead End":
if AutoBacktrack == true:
CircleIntSubtractor()
return true
else:
return false
@@ -256,22 +254,30 @@ func SolvinCircleDeadEnds():
if CircleManualDistance() != null:
for n in CircleManualDistance():
GoBack(LogDump[n])
func CircleComplete():
if CircleCompleted == true:
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Been_There == false:
Individual_Steps.push_front(GiveOrder())
print("Circle Complete")
print(Individual_Steps)
print(Tree_Array)
CircleCompleted = false
else:
pass
func CircleIntSubtractor():
#print(Individual_Steps[0])
CircleInts -= 1
GoBack(Individual_Steps[0])
print(CircleInts)
func CircleManualDistance():
if DeadEndCircles() == true and Intersections_from_root.size() >= 2:
var Starting_Pos = Intersections_from_root[-2]
var Ending_Pos = Intersections_from_root[-1]
var x = abs(Starting_Pos[0] - Ending_Pos[0])
var y = abs(Starting_Pos[1] - Ending_Pos[1])
return x+y
func ManualDistance(Start, End):
if DeadEndCircles() == true and Intersections_from_root.size() >= 2:
var Starting_Pos = Start
var Ending_Pos = End
var x = abs(Starting_Pos[0] - Ending_Pos[0])
var y = abs(Starting_Pos[1] - Ending_Pos[1])
return x+y
func Intersection_Tree():
if Cicling == false:
if Detail_Dict.Been_There == false:
@@ -304,14 +310,6 @@ func CheckForTreeDeadEnds():
else:
pass
func CircleManualDistance():
if DeadEndCircles() == true and Intersections_from_root.size() >= 2:
var Starting_Pos = Intersections_from_root[-2]
var Ending_Pos = Intersections_from_root[-1]
var x = abs(Starting_Pos[0] - Ending_Pos[0])
var y = abs(Starting_Pos[1] - Ending_Pos[1])
return x+y
func GiveOrder():
Ordered_Commands_Backward.erase("")
@@ -336,7 +334,7 @@ func TrackIntersections():
func MoveAfterIntersection():
if move == IntersectionMove+1:
if Move_Check6 != move:
if Move_Check6 != move and Cicling == false:
if TrackBack.size() != 1 and BackTrack_Array.size() > 1:
IntersectionDir.push_back(LogDumpOrdered[0])
if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1: