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 Order = []
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 AutoBacktrack = false
var IntersectionDict = {"Cord": [], "Data": [] }
@@ -81,7 +81,7 @@ var TargetsArray = []
var Goal = false
var Trunk = []
var PreTrunk = []
var count = {}
var InstancesDict = {}
func _input(event):
#if Current_Position != TargetCord:
@@ -104,9 +104,7 @@ func _input(event):
elif event.is_action_pressed("ui_accept"):
AutoSolve()
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):
FoundGoal()
AllObjectsFound()
@@ -196,16 +194,29 @@ func AllObjectsFound():
#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"]]
Trunk = CommonElements2(AllSetsToGoal)
print("This is the trunk: ", Trunk)
print()
print()
AllSetsToGoal = TrunkDelete()
Instances(AllSetsToGoal)
FullReverse(AllSetsToGoal)
#print(n ," set is equal to : ", placeHolder)
InstancesDict = Instances(AllSetsToGoal)
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
func Route():
var BestFirst = {}
for n in AllSetsToGoal:
if InstancesDict[n] == 2:
print("Heyyyyy")
func Mark(Prev_Direction):
var response = ways[IntersectionCounter()]
@@ -635,6 +646,11 @@ func GoBack(Set):
for n in Set:
Move(n)
func RGoBack(Set):
AutoBacktrack = true
for n in Set:
RMove(n)
func IntersectionCounter():
var R: bool = $Rightv.is_colliding()
var L: bool = $Leftv.is_colliding()
@@ -660,21 +676,12 @@ func RaycastHelper():
func FullReverse(data):
var vars = []
print(data)
print()
print()
data.reverse()
print(data)
print()
print()
for n in data:
n.reverse()
vars.push_back(n)
print("vars: ")
print()
print(vars)
print()
print()
for i in n:
i.reverse()
vars.push_back(i)
func TypeOfIntersectionHelper():
if Detail_Dict.Type != "Plain Path" and Detail_Dict.Type != "Dead End":
@@ -683,15 +690,16 @@ func TypeOfIntersectionHelper():
return "OneDirectionPath"
func Instances(Arrays):
var count = {}
for x in Arrays:
for n in x:
if count.get(n) == null:
count[n] = 0
if count.get(n) != null:
count[n] += 1
print(count)
count = count.duplicate(true)
return count
func CommonElements2(Arrays):
var count = []
@@ -813,6 +821,44 @@ func Move(SetDirection):
move += Move_Strength
Been_There()
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():
var DirectionStrengths = [6,6,5,6]