Done with Circles!!!!!! Circles are solves and Recall func is solved. Gonna start on multi solving algo!!!

This commit is contained in:
2024-10-13 13:11:15 -04:00
parent 76cddca5a5
commit cfb439deb9
2 changed files with 195 additions and 147 deletions

View File

@@ -59,7 +59,7 @@ var CircleInts = 0
var LogDumpOrdered = []
var Order = []
var Intersections_from_root = []
var TargetCord = [200,-10] # HAD TO CHANGE TARGET CORD, IT WAS PREVIOUSLY [2,-10]
var TargetCord = [0,-11] # HAD TO CHANGE TARGET CORD, IT WAS PREVIOUSLY [2,-10]
var CircleCompleted = null
var AutoBacktrack = false
var IntersectionDict = {"Cord": [], "Data": [] }
@@ -115,6 +115,7 @@ func _process(delta):
IntersectionDumping()
CordsDumping()
FinishCircling()
#print(Detail_Dict.Type)
#print(Ordered_Commands_Backward)
#print(InverNext)
#print(CordsDump)
@@ -134,6 +135,18 @@ func _process(delta):
print()
print()
print("******************************")
#print("The last Ordered commands were: ", LogDump)
print("Circling is: ", Cicling)
print("Current Pos: ", Current_Position)
print(Intersections)
Mark(Prev_dir)
TrackIntersections()
BackToStart()
for n in Individual_Steps:
#print(n)
GoBack(n)
#print(CordsDump)
Done = 1
func Mark(Prev_Direction):
@@ -147,6 +160,55 @@ func Mark(Prev_Direction):
Coordinate_Dict.Details = Detail_Dict
var Coordinate_Dict_Copy = Coordinate_Dict.duplicate(true)
Coordinate_Dict = Coordinate_Dict_Copy
func BackToStart():
print(Detail_Dict.Type)
if Detail_Dict.Type == "Plain Path" and Cicling == false:
print("PLAIN PATH NORMAL")
Ordered_Commands_Backward.push_front(Prev_dir_Opp)
print(Ordered_Commands_Backward)
Individual_Steps.push_front(Ordered_Commands_Backward)
print(Individual_Steps)
if Detail_Dict.Type == "Plain Path" and Cicling == true:
print("PLAIN PATH Circling")
CirclingParody()
if Intersections.find(Current_Position) != -1:
print("INTERSECTION NORMAL")
Ordered_Commands_Backward.push_back(Prev_dir_Opp)
Ordered_Commands_Backward.reverse()
Individual_Steps.push_front(Ordered_Commands_Backward)
print(Individual_Steps)
if Detail_Dict.Type == "Dead End":
print("DEAD END NORMAL")
CirclingParody()
func CirclingParody():
var HasMoreVal = []
var HasMoreIndex = []
if Cicling == true:
print("Cant find... Improvising")
for n in CircleIntsMax:
print(n)
HasMoreIndex.push_back(-(n+1))
HasMoreVal.push_back(ManualDistance(Current_Position, Intersections[-(n+1)]))
print(HasMoreIndex)
print(HasMoreVal)
print("The minimum value is: ",HasMoreVal.min())
var addition = []
addition.append_array(LogDump.slice(0,HasMoreVal.min()-1))
addition.push_front(Prev_dir_Opp)
Individual_Steps.push_front(addition)
if Cicling == false:
print("Found Ya!!!")
print(ManualDistance(Current_Position, Intersections[-1]))
var addition = []
addition.append_array(LogDump.slice(0,ManualDistance(Current_Position,Intersections[-1])-1))
addition.push_front(Prev_dir_Opp)
Individual_Steps.push_front(addition)
print(Individual_Steps)
func WhatMove():
if Detail_Dict.Been_There == true:
@@ -190,7 +252,6 @@ func BackTracking():
GoBack(TrackBack)
print(TrackBack)
func Circling():
if Been_There_Array.size() > 3:
if move_check5 != move:
@@ -213,6 +274,7 @@ func Circling():
for ints in CircleIntsMax+1:
Tree_Array.pop_back()
Tree_Array[-1] -= 1
Ordered_Commands_Backward.clear()
print(Tree_Array)
if CircleInts != 0:
@@ -278,7 +340,6 @@ func Goto():
FirstIntChange()
print("Needs More WORK!!!!!!!")
print("First Go To is : ",FirstGoTo)
func FirstIntChange():
FirstGoTo.append_array(Ordered_Commands_Backward)
@@ -289,7 +350,6 @@ func FirstIntChange():
GoBack(FirstGoTo)
print(FirstGoTo)
func CircleRootsAndInts():
if Cicling == true:
if Detail_Dict.Type != "Plain Path":
@@ -329,6 +389,8 @@ func FinishCircling():
Tree_Array.pop_back()
Tree_Array[-1] -= 1
print(Tree_Array)
print(Ordered_Commands_Backward)
Ordered_Commands_Backward.clear()
Move_Check10 = move
func DeadEndCircles():
@@ -357,14 +419,12 @@ func CircleManualDistance():
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
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:
@@ -399,7 +459,6 @@ func CheckForTreeDeadEnds():
else:
pass
func GiveOrder():
if Cicling == false:
Ordered_Commands_Backward.erase("")
@@ -423,7 +482,7 @@ func TrackIntersections():
Intersections.push_back(Current_Position)
var Intersections_Copy = Intersections.duplicate(true)
Intersections = Intersections_Copy
func MoveAfterIntersection():
if move == IntersectionMove+1:
if Move_Check6 != move and Cicling == false:
@@ -456,7 +515,7 @@ func MoveAfterIntersection():
#print(IntOptions)
#print(Intersections)
Move_Check6 = move
func IntersectionDumping():
if CurrentInt != "Plain Path" and Detail_Dict.Type != "Dead End" and Been_There_Array.size() >=1:
if Move_Check9 != move or Been_There_Array[-1] == true:
@@ -494,12 +553,6 @@ func IntersectionWaysAvailable():
#print(IntOptions)
pass
Move_Check7 = move
func BackToStart():
if Detail_Dict.Type == "Plain Path":
Individual_Steps.push_front(Ordered_Commands_Backward)
Individual_Steps_Opp.push_front(Ordered_Commands_Forward)
func Been_There():
if Been_There_Overide == false:
@@ -512,8 +565,6 @@ func Been_There():
Traveled = true
Been_There_Array.push_back(Traveled)
func GoBack(Set):
AutoBacktrack = true
for n in Set:
@@ -533,6 +584,126 @@ func IntersectionCounter():
pass
return WaysToGo
#***** Helpers *****
func RaycastHelper():
var R: bool = $Rightv.is_colliding()
var L: bool = $Leftv.is_colliding()
var D: bool = $Forwardv.is_colliding()
var U: bool = $Backv.is_colliding()
return [R,L,U,D]
func TypeOfIntersectionHelper():
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
return "BlanketIntersection"
else:
return "OneDirectionPath"
#***** Movement *****
func goDown():
var D = $Forwardv
dir = Vector2.DOWN
FullCount += 1
if not D.is_colliding():
self.global_position.y += 24
Current_Position[1] -=1
Prev_dir = "D"
Prev_dir_Opp = "U"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something below you")
func goUp():
var U = $Backv
dir = Vector2.UP
if not U.is_colliding():
self.global_position.y -= 24
Current_Position[1] +=1
Prev_dir = "U"
Prev_dir_Opp = "D"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something above you")
#BeenTheirFromPrevCord()
FullCount += 1
func goRight():
var R = $Rightv
dir = Vector2.RIGHT
if not R.is_colliding():
self.global_position.x += 24.4
Current_Position[0] +=1
Prev_dir = "R"
Prev_dir_Opp = "L"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something to your right")
FullCount += 1
func goLeft():
var L = $Leftv
dir = Vector2.LEFT
if not L.is_colliding():
self.global_position.x -= 24.4
Current_Position[0] -=1
Prev_dir = "L"
Prev_dir_Opp = "R"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something to your left")
FullCount += 1
#***** Auto Movement *****
func Move(SetDirection):
if SetDirection == "R":
self.global_position.x += 24.4
Current_Position[0] +=1
Prev_dir = "R"
Prev_dir_Opp = "L"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "L":
self.global_position.x -= 24.4
Current_Position[0] -=1
Prev_dir = "L"
Prev_dir_Opp = "R"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "D":
self.global_position.y += 24
Current_Position[1] -=1
Prev_dir = "D"
Prev_dir_Opp = "U"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "U":
self.global_position.y -= 24
Current_Position[1] +=1
Prev_dir = "U"
Prev_dir_Opp = "D"
move += Move_Strength
Been_There()
FullCount += 1
func AutoSolve():
var DirectionStrengths = [6,6,5,6]
@@ -578,126 +749,3 @@ func AutoSolve():
print(DirectionStrengths)
print("The Direction with the lowest points is ", DirArray[HighestPoints], "!")
Move(DirArray[HighestPoints])
#***** Helpers *****
func RaycastHelper():
var R: bool = $Rightv.is_colliding()
var L: bool = $Leftv.is_colliding()
var D: bool = $Forwardv.is_colliding()
var U: bool = $Backv.is_colliding()
return [R,L,U,D]
func TypeOfIntersectionHelper():
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
return "BlanketIntersection"
else:
return "OneDirectionPath"
#***** Movement *****
func goDown():
var D = $Forwardv
dir = Vector2.DOWN
FullCount += 1
if not D.is_colliding():
self.global_position.y += 24
Current_Position[1] -=1
Prev_dir = "D"
Prev_dir_Opp = "U"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something below you")
func goUp():
var U = $Backv
dir = Vector2.UP
if not U.is_colliding():
self.global_position.y -= 24
Current_Position[1] +=1
Prev_dir = "U"
Prev_dir_Opp = "D"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something above you")
#BeenTheirFromPrevCord()
FullCount += 1
func goRight():
var R = $Rightv
dir = Vector2.RIGHT
if not R.is_colliding():
self.global_position.x += 24.4
Current_Position[0] +=1
Prev_dir = "R"
Prev_dir_Opp = "L"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something to your right")
FullCount += 1
func goLeft():
var L = $Leftv
dir = Vector2.LEFT
if not L.is_colliding():
self.global_position.x -= 24.4
Current_Position[0] -=1
Prev_dir = "L"
Prev_dir_Opp = "R"
move += Move_Strength
Been_There_Overide = false
else:
Been_There_Overide = true
move += Move_Strength
print("There is something to your left")
FullCount += 1
#***** Auto Movement *****
func Move(SetDirection):
if SetDirection == "R":
self.global_position.x += 24.4
Current_Position[0] +=1
Prev_dir = "R"
Prev_dir_Opp = "L"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "L":
self.global_position.x -= 24.4
Current_Position[0] -=1
Prev_dir = "L"
Prev_dir_Opp = "R"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "D":
self.global_position.y += 24
Current_Position[1] -=1
Prev_dir = "D"
Prev_dir_Opp = "U"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "U":
self.global_position.y -= 24
Current_Position[1] +=1
Prev_dir = "U"
Prev_dir_Opp = "D"
move += Move_Strength
Been_There()
FullCount += 1