From 2d1dbe268b3000d32613e88eb367b2daae8d18f6 Mon Sep 17 00:00:00 2001 From: Jamal Millner II Date: Thu, 31 Oct 2024 08:09:41 -0400 Subject: [PATCH] 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 --- PlayerScript.gd | 92 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 23 deletions(-) diff --git a/PlayerScript.gd b/PlayerScript.gd index 2ad5672..143ac31 100644 --- a/PlayerScript.gd +++ b/PlayerScript.gd @@ -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]