Trunk is fully working and the route order is coming along. Route order needs an algo with non-biased to front. Maybe score system but idrk probably score system. Also the reverse thing is done

This commit is contained in:
2024-10-31 08:09:41 -04:00
parent 29b5831c86
commit 2d1dbe268b

View File

@@ -61,7 +61,7 @@ var CircleInts = 0
var LogDumpOrdered = [] var LogDumpOrdered = []
var Order = [] var Order = []
var Intersections_from_root = [] var Intersections_from_root = []
var TargetCord = [[0,-11], [13,-13], [15,-19]] # HAD TO CHANGE TARGET CORD, IT WAS PREVIOUSLY [2,-10] var TargetCord = [[0,-11], [13,-14], [15,-19]] # HAD TO CHANGE TARGET CORD, IT WAS PREVIOUSLY [2,-10]
var CircleCompleted = null var CircleCompleted = null
var AutoBacktrack = false var AutoBacktrack = false
var IntersectionDict = {"Cord": [], "Data": [] } var IntersectionDict = {"Cord": [], "Data": [] }
@@ -81,7 +81,7 @@ var TargetsArray = []
var Goal = false var Goal = false
var Trunk = [] var Trunk = []
var PreTrunk = [] var PreTrunk = []
var count = {} var InstancesDict = {}
func _input(event): func _input(event):
#if Current_Position != TargetCord: #if Current_Position != TargetCord:
@@ -104,9 +104,7 @@ func _input(event):
elif event.is_action_pressed("ui_accept"): elif event.is_action_pressed("ui_accept"):
AutoSolve() AutoSolve()
var Arrays = [['apple', 'orange', 'banana', 'pear', 'fish', 'pancake', 'taco', 'pizza'],['banana', 'pizza', 'fish', 'apple'],['taco', 'fish', 'apple', 'pizza'],["apple","fish"]] var Arrays = [['apple', 'orange', 'banana', 'pear', 'fish', 'pancake', 'taco', 'pizza'],['banana', 'pizza', 'fish', 'apple'],['taco', 'fish', 'apple', 'pizza'],["apple","fish"]]
#Instances(Arrays)
#print(Tree_Array)
# print(Current_Position)
func _process(delta): func _process(delta):
FoundGoal() FoundGoal()
AllObjectsFound() AllObjectsFound()
@@ -196,16 +194,29 @@ func AllObjectsFound():
#print("This is the Trunk ", Trunk) #print("This is the Trunk ", Trunk)
var Arrays = [['apple', 'orange', 'banana', 'pear', 'fish', 'pancake', 'taco', 'pizza'],['banana', 'pizza', 'fish', 'apple'],['taco', 'fish', 'apple', 'pizza'],["apple","fish"]] var Arrays = [['apple', 'orange', 'banana', 'pear', 'fish', 'pancake', 'taco', 'pizza'],['banana', 'pizza', 'fish', 'apple'],['taco', 'fish', 'apple', 'pizza'],["apple","fish"]]
Trunk = CommonElements2(AllSetsToGoal) Trunk = CommonElements2(AllSetsToGoal)
print("This is the trunk: ", Trunk)
print() print()
print() print()
AllSetsToGoal = TrunkDelete() AllSetsToGoal = TrunkDelete()
Instances(AllSetsToGoal) InstancesDict = Instances(AllSetsToGoal)
FullReverse(AllSetsToGoal)
#print(n ," set is equal to : ", placeHolder)
print() print()
FullReverse(AllSetsToGoal)
FullReverse(Trunk)
print("This is the trunk: ", Trunk)
print()
print(AllSetsToGoal)
print()
for n in Trunk:
RGoBack(n)
Route()
Move_Check1 = move Move_Check1 = move
func Route():
var BestFirst = {}
for n in AllSetsToGoal:
if InstancesDict[n] == 2:
print("Heyyyyy")
func Mark(Prev_Direction): func Mark(Prev_Direction):
var response = ways[IntersectionCounter()] var response = ways[IntersectionCounter()]
@@ -635,6 +646,11 @@ func GoBack(Set):
for n in Set: for n in Set:
Move(n) Move(n)
func RGoBack(Set):
AutoBacktrack = true
for n in Set:
RMove(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()
@@ -660,21 +676,12 @@ func RaycastHelper():
func FullReverse(data): func FullReverse(data):
var vars = [] var vars = []
print(data)
print()
print()
data.reverse() data.reverse()
print(data)
print()
print()
for n in data: for n in data:
n.reverse() n.reverse()
vars.push_back(n) for i in n:
print("vars: ") i.reverse()
print() vars.push_back(i)
print(vars)
print()
print()
func TypeOfIntersectionHelper(): func TypeOfIntersectionHelper():
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End": if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
@@ -683,15 +690,16 @@ func TypeOfIntersectionHelper():
return "OneDirectionPath" return "OneDirectionPath"
func Instances(Arrays): func Instances(Arrays):
var count = {}
for x in Arrays: for x in Arrays:
for n in x: for n in x:
if count.get(n) == null: if count.get(n) == null:
count[n] = 0 count[n] = 0
if count.get(n) != null: if count.get(n) != null:
count[n] += 1 count[n] += 1
print(count) print(count)
count = count.duplicate(true)
return count
func CommonElements2(Arrays): func CommonElements2(Arrays):
var count = [] var count = []
@@ -814,6 +822,44 @@ func Move(SetDirection):
Been_There() Been_There()
FullCount += 1 FullCount += 1
func RMove(SetDirection):
if SetDirection == "R":
self.global_position.x -= 24.4
Current_Position[0] -=1
Prev_dir = "L"
Prev_dir_Opp = "R"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "L":
self.global_position.x += 24.4
Current_Position[0] +=1
Prev_dir = "R"
Prev_dir_Opp = "L"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "D":
self.global_position.y -= 24
Current_Position[1] +=1
Prev_dir = "U"
Prev_dir_Opp = "D"
move += Move_Strength
Been_There()
FullCount += 1
if SetDirection == "U":
self.global_position.y += 24
Current_Position[1] -=1
Prev_dir = "D"
Prev_dir_Opp = "U"
move += Move_Strength
Been_There()
FullCount += 1
func AutoSolve(): func AutoSolve():
var DirectionStrengths = [6,6,5,6] var DirectionStrengths = [6,6,5,6]
var Colliders = RaycastHelper() var Colliders = RaycastHelper()