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