|
|
|
|
@@ -87,57 +87,65 @@ var RouteCounter = 0
|
|
|
|
|
var SendToRobo = []
|
|
|
|
|
var RetraveledArray = []
|
|
|
|
|
var Ori = 0
|
|
|
|
|
var Orientations = []
|
|
|
|
|
var amnt = 0
|
|
|
|
|
func _input(event):
|
|
|
|
|
#if Current_Position != TargetCord:
|
|
|
|
|
if event.is_action_pressed("ui_left"):
|
|
|
|
|
goLeft()
|
|
|
|
|
LeftTurn()
|
|
|
|
|
Been_There()
|
|
|
|
|
AutoBacktrack = false
|
|
|
|
|
elif event.is_action_pressed("ui_right"):
|
|
|
|
|
goRight()
|
|
|
|
|
RightTurn()
|
|
|
|
|
Been_There()
|
|
|
|
|
AutoBacktrack = false
|
|
|
|
|
elif event.is_action_pressed("ui_up"):
|
|
|
|
|
goUp()
|
|
|
|
|
Been_There()
|
|
|
|
|
AutoBacktrack = false
|
|
|
|
|
elif event.is_action_pressed("ui_down"):
|
|
|
|
|
#goDown()
|
|
|
|
|
goingForward()
|
|
|
|
|
goDown()
|
|
|
|
|
Been_There()
|
|
|
|
|
AutoBacktrack = false
|
|
|
|
|
elif event.is_action_pressed("ui_accept"):
|
|
|
|
|
AutoSolve()
|
|
|
|
|
|
|
|
|
|
#AutoSolve()
|
|
|
|
|
$Sprite2D.rotation_degrees += 180
|
|
|
|
|
$Backv.rotation_degrees += 180
|
|
|
|
|
$Forwardv.rotation_degrees += 180
|
|
|
|
|
$Leftv.rotation_degrees += 180
|
|
|
|
|
$Rightv.rotation_degrees += 180
|
|
|
|
|
Ori += 180
|
|
|
|
|
|
|
|
|
|
elif event.is_action_pressed("ui_text_backspace"):
|
|
|
|
|
print(Ordered_Commands_Backward)
|
|
|
|
|
print()
|
|
|
|
|
print(Individual_Steps)
|
|
|
|
|
print("**********************************")
|
|
|
|
|
print()
|
|
|
|
|
print(Tree_Array)
|
|
|
|
|
print(SendToRobo)
|
|
|
|
|
print(Current_Position)
|
|
|
|
|
var arr1 = [['apple', 'orange', 'banana', 'pear', 'fish', 'pancake', 'taco', 'pizza'],['banana', 'pizza', 'fish', 'apple'],['taco', 'fish', 'apple', 'pizza']]
|
|
|
|
|
var arr2 = AllSetsToGoal
|
|
|
|
|
CommonsSort(arr1)
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
|
#FoundGoal()
|
|
|
|
|
#AllObjectsFound()
|
|
|
|
|
Circling()
|
|
|
|
|
CallableRaycastData()
|
|
|
|
|
Mark(Prev_dir)
|
|
|
|
|
WhatMove()
|
|
|
|
|
BackTracking()
|
|
|
|
|
GiveOrder()
|
|
|
|
|
Intersection_Tree()
|
|
|
|
|
|
|
|
|
|
Circling()
|
|
|
|
|
CheckForTreeDeadEnds()
|
|
|
|
|
TravelLog()
|
|
|
|
|
DeadEndCircles()
|
|
|
|
|
CircleRootsAndInts()
|
|
|
|
|
SolvinCircleDeadEnds()
|
|
|
|
|
#MoveAfterIntersection()
|
|
|
|
|
MoveAfterIntersection()
|
|
|
|
|
IntersectionWaysAvailable()
|
|
|
|
|
IntersectionDumping()
|
|
|
|
|
CordsDumping()
|
|
|
|
|
FinishCircling()
|
|
|
|
|
#print(TrackBack)
|
|
|
|
|
#print(Tree_Array)
|
|
|
|
|
#print(LogDump)
|
|
|
|
|
#print(Orientations)
|
|
|
|
|
#Orienting()
|
|
|
|
|
#print(Current_Position)
|
|
|
|
|
#print(Ordered_Commands_Backward)
|
|
|
|
|
#print(Individual_Steps)
|
|
|
|
|
func FoundGoal():
|
|
|
|
|
if TargetCord.find(Cords[-1]) != -1 and TargetsArray.find(Cords[-1]) == -1:
|
|
|
|
|
Goal = true
|
|
|
|
|
@@ -359,7 +367,6 @@ func CirclingParody():
|
|
|
|
|
if Cicling == false:
|
|
|
|
|
print("Found Ya!!!")
|
|
|
|
|
print(ManualDistance(Current_Position, Intersections[-1]))
|
|
|
|
|
#Current_Position[0] +=1
|
|
|
|
|
var addition = []
|
|
|
|
|
addition.append_array(LogDump.slice(0,ManualDistance(Current_Position,Intersections[-1])-1))
|
|
|
|
|
addition.push_front(Prev_dir_Opp)
|
|
|
|
|
@@ -405,23 +412,22 @@ func BackTracking():
|
|
|
|
|
if Cicling == false:
|
|
|
|
|
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Been_There == false:
|
|
|
|
|
if BackTrack_Array.find(move) == -1:
|
|
|
|
|
print("GO TIME")
|
|
|
|
|
BackTrack_Array.push_back(move)
|
|
|
|
|
if Intersections.find(Current_Position) == -1 and Intersections.find(Current_Position) != Intersections.size() -1 and BackTrack_Array.size() >= 2:
|
|
|
|
|
TrackBack = GiveOrder()
|
|
|
|
|
#Individual_Steps_Opp.push_back(Ordered_Commands_Forward)
|
|
|
|
|
Individual_Steps_Opp.push_back(Ordered_Commands_Forward)
|
|
|
|
|
#print(TrackBack)
|
|
|
|
|
Distance_From_Intersection = BackTrack_Array[-1] - BackTrack_Array[-2]
|
|
|
|
|
print("The distance from the last intersection is : ", Distance_From_Intersection)
|
|
|
|
|
print("To get to the last intersection follow these steps : ", TrackBack)
|
|
|
|
|
#Individual_Steps.push_front(TrackBack)
|
|
|
|
|
if Detail_Dict.Type == "Dead End" and Current_Position != [0,0]:
|
|
|
|
|
FlipAround()
|
|
|
|
|
print("Done Flipping")
|
|
|
|
|
print("Moving")
|
|
|
|
|
FullReverseTurn()
|
|
|
|
|
print("Done reverse")
|
|
|
|
|
GoBack(TrackBack)
|
|
|
|
|
GoBack(TrackBack)
|
|
|
|
|
print(TrackBack)
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
Tree_Array[-1] -= 1
|
|
|
|
|
print("Done")
|
|
|
|
|
|
|
|
|
|
func Circling():
|
|
|
|
|
if Been_There_Array.size() > 3:
|
|
|
|
|
@@ -435,17 +441,11 @@ func Circling():
|
|
|
|
|
HowManyIntsInCircle()
|
|
|
|
|
if CircleInts == 0:
|
|
|
|
|
print("This Circle is exhausted go back")
|
|
|
|
|
print(Individual_Steps)
|
|
|
|
|
print(CircleIntsMax)
|
|
|
|
|
for n in CircleIntsMax:
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
FlipAround()
|
|
|
|
|
print(Individual_Steps[0])
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
FlipAround()
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
#print(Individual_Steps)
|
|
|
|
|
print(Individual_Steps)
|
|
|
|
|
Cicling = false
|
|
|
|
|
print("Circling is false!!!!")
|
|
|
|
|
for ints in CircleIntsMax+1:
|
|
|
|
|
@@ -496,14 +496,12 @@ func Skip():
|
|
|
|
|
if CircleInts + 1 == CircleIntsMax:
|
|
|
|
|
FirstIntChange()
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
#Individual_Steps.pop_front()
|
|
|
|
|
print("First Go To is : ",FirstGoTo)
|
|
|
|
|
else:
|
|
|
|
|
for n in 2:
|
|
|
|
|
print("N is equal to: ",n)
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
#Individual_Steps.pop_front()
|
|
|
|
|
print("Needs More WORK!!!!!!!")
|
|
|
|
|
print("First Go To is : ",FirstGoTo)
|
|
|
|
|
@@ -526,9 +524,7 @@ func FirstIntChange():
|
|
|
|
|
FirstGoTo.reverse()
|
|
|
|
|
print(Intersections_from_root)
|
|
|
|
|
print(Ordered_Commands_Backward)
|
|
|
|
|
FlipAround()
|
|
|
|
|
GoBack(FirstGoTo)
|
|
|
|
|
#Orientations[Intersections.find(Current_Position)-1] = Ori
|
|
|
|
|
print(FirstGoTo)
|
|
|
|
|
|
|
|
|
|
func CircleRootsAndInts():
|
|
|
|
|
@@ -551,8 +547,6 @@ func FinishCircling():
|
|
|
|
|
if Current_Position == Intersections[-(CircleIntsMax+1)]:
|
|
|
|
|
Cicling = false
|
|
|
|
|
print("Its On the Root!!!")
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
FlipAround()
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
print(Individual_Steps)
|
|
|
|
|
@@ -562,16 +556,11 @@ func FinishCircling():
|
|
|
|
|
else:
|
|
|
|
|
print("Its Off the Root!!!")
|
|
|
|
|
Cicling = false
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
FlipAround()
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
FlipAround()
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
print("Its On the Root!!!")
|
|
|
|
|
print(Ori)
|
|
|
|
|
print(Individual_Steps)
|
|
|
|
|
for ints in CircleIntsMax+1:
|
|
|
|
|
Tree_Array.pop_back()
|
|
|
|
|
@@ -590,17 +579,10 @@ func DeadEndCircles():
|
|
|
|
|
|
|
|
|
|
func SolvinCircleDeadEnds():
|
|
|
|
|
if CircleManualDistance() != null:
|
|
|
|
|
FlipAround()
|
|
|
|
|
for n in CircleManualDistance() + 1:
|
|
|
|
|
print(LogDump[n])
|
|
|
|
|
for n in CircleManualDistance():
|
|
|
|
|
GoBack(LogDump[n])
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
#print(Intersections.find(Current_Position)-1)
|
|
|
|
|
print(Orientations)
|
|
|
|
|
CircleInts -= 1
|
|
|
|
|
FlipAround()
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Reorient(Intersections.find(Current_Position)-1)
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
print(CircleInts)
|
|
|
|
|
|
|
|
|
|
@@ -623,39 +605,42 @@ func ManualDistance(Start, End):
|
|
|
|
|
|
|
|
|
|
func Intersection_Tree():
|
|
|
|
|
if Cicling == false:
|
|
|
|
|
if Cords.find(Current_Position) == -1 or Cords.find(Current_Position) == Cords.size()-1:
|
|
|
|
|
if Detail_Dict.Been_There == false:
|
|
|
|
|
if Move_Check2 != move:
|
|
|
|
|
if Detail_Dict.Type == "3 Way Intersection" and Current_Position != [0,0] and Prev_dir != "R" and Prev_dir != "L":
|
|
|
|
|
if Detail_Dict.Type == "3 Way Intersection" and Current_Position != [0,0]:
|
|
|
|
|
Tree_Array.push_back(2)
|
|
|
|
|
Individual_Steps.push_front(TrackBack)
|
|
|
|
|
print(Tree_Array)
|
|
|
|
|
print(Intersections)
|
|
|
|
|
if Detail_Dict.Type == "4 Way Intersection" and Current_Position != [0,0] and Prev_dir != "R" and Prev_dir != "L":
|
|
|
|
|
if Detail_Dict.Type == "4 Way Intersection" and Current_Position != [0,0]:
|
|
|
|
|
Tree_Array.push_back(3)
|
|
|
|
|
Individual_Steps.push_front(TrackBack)
|
|
|
|
|
print(Tree_Array)
|
|
|
|
|
print(Intersections)
|
|
|
|
|
if Detail_Dict.Type == "Dead End" and Current_Position != [0,0]:
|
|
|
|
|
Tree_Array[-1] -= 1
|
|
|
|
|
print(Tree_Array)
|
|
|
|
|
print(Intersections)
|
|
|
|
|
Move_Check2 = move
|
|
|
|
|
|
|
|
|
|
func CheckForTreeDeadEnds():
|
|
|
|
|
if Cicling == false:
|
|
|
|
|
if Tree_Array.size() > 0:
|
|
|
|
|
if Tree_Array[-1] <= 0:
|
|
|
|
|
Tree_Array.pop_back()
|
|
|
|
|
FlipAround()
|
|
|
|
|
print("vvvvvv GOING FROM THIS PATH vvvvvv")
|
|
|
|
|
print(Individual_Steps[0])
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Reorient(Intersections.find(Current_Position) -1)
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
Tree_Array[-1] -= 1
|
|
|
|
|
else:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
if Tree_Array.size() > 0:
|
|
|
|
|
if Tree_Array[-1] <= 0:
|
|
|
|
|
Tree_Array.pop_back()
|
|
|
|
|
Tree_Array[-1] -= 1
|
|
|
|
|
print(Tree_Array)
|
|
|
|
|
GoBack(Individual_Steps[0])
|
|
|
|
|
Individual_Steps.pop_front()
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
func GiveOrder():
|
|
|
|
|
if Cicling == false:
|
|
|
|
|
Ordered_Commands_Backward.erase("")
|
|
|
|
|
Ordered_Commands_Forward.erase("")
|
|
|
|
|
#Ordered_Commands_Backward.clear()
|
|
|
|
|
if move_check != move:
|
|
|
|
|
TrackIntersections()
|
|
|
|
|
if Detail_Dict.Been_There == false:
|
|
|
|
|
@@ -669,10 +654,9 @@ func GiveOrder():
|
|
|
|
|
move_check = move
|
|
|
|
|
|
|
|
|
|
func TrackIntersections():
|
|
|
|
|
if Intersections.find(Current_Position) == -1 and Prev_dir != "R" and Prev_dir != "L":
|
|
|
|
|
if Intersections.find(Current_Position) == -1:
|
|
|
|
|
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
|
|
|
|
|
Intersections.push_back(Current_Position)
|
|
|
|
|
Orientations.push_back(Ori)
|
|
|
|
|
var Intersections_Copy = Intersections.duplicate(true)
|
|
|
|
|
Intersections = Intersections_Copy
|
|
|
|
|
|
|
|
|
|
@@ -696,7 +680,15 @@ func MoveAfterIntersection():
|
|
|
|
|
else:
|
|
|
|
|
Invert = false
|
|
|
|
|
|
|
|
|
|
if Invert == true:
|
|
|
|
|
if Invert == true:#print(Direction.find(Dir))
|
|
|
|
|
# if Ori == 0 or Ori == 180:
|
|
|
|
|
# print("YYYYYYY")
|
|
|
|
|
# if Ori == 0:
|
|
|
|
|
# print("Same/Normal Orientation")
|
|
|
|
|
# print(Dir)
|
|
|
|
|
# if Ori == 180:
|
|
|
|
|
# print("Flipped")
|
|
|
|
|
# print(Direction[Direction.find(Dir)])
|
|
|
|
|
#print(Prev_dir_Opp)
|
|
|
|
|
IntOptions[-1].erase(Prev_dir_Opp)
|
|
|
|
|
#print(IntOptions)
|
|
|
|
|
@@ -749,7 +741,7 @@ func IntersectionWaysAvailable():
|
|
|
|
|
|
|
|
|
|
func Been_There():
|
|
|
|
|
if Been_There_Overide == false:
|
|
|
|
|
if Cords.find(Current_Position) == -1 or Prev_dir == "L" or Prev_dir == "R":
|
|
|
|
|
if Cords.find(Current_Position) == -1 or Prev_dir == "R" or Prev_dir == "L":
|
|
|
|
|
Cords.push_back(Current_Position)
|
|
|
|
|
Cords_Copy = Cords.duplicate(true)
|
|
|
|
|
Cords = Cords_Copy
|
|
|
|
|
@@ -761,7 +753,6 @@ func Been_There():
|
|
|
|
|
func GoBack(Set):
|
|
|
|
|
AutoBacktrack = true
|
|
|
|
|
for n in Set:
|
|
|
|
|
#await get_tree().create_timer(.25).timeout
|
|
|
|
|
Move(n)
|
|
|
|
|
|
|
|
|
|
func RGoBack(Set):
|
|
|
|
|
@@ -802,9 +793,9 @@ func OppData(array):
|
|
|
|
|
func RaycastHelper():
|
|
|
|
|
var R: bool = $Rightv.is_colliding()
|
|
|
|
|
var L: bool = $Leftv.is_colliding()
|
|
|
|
|
var F: bool = $Forwardv.is_colliding()
|
|
|
|
|
|
|
|
|
|
return [R,L,F]
|
|
|
|
|
var D: bool = $Forwardv.is_colliding()
|
|
|
|
|
var U: bool = $Backv.is_colliding()
|
|
|
|
|
return [R,L,U,D]
|
|
|
|
|
|
|
|
|
|
func FullReverse(data):
|
|
|
|
|
var vars = []
|
|
|
|
|
@@ -896,169 +887,199 @@ func CommonsSort(Arrays):
|
|
|
|
|
return Recount
|
|
|
|
|
|
|
|
|
|
#***** Movement *****
|
|
|
|
|
func FlipAround():
|
|
|
|
|
FixOri("Flip")
|
|
|
|
|
$Sprite2D.rotation_degrees += 180
|
|
|
|
|
$Rightv.rotation_degrees += 180
|
|
|
|
|
$Leftv.rotation_degrees += 180
|
|
|
|
|
$Forwardv.rotation_degrees += 180
|
|
|
|
|
$Backv.rotation_degrees += 180
|
|
|
|
|
|
|
|
|
|
func Reorient(Index):
|
|
|
|
|
print("ORI: ",Ori)
|
|
|
|
|
print("Orienting Array: ", Orientations)
|
|
|
|
|
var subtractor = Ori
|
|
|
|
|
var equ = Orientations[Index]-subtractor
|
|
|
|
|
if equ >= 360:
|
|
|
|
|
equ -= 360
|
|
|
|
|
if equ < 0:
|
|
|
|
|
equ += 360
|
|
|
|
|
if equ == 90:
|
|
|
|
|
Move("R")
|
|
|
|
|
if equ == 270:
|
|
|
|
|
Move("L")
|
|
|
|
|
if equ == 180:
|
|
|
|
|
FlipAround()
|
|
|
|
|
if equ == 0:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
func FixOri(Dir):
|
|
|
|
|
if Dir == "R":
|
|
|
|
|
Ori += 90
|
|
|
|
|
if Dir == "L":
|
|
|
|
|
Ori -= 90
|
|
|
|
|
if Dir == "Flip":
|
|
|
|
|
Ori += 180
|
|
|
|
|
if Ori >= 360:
|
|
|
|
|
Ori -= 360
|
|
|
|
|
if Ori < 0:
|
|
|
|
|
Ori += 360
|
|
|
|
|
|
|
|
|
|
func goForward():
|
|
|
|
|
#if not $Forwardv.is_colliding():
|
|
|
|
|
if Ori == 0:
|
|
|
|
|
self.global_position.y += 24
|
|
|
|
|
Current_Position[1] -=1
|
|
|
|
|
if Ori == 180:
|
|
|
|
|
self.global_position.y -= 24
|
|
|
|
|
Current_Position[1] +=1
|
|
|
|
|
if Ori == 90:
|
|
|
|
|
self.global_position.x -= 24.4
|
|
|
|
|
Current_Position[0] -=1
|
|
|
|
|
if Ori == 270:
|
|
|
|
|
self.global_position.x += 24.4
|
|
|
|
|
Current_Position[0] +=1
|
|
|
|
|
Prev_dir = "F"
|
|
|
|
|
Prev_dir_Opp = "F"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func goingForward():
|
|
|
|
|
func goDown():
|
|
|
|
|
var D = $Forwardv
|
|
|
|
|
dir = Vector2.DOWN
|
|
|
|
|
FullCount += 1
|
|
|
|
|
if not D.is_colliding():
|
|
|
|
|
goForward()
|
|
|
|
|
move += 1
|
|
|
|
|
#self.global_position.y += 24
|
|
|
|
|
#Current_Position[1] -=1
|
|
|
|
|
Prev_dir = "F"
|
|
|
|
|
Prev_dir_Opp = "F"
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
Been_There_Overide = false
|
|
|
|
|
#Ori = 0
|
|
|
|
|
Orienting("D")
|
|
|
|
|
else:
|
|
|
|
|
Ordered_Commands_Backward.pop_back()
|
|
|
|
|
Been_There_Overide = true
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
print("There is something infront of you")
|
|
|
|
|
print("There is something below you")
|
|
|
|
|
|
|
|
|
|
func goRight():
|
|
|
|
|
func goUp():
|
|
|
|
|
var U = $Backv
|
|
|
|
|
dir = Vector2.UP
|
|
|
|
|
if not U.is_colliding():
|
|
|
|
|
#self.global_position.y -= 24
|
|
|
|
|
#Current_Position[1] +=1
|
|
|
|
|
Prev_dir = "F"
|
|
|
|
|
Prev_dir_Opp = "F"
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
Been_There_Overide = false
|
|
|
|
|
#Ori = 180
|
|
|
|
|
Orienting("U")
|
|
|
|
|
else:
|
|
|
|
|
Been_There_Overide = true
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
print("There is something above you")
|
|
|
|
|
#BeenTheirFromPrevCord()
|
|
|
|
|
FullCount += 1
|
|
|
|
|
|
|
|
|
|
func RightTurn():
|
|
|
|
|
var R = $Rightv
|
|
|
|
|
dir = Vector2.RIGHT
|
|
|
|
|
if not R.is_colliding():
|
|
|
|
|
#self.global_position.x += 24.4
|
|
|
|
|
#Current_Position[0] +=1
|
|
|
|
|
$Sprite2D.rotation_degrees += 90
|
|
|
|
|
$Rightv.rotation_degrees += 90
|
|
|
|
|
$Leftv.rotation_degrees += 90
|
|
|
|
|
$Forwardv.rotation_degrees += 90
|
|
|
|
|
$Backv.rotation_degrees += 90
|
|
|
|
|
FixOri("R")
|
|
|
|
|
$Sprite2D.rotation_degrees -= 90
|
|
|
|
|
$Backv.rotation_degrees -= 90
|
|
|
|
|
$Forwardv.rotation_degrees -= 90
|
|
|
|
|
$Leftv.rotation_degrees -= 90
|
|
|
|
|
$Rightv.rotation_degrees -=90
|
|
|
|
|
Prev_dir = "R"
|
|
|
|
|
Prev_dir_Opp = "L"
|
|
|
|
|
move += 1
|
|
|
|
|
#Been_There_Overide = false
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
Been_There_Overide = false
|
|
|
|
|
Ori -= 90
|
|
|
|
|
print(Ori)
|
|
|
|
|
Orienting("R")
|
|
|
|
|
else:
|
|
|
|
|
Been_There_Overide = true
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
print("There is something to your right")
|
|
|
|
|
FullCount += 1
|
|
|
|
|
|
|
|
|
|
func goLeft():
|
|
|
|
|
func LeftTurn():
|
|
|
|
|
var L = $Leftv
|
|
|
|
|
dir = Vector2.LEFT
|
|
|
|
|
if not L.is_colliding():
|
|
|
|
|
#self.global_position.x -= 24.4
|
|
|
|
|
#Current_Position[0] -=1
|
|
|
|
|
$Sprite2D.rotation_degrees -= 90
|
|
|
|
|
$Rightv.rotation_degrees -= 90
|
|
|
|
|
$Leftv.rotation_degrees -= 90
|
|
|
|
|
$Forwardv.rotation_degrees -= 90
|
|
|
|
|
$Backv.rotation_degrees -= 90
|
|
|
|
|
FixOri("L")
|
|
|
|
|
$Sprite2D.rotation_degrees += 90
|
|
|
|
|
$Backv.rotation_degrees += 90
|
|
|
|
|
$Forwardv.rotation_degrees += 90
|
|
|
|
|
$Leftv.rotation_degrees += 90
|
|
|
|
|
$Rightv.rotation_degrees +=90
|
|
|
|
|
Prev_dir = "L"
|
|
|
|
|
Prev_dir_Opp = "R"
|
|
|
|
|
move += 1
|
|
|
|
|
#Been_There_Overide = false
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
Been_There_Overide = false
|
|
|
|
|
Ori += 90
|
|
|
|
|
Orienting("L")
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
Been_There_Overide = true
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
print("There is something to your left")
|
|
|
|
|
FullCount += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Orienting(Dir):
|
|
|
|
|
var Base = [0,90,180,270]
|
|
|
|
|
var Way = ""
|
|
|
|
|
var Default = ["U","D","L","R"]
|
|
|
|
|
var LOrientation = ["R","L","D","U"]
|
|
|
|
|
var ROrientation = ["L","R", "U","D"]
|
|
|
|
|
var BOrientation = ["D","U","R","L"]
|
|
|
|
|
if Ori < 0:
|
|
|
|
|
Ori = 360 + Ori
|
|
|
|
|
if Ori >= 360:
|
|
|
|
|
Ori = Ori - 360
|
|
|
|
|
|
|
|
|
|
#print(Dir)
|
|
|
|
|
#print(Ori)
|
|
|
|
|
if Ori == 270:
|
|
|
|
|
if Dir == "U":
|
|
|
|
|
self.global_position.x -= 24.4
|
|
|
|
|
Current_Position[0] -=1
|
|
|
|
|
if Dir == "D":
|
|
|
|
|
self.global_position.x += 24.4
|
|
|
|
|
Current_Position[0] +=1
|
|
|
|
|
if Dir == "F":
|
|
|
|
|
self.global_position.x += 24.4
|
|
|
|
|
Current_Position[0] +=1
|
|
|
|
|
|
|
|
|
|
if Ori == 180:
|
|
|
|
|
if Dir == "U":
|
|
|
|
|
self.global_position.y += 24
|
|
|
|
|
Current_Position[1] -=1
|
|
|
|
|
if Dir == "D":
|
|
|
|
|
self.global_position.y -= 24
|
|
|
|
|
Current_Position[1] +=1
|
|
|
|
|
if Dir == "F":
|
|
|
|
|
self.global_position.y -= 24
|
|
|
|
|
Current_Position[1] +=1
|
|
|
|
|
|
|
|
|
|
if Ori == 90:
|
|
|
|
|
if Dir == "U":
|
|
|
|
|
self.global_position.x += 24.4
|
|
|
|
|
Current_Position[0] +=1
|
|
|
|
|
if Dir == "D":
|
|
|
|
|
self.global_position.x -= 24.4
|
|
|
|
|
Current_Position[0] -=1
|
|
|
|
|
if Dir == "F":
|
|
|
|
|
self.global_position.x -= 24.4
|
|
|
|
|
Current_Position[0] -=1
|
|
|
|
|
|
|
|
|
|
if Ori == 0:
|
|
|
|
|
if Dir == "U":
|
|
|
|
|
self.global_position.y -= 24
|
|
|
|
|
Current_Position[1] +=1
|
|
|
|
|
if Dir == "D":
|
|
|
|
|
self.global_position.y += 24
|
|
|
|
|
Current_Position[1] -=1
|
|
|
|
|
if Dir == "F":
|
|
|
|
|
self.global_position.y += 24
|
|
|
|
|
Current_Position[1] -=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#***** Auto Movement *****
|
|
|
|
|
func Move(SetDirection):
|
|
|
|
|
|
|
|
|
|
if SetDirection == "R":
|
|
|
|
|
$Sprite2D.rotation_degrees += 90
|
|
|
|
|
$Rightv.rotation_degrees += 90
|
|
|
|
|
$Leftv.rotation_degrees += 90
|
|
|
|
|
$Forwardv.rotation_degrees += 90
|
|
|
|
|
$Backv.rotation_degrees += 90
|
|
|
|
|
FixOri("R")
|
|
|
|
|
$Sprite2D.rotation_degrees -= 90
|
|
|
|
|
$Backv.rotation_degrees -= 90
|
|
|
|
|
$Forwardv.rotation_degrees -= 90
|
|
|
|
|
$Leftv.rotation_degrees -= 90
|
|
|
|
|
$Rightv.rotation_degrees -=90
|
|
|
|
|
Ori -= 90
|
|
|
|
|
Prev_dir = "R"
|
|
|
|
|
Prev_dir_Opp = "L"
|
|
|
|
|
move += 1
|
|
|
|
|
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
Been_There()
|
|
|
|
|
FullCount += 1
|
|
|
|
|
|
|
|
|
|
if SetDirection == "L":
|
|
|
|
|
$Sprite2D.rotation_degrees -= 90
|
|
|
|
|
$Rightv.rotation_degrees -= 90
|
|
|
|
|
$Leftv.rotation_degrees -= 90
|
|
|
|
|
$Forwardv.rotation_degrees -= 90
|
|
|
|
|
$Backv.rotation_degrees -= 90
|
|
|
|
|
FixOri("L")
|
|
|
|
|
$Sprite2D.rotation_degrees += 90
|
|
|
|
|
$Backv.rotation_degrees += 90
|
|
|
|
|
$Forwardv.rotation_degrees += 90
|
|
|
|
|
$Leftv.rotation_degrees += 90
|
|
|
|
|
$Rightv.rotation_degrees +=90
|
|
|
|
|
Ori += 90
|
|
|
|
|
Prev_dir = "L"
|
|
|
|
|
Prev_dir_Opp = "R"
|
|
|
|
|
move += 1
|
|
|
|
|
|
|
|
|
|
if SetDirection == "F":
|
|
|
|
|
goForward()
|
|
|
|
|
move += 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"
|
|
|
|
|
if SetDirection == "F":
|
|
|
|
|
self.global_position.y += 24
|
|
|
|
|
Current_Position[1] -=1
|
|
|
|
|
Prev_dir = "F"
|
|
|
|
|
Prev_dir_Opp = "F"
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
Been_There()
|
|
|
|
|
FullCount += 1
|
|
|
|
|
Been_There()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if SetDirection == "F":
|
|
|
|
|
self.global_position.y -= 24
|
|
|
|
|
Current_Position[1] +=1
|
|
|
|
|
Prev_dir = "F"
|
|
|
|
|
Prev_dir_Opp = "F"
|
|
|
|
|
move += Move_Strength
|
|
|
|
|
Been_There()
|
|
|
|
|
FullCount += 1
|
|
|
|
|
|
|
|
|
|
func RMove(SetDirection):
|
|
|
|
|
|
|
|
|
|
if SetDirection == "R":
|
|
|
|
|
@@ -1097,51 +1118,35 @@ func RMove(SetDirection):
|
|
|
|
|
Been_There()
|
|
|
|
|
FullCount += 1
|
|
|
|
|
|
|
|
|
|
func FullReverseTurn():
|
|
|
|
|
$Sprite2D.rotation_degrees += 180
|
|
|
|
|
$Backv.rotation_degrees += 180
|
|
|
|
|
$Forwardv.rotation_degrees += 180
|
|
|
|
|
$Leftv.rotation_degrees += 180
|
|
|
|
|
$Rightv.rotation_degrees += 180
|
|
|
|
|
Ori += 180
|
|
|
|
|
|
|
|
|
|
func AutoSolve():
|
|
|
|
|
var DirectionStrengths = [6 ,6,12]
|
|
|
|
|
var DirectionStrengths = [6,6,5,6]
|
|
|
|
|
var Colliders = RaycastHelper()
|
|
|
|
|
var DirArray = ["R","L","F"]
|
|
|
|
|
var Turns = ["R","L"]
|
|
|
|
|
var OriChange90 = ["R", "L", "Flip","F"]
|
|
|
|
|
var OriChange270 = ["L", "R","F","Flip"]
|
|
|
|
|
var OriChange0 = ["Flip", "F", "L", "R"]
|
|
|
|
|
var OriChnage180 = ["F","Flip","R","L"]
|
|
|
|
|
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]]]
|
|
|
|
|
var GoOrNot = []
|
|
|
|
|
var Options = ["Above", "Below", "The Right", "The Left"]
|
|
|
|
|
var FoundOrNot = [Cords.find(OptionArrays[0]),Cords.find(OptionArrays[1]),Cords.find(OptionArrays[2]),Cords.find(OptionArrays[3])]
|
|
|
|
|
var ALLORI = [OriChange0,OriChange90,OriChnage180,OriChange270]
|
|
|
|
|
var OriNums = [0,90,180,270]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for n in DirectionStrengths.size():
|
|
|
|
|
var MoveScore = DumpDuplicate.rfind(DirArray[n])
|
|
|
|
|
if Colliders[n] == true:
|
|
|
|
|
DirectionStrengths[n] -= 5000
|
|
|
|
|
if DirArray[n] == "R" or DirArray[n] == "L":
|
|
|
|
|
if Turns.find(Prev_dir) != -1:
|
|
|
|
|
#print("Kill turns")
|
|
|
|
|
DirectionStrengths[n] -= 2500
|
|
|
|
|
#print(FoundOrNot)
|
|
|
|
|
#print(Options)
|
|
|
|
|
#print(ALLORI[OriNums.find(Ori)])
|
|
|
|
|
var Boom = ALLORI[OriNums.find(Ori)]
|
|
|
|
|
var subtracted = []
|
|
|
|
|
for x in FoundOrNot:
|
|
|
|
|
if x != -1:
|
|
|
|
|
subtracted.push_back(Boom[FoundOrNot.find(x)])
|
|
|
|
|
subtracted.erase("Flip")
|
|
|
|
|
for p in subtracted:
|
|
|
|
|
var takeout = DirArray.find(p)
|
|
|
|
|
DirectionStrengths[takeout] -= 1000
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
if Individual_Steps.size() >= 1:
|
|
|
|
|
elif Individual_Steps.size() >= 1:
|
|
|
|
|
var Wayback = Individual_Steps[0]
|
|
|
|
|
if Wayback[0] == DirArray[n]:
|
|
|
|
|
DirectionStrengths[n] -= 25
|
|
|
|
|
@@ -1160,11 +1165,8 @@ func AutoSolve():
|
|
|
|
|
#if Cicling == true:
|
|
|
|
|
# print("ITS CIRCLING DO SOME MODS")
|
|
|
|
|
# print(IntOptions )
|
|
|
|
|
var HighestPoints = DirectionStrengths.find(max(DirectionStrengths[0],DirectionStrengths[1],DirectionStrengths[2]))
|
|
|
|
|
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])
|
|
|
|
|
#print(Detail_Dict)
|
|
|
|
|
#print(move)
|
|
|
|
|
#print(Ordered_Commands_Backward)
|
|
|
|
|
|
|
|
|
|
|