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 LogDumpOrdered = []
var Order = [] var Order = []
var Intersections_from_root = [] 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 CircleCompleted = null
var AutoBacktrack = false var AutoBacktrack = false
var IntersectionDict = {"Cord": [], "Data": [] } var IntersectionDict = {"Cord": [], "Data": [] }
@@ -115,6 +115,7 @@ func _process(delta):
IntersectionDumping() IntersectionDumping()
CordsDumping() CordsDumping()
FinishCircling() FinishCircling()
#print(Detail_Dict.Type)
#print(Ordered_Commands_Backward) #print(Ordered_Commands_Backward)
#print(InverNext) #print(InverNext)
#print(CordsDump) #print(CordsDump)
@@ -134,6 +135,18 @@ func _process(delta):
print() print()
print() 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 Done = 1
func Mark(Prev_Direction): func Mark(Prev_Direction):
@@ -148,6 +161,55 @@ func Mark(Prev_Direction):
var Coordinate_Dict_Copy = Coordinate_Dict.duplicate(true) var Coordinate_Dict_Copy = Coordinate_Dict.duplicate(true)
Coordinate_Dict = Coordinate_Dict_Copy 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(): func WhatMove():
if Detail_Dict.Been_There == true: if Detail_Dict.Been_There == true:
if state4 != 1: if state4 != 1:
@@ -190,7 +252,6 @@ func BackTracking():
GoBack(TrackBack) GoBack(TrackBack)
print(TrackBack) print(TrackBack)
func Circling(): func Circling():
if Been_There_Array.size() > 3: if Been_There_Array.size() > 3:
if move_check5 != move: if move_check5 != move:
@@ -213,6 +274,7 @@ func Circling():
for ints in CircleIntsMax+1: for ints in CircleIntsMax+1:
Tree_Array.pop_back() Tree_Array.pop_back()
Tree_Array[-1] -= 1 Tree_Array[-1] -= 1
Ordered_Commands_Backward.clear()
print(Tree_Array) print(Tree_Array)
if CircleInts != 0: if CircleInts != 0:
@@ -279,7 +341,6 @@ func Goto():
print("Needs More WORK!!!!!!!") print("Needs More WORK!!!!!!!")
print("First Go To is : ",FirstGoTo) print("First Go To is : ",FirstGoTo)
func FirstIntChange(): func FirstIntChange():
FirstGoTo.append_array(Ordered_Commands_Backward) FirstGoTo.append_array(Ordered_Commands_Backward)
FirstGoTo.push_back(Prev_dir_Opp) FirstGoTo.push_back(Prev_dir_Opp)
@@ -289,7 +350,6 @@ func FirstIntChange():
GoBack(FirstGoTo) GoBack(FirstGoTo)
print(FirstGoTo) print(FirstGoTo)
func CircleRootsAndInts(): func CircleRootsAndInts():
if Cicling == true: if Cicling == true:
if Detail_Dict.Type != "Plain Path": if Detail_Dict.Type != "Plain Path":
@@ -329,6 +389,8 @@ func FinishCircling():
Tree_Array.pop_back() Tree_Array.pop_back()
Tree_Array[-1] -= 1 Tree_Array[-1] -= 1
print(Tree_Array) print(Tree_Array)
print(Ordered_Commands_Backward)
Ordered_Commands_Backward.clear()
Move_Check10 = move Move_Check10 = move
func DeadEndCircles(): func DeadEndCircles():
@@ -357,14 +419,12 @@ func CircleManualDistance():
return x+y return x+y
func ManualDistance(Start, End): func ManualDistance(Start, End):
if DeadEndCircles() == true and Intersections_from_root.size() >= 2: var Starting_Pos = Start
var Starting_Pos = Start var Ending_Pos = End
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 x = abs(Starting_Pos[0] - Ending_Pos[0])
var y = abs(Starting_Pos[1] - Ending_Pos[1])
return x+y
func Intersection_Tree(): func Intersection_Tree():
if Cicling == false: if Cicling == false:
@@ -399,7 +459,6 @@ func CheckForTreeDeadEnds():
else: else:
pass pass
func GiveOrder(): func GiveOrder():
if Cicling == false: if Cicling == false:
Ordered_Commands_Backward.erase("") Ordered_Commands_Backward.erase("")
@@ -495,12 +554,6 @@ func IntersectionWaysAvailable():
pass pass
Move_Check7 = move 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(): func Been_There():
if Been_There_Overide == false: if Been_There_Overide == false:
if Cords.find(Current_Position) == -1: if Cords.find(Current_Position) == -1:
@@ -512,8 +565,6 @@ func Been_There():
Traveled = true Traveled = true
Been_There_Array.push_back(Traveled) Been_There_Array.push_back(Traveled)
func GoBack(Set): func GoBack(Set):
AutoBacktrack = true AutoBacktrack = true
for n in Set: for n in Set:
@@ -533,52 +584,6 @@ func IntersectionCounter():
pass pass
return WaysToGo return WaysToGo
func AutoSolve():
var DirectionStrengths = [6,6,5,6]
var Colliders = RaycastHelper()
var DirArray = ["R","L","U","D"]
var DumpDuplicate = LogDump
var cp = Current_Position
var OptionArrays = [[cp[0],cp[1]+1],[cp[0],cp[1]-1],[cp[0]+1,cp[1]],[cp[0]-1,cp[1]]]
for n in DirectionStrengths.size():
var MoveScore = DumpDuplicate.rfind(DirArray[n])
if Colliders[n] == true:
DirectionStrengths[n] -= 1000
if DirArray.find(Prev_dir_Opp) == n:
DirectionStrengths[n] -= 50
if Individual_Steps.size() < 1 and Ordered_Commands_Backward.size() > 1:
if Ordered_Commands_Backward[0] == DirArray[n]:
DirectionStrengths[n] -= 25
elif Individual_Steps.size() >= 1:
var Wayback = Individual_Steps[0]
if Wayback[0] == DirArray[n]:
DirectionStrengths[n] -= 25
if MoveScore < 15:
DirectionStrengths[n] -= MoveScore
if Intersections.find(Current_Position) != -1:
var Set = Intersections.find(Current_Position) -1
#print(IntOptions[Set])
#print(IntOptions)
#print(Set)
if IntOptions[Set].find(DirArray[n]) == -1:
DirectionStrengths[n] -= 1000
for i in OptionArrays:
if Intersections.find(i) != -1:
DirectionStrengths[n] -= 500
#if Cicling == true:
# print("ITS CIRCLING DO SOME MODS")
# print(IntOptions )
AutoBacktrack = false
var HighestPoints = DirectionStrengths.find(max(DirectionStrengths[0],DirectionStrengths[1],DirectionStrengths[2],DirectionStrengths[3]))
print(DirectionStrengths)
print("The Direction with the lowest points is ", DirArray[HighestPoints], "!")
Move(DirArray[HighestPoints])
#***** Helpers ***** #***** Helpers *****
func RaycastHelper(): func RaycastHelper():
@@ -588,7 +593,6 @@ func RaycastHelper():
var U: bool = $Backv.is_colliding() var U: bool = $Backv.is_colliding()
return [R,L,U,D] return [R,L,U,D]
func TypeOfIntersectionHelper(): func TypeOfIntersectionHelper():
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End": if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
return "BlanketIntersection" return "BlanketIntersection"
@@ -613,7 +617,6 @@ func goDown():
move += Move_Strength move += Move_Strength
print("There is something below you") print("There is something below you")
func goUp(): func goUp():
var U = $Backv var U = $Backv
dir = Vector2.UP dir = Vector2.UP
@@ -664,8 +667,8 @@ func goLeft():
FullCount += 1 FullCount += 1
#***** Auto Movement ***** #***** Auto Movement *****
func Move(SetDirection): func Move(SetDirection):
if SetDirection == "R": if SetDirection == "R":
self.global_position.x += 24.4 self.global_position.x += 24.4
Current_Position[0] +=1 Current_Position[0] +=1
@@ -701,3 +704,48 @@ func Move(SetDirection):
move += Move_Strength move += Move_Strength
Been_There() Been_There()
FullCount += 1 FullCount += 1
func AutoSolve():
var DirectionStrengths = [6,6,5,6]
var Colliders = RaycastHelper()
var DirArray = ["R","L","U","D"]
var DumpDuplicate = LogDump
var cp = Current_Position
var OptionArrays = [[cp[0],cp[1]+1],[cp[0],cp[1]-1],[cp[0]+1,cp[1]],[cp[0]-1,cp[1]]]
for n in DirectionStrengths.size():
var MoveScore = DumpDuplicate.rfind(DirArray[n])
if Colliders[n] == true:
DirectionStrengths[n] -= 1000
if DirArray.find(Prev_dir_Opp) == n:
DirectionStrengths[n] -= 50
if Individual_Steps.size() < 1 and Ordered_Commands_Backward.size() > 1:
if Ordered_Commands_Backward[0] == DirArray[n]:
DirectionStrengths[n] -= 25
elif Individual_Steps.size() >= 1:
var Wayback = Individual_Steps[0]
if Wayback[0] == DirArray[n]:
DirectionStrengths[n] -= 25
if MoveScore < 15:
DirectionStrengths[n] -= MoveScore
if Intersections.find(Current_Position) != -1:
var Set = Intersections.find(Current_Position) -1
#print(IntOptions[Set])
#print(IntOptions)
#print(Set)
if IntOptions[Set].find(DirArray[n]) == -1:
DirectionStrengths[n] -= 1000
for i in OptionArrays:
if Intersections.find(i) != -1:
DirectionStrengths[n] -= 500
#if Cicling == true:
# print("ITS CIRCLING DO SOME MODS")
# print(IntOptions )
AutoBacktrack = false
var HighestPoints = DirectionStrengths.find(max(DirectionStrengths[0],DirectionStrengths[1],DirectionStrengths[2],DirectionStrengths[3]))
print(DirectionStrengths)
print("The Direction with the lowest points is ", DirArray[HighestPoints], "!")
Move(DirArray[HighestPoints])

File diff suppressed because one or more lines are too long