diff --git a/PlayerScript.gd b/PlayerScript.gd index 32e5ffd..56e9c2b 100644 --- a/PlayerScript.gd +++ b/PlayerScript.gd @@ -102,6 +102,7 @@ func _input(event): AutoBacktrack = false elif event.is_action_pressed("ui_accept"): AutoSolve() + #print(Tree_Array) # print(Current_Position) func _process(delta): @@ -182,17 +183,19 @@ func FoundGoal(): func AllObjectsFound(): if Tree_Array_SetStart != Tree_Array[0]: var CurrentInstructionSet = [] - Trunk = CommonElements(AllSetsToGoal[0], AllSetsToGoal[1], AllSetsToGoal[2]) - print("This is the Trunk ", Trunk) if Move_Check1 != move: print("We Done!!!!!!!!!!!!!!!!!") print() for n in AllSetsToGoal.size(): var placeHolder = [] - placeHolder = AllSetsToGoal[n] - placeHolder.slice(Trunk[-1]) - print(n ," set is equal to : ", placeHolder ) - print() + #placeHolder = AllSetsToGoal[n] + #placeHolder.slice(placeHolder.find(Trunk[-1])) + #Trunk = CommonElements(AllSetsToGoal[0], AllSetsToGoal[1], AllSetsToGoal[2]) + #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"]] + CommonElements2(Arrays) + #print(n ," set is equal to : ", placeHolder) + print() Move_Check1 = move func Mark(Prev_Direction): @@ -653,6 +656,21 @@ func CommonElements(A,B,C): if x in C: count.push_back(x) return count +func CommonElements2(Arrays): + var count = [] + var deletions = [] + for x in Arrays: + for n in Arrays[0]: + if n in x: + if count.find(n) == -1: + count.push_back(n) + else: + deletions.push_back(n) + for i in deletions: + count.erase(i) + print(count) + return count + #***** Movement ***** func goDown():