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