Done with Circles!!!!!! Circles are solves and Recall func is solved. Gonna start on multi solving algo!!!
This commit is contained in:
176
PlayerScript.gd
176
PlayerScript.gd
@@ -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):
|
||||
@@ -148,6 +161,55 @@ func Mark(Prev_Direction):
|
||||
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:
|
||||
if state4 != 1:
|
||||
@@ -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:
|
||||
@@ -279,7 +341,6 @@ func Goto():
|
||||
print("Needs More WORK!!!!!!!")
|
||||
print("First Go To is : ",FirstGoTo)
|
||||
|
||||
|
||||
func FirstIntChange():
|
||||
FirstGoTo.append_array(Ordered_Commands_Backward)
|
||||
FirstGoTo.push_back(Prev_dir_Opp)
|
||||
@@ -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,7 +419,6 @@ 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
|
||||
|
||||
@@ -365,7 +426,6 @@ func ManualDistance(Start, End):
|
||||
var y = abs(Starting_Pos[1] - Ending_Pos[1])
|
||||
return x+y
|
||||
|
||||
|
||||
func Intersection_Tree():
|
||||
if Cicling == false:
|
||||
if Detail_Dict.Been_There == false:
|
||||
@@ -399,7 +459,6 @@ func CheckForTreeDeadEnds():
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
func GiveOrder():
|
||||
if Cicling == false:
|
||||
Ordered_Commands_Backward.erase("")
|
||||
@@ -495,12 +554,6 @@ func IntersectionWaysAvailable():
|
||||
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:
|
||||
if Cords.find(Current_Position) == -1:
|
||||
@@ -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,52 +584,6 @@ func IntersectionCounter():
|
||||
pass
|
||||
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 *****
|
||||
|
||||
func RaycastHelper():
|
||||
@@ -588,7 +593,6 @@ func RaycastHelper():
|
||||
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"
|
||||
@@ -613,7 +617,6 @@ func goDown():
|
||||
move += Move_Strength
|
||||
print("There is something below you")
|
||||
|
||||
|
||||
func goUp():
|
||||
var U = $Backv
|
||||
dir = Vector2.UP
|
||||
@@ -664,8 +667,8 @@ func goLeft():
|
||||
FullCount += 1
|
||||
|
||||
#***** Auto Movement *****
|
||||
|
||||
func Move(SetDirection):
|
||||
|
||||
if SetDirection == "R":
|
||||
self.global_position.x += 24.4
|
||||
Current_Position[0] +=1
|
||||
@@ -701,3 +704,48 @@ func Move(SetDirection):
|
||||
move += Move_Strength
|
||||
Been_There()
|
||||
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])
|
||||
|
||||
Reference in New Issue
Block a user