All Intersections point system Algo-Fully Working-
This commit is contained in:
@@ -8,6 +8,7 @@ var Current_Position = [0,0]
|
|||||||
var Cords = [[0,0]]
|
var Cords = [[0,0]]
|
||||||
var Cords_Copy = []
|
var Cords_Copy = []
|
||||||
var Intersections = [[]]
|
var Intersections = [[]]
|
||||||
|
|
||||||
var Intersections_Copy = []
|
var Intersections_Copy = []
|
||||||
var Distance_From_Intersection = 0
|
var Distance_From_Intersection = 0
|
||||||
var Tree_Array = []
|
var Tree_Array = []
|
||||||
@@ -39,6 +40,7 @@ var Move_Check2 = 0
|
|||||||
var Move_Check = 0
|
var Move_Check = 0
|
||||||
var move_check2 = 0
|
var move_check2 = 0
|
||||||
var Move_Check3 = 0
|
var Move_Check3 = 0
|
||||||
|
var move_check7 = 99
|
||||||
var Been_There_Overide = false
|
var Been_There_Overide = false
|
||||||
var LogDump = []
|
var LogDump = []
|
||||||
var IntersectionDump = []
|
var IntersectionDump = []
|
||||||
@@ -52,7 +54,7 @@ var CircleInts = 0
|
|||||||
var LogDumpOrdered = []
|
var LogDumpOrdered = []
|
||||||
var Order = []
|
var Order = []
|
||||||
var Intersections_from_root = []
|
var Intersections_from_root = []
|
||||||
var TargetCord = [100,-10]
|
var TargetCord = [2,-10]
|
||||||
var CircleCompleted = null
|
var CircleCompleted = null
|
||||||
var AutoBacktrack = false
|
var AutoBacktrack = false
|
||||||
var IntersectionDict = {"Cord": [], "Data": [] }
|
var IntersectionDict = {"Cord": [], "Data": [] }
|
||||||
@@ -60,8 +62,10 @@ var IntersectionDir = []
|
|||||||
var IntersectionMove = 0
|
var IntersectionMove = 0
|
||||||
var IntOptions = []
|
var IntOptions = []
|
||||||
var CurrentInt = ""
|
var CurrentInt = ""
|
||||||
var InverNext = false
|
var Invert = false
|
||||||
var InvertionArray = []
|
var InvertionArray = []
|
||||||
|
var CordsDump = []
|
||||||
|
var FullCount = 0
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if Current_Position != TargetCord:
|
if Current_Position != TargetCord:
|
||||||
@@ -101,7 +105,9 @@ func _process(delta):
|
|||||||
MoveAfterIntersection()
|
MoveAfterIntersection()
|
||||||
IntersectionWaysAvailable()
|
IntersectionWaysAvailable()
|
||||||
IntersectionDumping()
|
IntersectionDumping()
|
||||||
|
CordsDumping()
|
||||||
#print(InverNext)
|
#print(InverNext)
|
||||||
|
#print(CordsDump)
|
||||||
else:
|
else:
|
||||||
print("We Done!!!!!!!!!!!!!!!!!!!!!!!")
|
print("We Done!!!!!!!!!!!!!!!!!!!!!!!")
|
||||||
|
|
||||||
@@ -129,6 +135,13 @@ func WhatMove():
|
|||||||
move = move + 1
|
move = move + 1
|
||||||
state4 = 2
|
state4 = 2
|
||||||
|
|
||||||
|
func CordsDumping():
|
||||||
|
if move_check7 != FullCount:
|
||||||
|
CordsDump.push_back(Current_Position)
|
||||||
|
var Duplicate = CordsDump.duplicate(true)
|
||||||
|
CordsDump = Duplicate
|
||||||
|
move_check7 = FullCount
|
||||||
|
|
||||||
func TravelLog():
|
func TravelLog():
|
||||||
if Detail_Dict.Been_There == false:
|
if Detail_Dict.Been_There == false:
|
||||||
if move_check3 != move:
|
if move_check3 != move:
|
||||||
@@ -143,6 +156,7 @@ func BackTracking():
|
|||||||
BackTrack_Array.push_back(move)
|
BackTrack_Array.push_back(move)
|
||||||
if Intersections.find(Current_Position) == -1 and Intersections.find(Current_Position) != Intersections.size() -1 and BackTrack_Array.size() >= 2:
|
if Intersections.find(Current_Position) == -1 and Intersections.find(Current_Position) != Intersections.size() -1 and BackTrack_Array.size() >= 2:
|
||||||
TrackBack = GiveOrder()
|
TrackBack = GiveOrder()
|
||||||
|
print(TrackBack)
|
||||||
Distance_From_Intersection = BackTrack_Array[-1] - BackTrack_Array[-2]
|
Distance_From_Intersection = BackTrack_Array[-1] - BackTrack_Array[-2]
|
||||||
print("The distance from the last intersection is : ", Distance_From_Intersection)
|
print("The distance from the last intersection is : ", Distance_From_Intersection)
|
||||||
print("To get to the last intersection follow these steps : ", TrackBack)
|
print("To get to the last intersection follow these steps : ", TrackBack)
|
||||||
@@ -297,43 +311,36 @@ func TrackIntersections():
|
|||||||
|
|
||||||
func MoveAfterIntersection():
|
func MoveAfterIntersection():
|
||||||
if move == IntersectionMove+1:
|
if move == IntersectionMove+1:
|
||||||
if InverNext == false:
|
if Move_Check6 != move:
|
||||||
if Move_Check6 != move:
|
if TrackBack.size() != 1 and BackTrack_Array.size() > 1:
|
||||||
if TrackBack.size() != 1 and BackTrack_Array.size() > 1:
|
IntersectionDir.push_back(LogDumpOrdered[0])
|
||||||
IntersectionDir.push_back(LogDumpOrdered[0])
|
if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1:
|
||||||
if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1:
|
InvertionArray.pop_back()
|
||||||
InvertionArray.pop_back()
|
Invert = true
|
||||||
InverNext = true
|
|
||||||
else:
|
|
||||||
InverNext = false
|
|
||||||
else:
|
else:
|
||||||
IntersectionDir.push_back(LogDump[0])
|
Invert = false
|
||||||
if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1:
|
else:
|
||||||
InvertionArray.pop_back()
|
IntersectionDir.push_back(LogDump[0])
|
||||||
InverNext = true
|
if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1 and Invert == false:
|
||||||
|
InvertionArray.pop_back()
|
||||||
elif BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] != 1:
|
Invert = true
|
||||||
InverNext = false
|
elif BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] != 1:
|
||||||
|
Invert = false
|
||||||
InvertionArray.push_back(InverNext)
|
|
||||||
CallingDir()
|
|
||||||
if InvertionArray.size() > 1 and InvertionArray[-2] == true and InvertionArray[-1] == false:
|
|
||||||
print(Prev_dir_Opp)
|
|
||||||
if InvertionArray.size() >1 and InvertionArray[-1] == true and InvertionArray[-2] == false:
|
|
||||||
print(Prev_dir_Opp)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(Prev_dir)
|
Invert = false
|
||||||
print(InvertionArray)
|
|
||||||
#print("The Test is here !!!", IntOptions)
|
|
||||||
Move_Check6 = move
|
|
||||||
else:
|
|
||||||
InverNext = false
|
|
||||||
MoveAfterIntersection()
|
|
||||||
|
|
||||||
func CallingDir():
|
if Invert == true:
|
||||||
if Intersections.find(Current_Position) != -1 and IntOptions.size() > 1:
|
#print(Prev_dir_Opp)
|
||||||
print(IntOptions[Intersections.find(Current_Position)-1])
|
IntOptions[-1].erase(Prev_dir_Opp)
|
||||||
|
#print(IntOptions)
|
||||||
|
if Invert == false and CordsDump.size() >= 2 :
|
||||||
|
#print(Prev_dir)
|
||||||
|
if CordsDump.size() >= 2 and Intersections.find(CordsDump[-1]) != -1:
|
||||||
|
IntOptions[Intersections.find(CordsDump[-1])-1].erase(Prev_dir)
|
||||||
|
|
||||||
|
#print(IntOptions)
|
||||||
|
#print(Intersections)
|
||||||
|
Move_Check6 = move
|
||||||
|
|
||||||
func IntersectionDumping():
|
func IntersectionDumping():
|
||||||
if CurrentInt != "Plain Path" and Detail_Dict.Type != "Dead End":
|
if CurrentInt != "Plain Path" and Detail_Dict.Type != "Dead End":
|
||||||
@@ -436,12 +443,21 @@ func AutoSolve():
|
|||||||
DirectionStrengths[n] -= 25
|
DirectionStrengths[n] -= 25
|
||||||
if MoveScore < 15:
|
if MoveScore < 15:
|
||||||
DirectionStrengths[n] -= MoveScore
|
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:
|
for i in OptionArrays:
|
||||||
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(DirectionStrengths)
|
||||||
|
print("The Direction with the lowest points is ", DirArray[HighestPoints], "!")
|
||||||
Move(DirArray[HighestPoints])
|
Move(DirArray[HighestPoints])
|
||||||
|
|
||||||
#***** Helpers *****
|
#***** Helpers *****
|
||||||
@@ -465,6 +481,7 @@ func TypeOfIntersectionHelper():
|
|||||||
func goDown():
|
func goDown():
|
||||||
var D = $Forwardv
|
var D = $Forwardv
|
||||||
dir = Vector2.DOWN
|
dir = Vector2.DOWN
|
||||||
|
FullCount += 1
|
||||||
if not D.is_colliding():
|
if not D.is_colliding():
|
||||||
self.global_position.y += 24
|
self.global_position.y += 24
|
||||||
Current_Position[1] -=1
|
Current_Position[1] -=1
|
||||||
@@ -477,6 +494,7 @@ 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
|
||||||
@@ -492,6 +510,7 @@ func goUp():
|
|||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
print("There is something above you")
|
print("There is something above you")
|
||||||
#BeenTheirFromPrevCord()
|
#BeenTheirFromPrevCord()
|
||||||
|
FullCount += 1
|
||||||
|
|
||||||
func goRight():
|
func goRight():
|
||||||
var R = $Rightv
|
var R = $Rightv
|
||||||
@@ -507,6 +526,7 @@ func goRight():
|
|||||||
Been_There_Overide = true
|
Been_There_Overide = true
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
print("There is something to your right")
|
print("There is something to your right")
|
||||||
|
FullCount += 1
|
||||||
|
|
||||||
func goLeft():
|
func goLeft():
|
||||||
var L = $Leftv
|
var L = $Leftv
|
||||||
@@ -522,6 +542,7 @@ func goLeft():
|
|||||||
Been_There_Overide = true
|
Been_There_Overide = true
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
print("There is something to your left")
|
print("There is something to your left")
|
||||||
|
FullCount += 1
|
||||||
|
|
||||||
#***** Auto Movement *****
|
#***** Auto Movement *****
|
||||||
|
|
||||||
@@ -533,6 +554,7 @@ func Move(SetDirection):
|
|||||||
Prev_dir_Opp = "L"
|
Prev_dir_Opp = "L"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
|
FullCount += 1
|
||||||
|
|
||||||
if SetDirection == "L":
|
if SetDirection == "L":
|
||||||
self.global_position.x -= 24.4
|
self.global_position.x -= 24.4
|
||||||
@@ -541,6 +563,7 @@ func Move(SetDirection):
|
|||||||
Prev_dir_Opp = "R"
|
Prev_dir_Opp = "R"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
|
FullCount += 1
|
||||||
|
|
||||||
if SetDirection == "D":
|
if SetDirection == "D":
|
||||||
self.global_position.y += 24
|
self.global_position.y += 24
|
||||||
@@ -549,6 +572,7 @@ func Move(SetDirection):
|
|||||||
Prev_dir_Opp = "U"
|
Prev_dir_Opp = "U"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
|
FullCount += 1
|
||||||
|
|
||||||
if SetDirection == "U":
|
if SetDirection == "U":
|
||||||
self.global_position.y -= 24
|
self.global_position.y -= 24
|
||||||
@@ -557,3 +581,4 @@ func Move(SetDirection):
|
|||||||
Prev_dir_Opp = "D"
|
Prev_dir_Opp = "D"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
|
FullCount += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user