Slight Refactor and helper functions
This commit is contained in:
@@ -9,7 +9,10 @@ var Cords = [[0,0]]
|
|||||||
var Cords_Copy = []
|
var Cords_Copy = []
|
||||||
var Intersections = [[]]
|
var Intersections = [[]]
|
||||||
var Intersections_Copy = []
|
var Intersections_Copy = []
|
||||||
|
var RightCast
|
||||||
|
var LeftCast
|
||||||
|
var UpCast
|
||||||
|
var DownCast
|
||||||
var Moves_From_Last_Intersection = []
|
var Moves_From_Last_Intersection = []
|
||||||
var Moves_From_Last_Intersection_Copy = []
|
var Moves_From_Last_Intersection_Copy = []
|
||||||
var Back_From_DeadEnd = []
|
var Back_From_DeadEnd = []
|
||||||
@@ -99,6 +102,8 @@ var IntersectionDict = {"Cord": [],
|
|||||||
var IntersectionDir = []
|
var IntersectionDir = []
|
||||||
var IntersectionMove = 0
|
var IntersectionMove = 0
|
||||||
var IntOptions = []
|
var IntOptions = []
|
||||||
|
var CurrentInt = ""
|
||||||
|
var AmIBacktracking = false
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if Current_Position != TargetCord:
|
if Current_Position != TargetCord:
|
||||||
@@ -132,6 +137,7 @@ func _input(event):
|
|||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if Current_Position != TargetCord:
|
if Current_Position != TargetCord:
|
||||||
|
CallableRaycastData()
|
||||||
Mark(Prev_dir)
|
Mark(Prev_dir)
|
||||||
WhatMove()
|
WhatMove()
|
||||||
BackTracking()
|
BackTracking()
|
||||||
@@ -146,6 +152,7 @@ func _process(delta):
|
|||||||
MoveAfterIntersection()
|
MoveAfterIntersection()
|
||||||
IntersectionWaysAvailable()
|
IntersectionWaysAvailable()
|
||||||
IntersectionDumping()
|
IntersectionDumping()
|
||||||
|
#print(Been_There_Array)
|
||||||
#BeenTheirFromPrevCord()
|
#BeenTheirFromPrevCord()
|
||||||
#print(AutoBacktrack)var IntersectionDict = {
|
#print(AutoBacktrack)var IntersectionDict = {
|
||||||
#CircleComplete()
|
#CircleComplete()
|
||||||
@@ -413,7 +420,6 @@ func GiveOrder():
|
|||||||
return test
|
return test
|
||||||
move_check = move
|
move_check = move
|
||||||
|
|
||||||
|
|
||||||
func TrackIntersections():
|
func TrackIntersections():
|
||||||
if Intersections.find(Current_Position) == -1:
|
if Intersections.find(Current_Position) == -1:
|
||||||
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
|
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
|
||||||
@@ -431,14 +437,31 @@ func MoveAfterIntersection():
|
|||||||
#print(Intersections)
|
#print(Intersections)
|
||||||
#print(IntersectionDir)
|
#print(IntersectionDir)
|
||||||
Move_Check6 = move
|
Move_Check6 = move
|
||||||
#Omggggggggggggggggggggggggggggggggggggggg
|
|
||||||
func IntersectionDumping():
|
func IntersectionDumping():
|
||||||
if Move_Check9 != move:
|
if CurrentInt != "Plain Path" and Detail_Dict.Type != "Dead End":
|
||||||
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
|
if Move_Check9 != move or Been_There_Array[-1] == true:
|
||||||
IntersectionMove = move
|
IntersectionMove = move
|
||||||
IntersectionDump.push_back(Current_Position)
|
IntersectionDump.push_back(Current_Position)
|
||||||
|
var Dupe = IntersectionDump.duplicate(true)
|
||||||
|
IntersectionDump = Dupe
|
||||||
print(IntersectionDump)
|
print(IntersectionDump)
|
||||||
Move_Check9 = move
|
Move_Check9 = move
|
||||||
|
|
||||||
|
func CallableRaycastData():
|
||||||
|
RightCast = $Rightv.is_colliding()
|
||||||
|
LeftCast = $Leftv.is_colliding()
|
||||||
|
DownCast = $Forwardv.is_colliding()
|
||||||
|
UpCast = $Backv.is_colliding()
|
||||||
|
var count = 0
|
||||||
|
|
||||||
|
var array = [RightCast,LeftCast,UpCast,DownCast]
|
||||||
|
for n in array:
|
||||||
|
if n == false:
|
||||||
|
count += 1
|
||||||
|
CurrentInt = ways[count]
|
||||||
|
#print(CurrentInt)
|
||||||
|
|
||||||
|
|
||||||
func IntersectionWaysAvailable():
|
func IntersectionWaysAvailable():
|
||||||
var R: bool = $Rightv.is_colliding()
|
var R: bool = $Rightv.is_colliding()
|
||||||
@@ -490,7 +513,6 @@ func GoBack(Set):
|
|||||||
for n in Set:
|
for n in Set:
|
||||||
Move(n)
|
Move(n)
|
||||||
|
|
||||||
|
|
||||||
func IntersectionCounter():
|
func IntersectionCounter():
|
||||||
var R: bool = $Rightv.is_colliding()
|
var R: bool = $Rightv.is_colliding()
|
||||||
var L: bool = $Leftv.is_colliding()
|
var L: bool = $Leftv.is_colliding()
|
||||||
@@ -504,11 +526,9 @@ func IntersectionCounter():
|
|||||||
if Direction == true:
|
if Direction == true:
|
||||||
pass
|
pass
|
||||||
return WaysToGo
|
return WaysToGo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
@@ -524,6 +544,7 @@ func Move(SetDirection):
|
|||||||
Prev_dir_Opp = "R"
|
Prev_dir_Opp = "R"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
|
|
||||||
if SetDirection == "D":
|
if SetDirection == "D":
|
||||||
self.global_position.y += 24
|
self.global_position.y += 24
|
||||||
Current_Position[1] -=1
|
Current_Position[1] -=1
|
||||||
@@ -531,6 +552,7 @@ func Move(SetDirection):
|
|||||||
Prev_dir_Opp = "U"
|
Prev_dir_Opp = "U"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
|
|
||||||
if SetDirection == "U":
|
if SetDirection == "U":
|
||||||
self.global_position.y -= 24
|
self.global_position.y -= 24
|
||||||
Current_Position[1] +=1
|
Current_Position[1] +=1
|
||||||
@@ -538,7 +560,6 @@ func Move(SetDirection):
|
|||||||
Prev_dir_Opp = "D"
|
Prev_dir_Opp = "D"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
#print(Current_Position)
|
|
||||||
|
|
||||||
|
|
||||||
func AutoSolve():
|
func AutoSolve():
|
||||||
@@ -576,9 +597,6 @@ func AutoSolve():
|
|||||||
if Intersections.find(i) != -1:
|
if Intersections.find(i) != -1:
|
||||||
DirectionStrengths[n] -= 100
|
DirectionStrengths[n] -= 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AutoBacktrack = false
|
AutoBacktrack = false
|
||||||
var HighestPoints = DirectionStrengths.find(max(DirectionStrengths[0],DirectionStrengths[1],DirectionStrengths[2],DirectionStrengths[3]))
|
var HighestPoints = DirectionStrengths.find(max(DirectionStrengths[0],DirectionStrengths[1],DirectionStrengths[2],DirectionStrengths[3]))
|
||||||
#print(DirArray[HighestPoints])
|
#print(DirArray[HighestPoints])
|
||||||
|
|||||||
Reference in New Issue
Block a user