From 7f4849e9dffeb6e9df880411e8d76925a12a9ce7 Mon Sep 17 00:00:00 2001 From: kmk028 Date: Wed, 11 Nov 2020 00:56:36 -0800 Subject: [PATCH 01/10] Helper functions added --- projects/graph/graph.py | 66 ++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/projects/graph/graph.py b/projects/graph/graph.py index 59fecae4b..e379d75ad 100644 --- a/projects/graph/graph.py +++ b/projects/graph/graph.py @@ -3,29 +3,57 @@ """ from util import Stack, Queue # These may come in handy + + class Graph: """Represent a graph as a dictionary of vertices mapping labels to edges.""" def __init__(self): + # vertex ID --> set of neighbors self.vertices = {} + # def __repr__(self): + # return str(self.vertices) + def add_vertex(self, vertex_id): """ Add a vertex to the graph. """ - pass # TODO - - def add_edge(self, v1, v2): + self.vertices[vertex_id] = set() + + # adds directed edge from "from_vertex" to "to_vertex" + def add_edge(self, from_vertex_id, to_vertex_id): """ Add a directed edge to the graph. """ - pass # TODO + if from_vertex_id not in self.vertices or to_vertex_id not in self.vertices: + print ("Attempting to add edge to non existing node") + return + self.vertices[from_vertex_id].add(to_vertex_id) #.add is method for set def get_neighbors(self, vertex_id): """ Get all neighbors (edges) of a vertex. """ - pass # TODO + return self.vertices[vertex_id] + + #remove vertex from graph and any incoming edges to it + def remove_vertex(self,vertex_id): + if vertex_id not in self.vertices: + print("Attempting to remove non existant vertices") + return + + self.vertices.pop(vertex_id) + for remaining_vertex in self.vertices: + self.vertices[remaining_vertex].discard(vertex_id) + + def remove_edge(self,from_vertex_id,to_vertex_id): + if from_vertex_id not in self.vertices or to_vertex_id not in self.vertices: + print("Attempting to remove edges non existant vertex") + return + self.vertices[from_vertex_id].discard(to_vertex_id) + + def bft(self, starting_vertex): """ @@ -103,6 +131,10 @@ def dfs_recursive(self, starting_vertex, destination_vertex): ''' print(graph.vertices) + graph.remove_edge(8,1) + + print(graph.vertices) + ''' Valid BFT paths: 1, 2, 3, 4, 5, 6, 7 @@ -131,15 +163,15 @@ def dfs_recursive(self, starting_vertex, destination_vertex): graph.dft_recursive(1) ''' - Valid BFS path: - [1, 2, 4, 6] - ''' - print(graph.bfs(1, 6)) - - ''' - Valid DFS paths: - [1, 2, 4, 6] - [1, 2, 4, 7, 6] - ''' - print(graph.dfs(1, 6)) - print(graph.dfs_recursive(1, 6)) + # Valid BFS path: + # [1, 2, 4, 6] + # ''' + # print(graph.bfs(1, 6)) + + # ''' + # Valid DFS paths: + # [1, 2, 4, 6] + # [1, 2, 4, 7, 6] + # ''' + # print(graph.dfs(1, 6)) + # print(graph.dfs_recursive(1, 6)) From 855c50be25d6d8d6d9db001f3a05e2e755f804f4 Mon Sep 17 00:00:00 2001 From: kmk028 Date: Wed, 11 Nov 2020 20:47:38 -0800 Subject: [PATCH 02/10] dft,bft and dfs added --- projects/graph/graph.py | 57 ++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/projects/graph/graph.py b/projects/graph/graph.py index e379d75ad..459554860 100644 --- a/projects/graph/graph.py +++ b/projects/graph/graph.py @@ -4,7 +4,7 @@ from util import Stack, Queue # These may come in handy - +from collections import deque class Graph: """Represent a graph as a dictionary of vertices mapping labels to edges.""" @@ -60,16 +60,35 @@ def bft(self, starting_vertex): Print each vertex in breadth-first order beginning from starting_vertex. """ - pass # TODO + queue = deque() + visited = set() + queue.append(starting_vertex) + while len(queue)>0: + currNode = queue.popleft() + if currNode not in visited: + visited.add(currNode) + print (currNode) + for neigbor in self.vertices[currNode]: + queue.append(neigbor) def dft(self, starting_vertex): """ Print each vertex in depth-first order beginning from starting_vertex. """ - pass # TODO + stack = deque() + visited = set() + stack.append(starting_vertex) + while len(stack)>0: + currNode = stack.pop() + if currNode not in visited: + visited.add(currNode) + print (currNode) + for neigbor in self.vertices[currNode]: + stack.append(neigbor) - def dft_recursive(self, starting_vertex): + + def dft_recursive(self, starting_vertex,visited=set()): """ Print each vertex in depth-first order beginning from starting_vertex. @@ -85,14 +104,29 @@ def bfs(self, starting_vertex, destination_vertex): breath-first order. """ pass # TODO - + + def dfs(self, starting_vertex, destination_vertex): """ Return a list containing a path from starting_vertex to destination_vertex in depth-first order. """ - pass # TODO + stack = deque() + visited = set() + #push the current path you are onto stack, instwead of single vertex + stack.append([starting_vertex]) + while len(stack)>0: + currPath = stack.pop() + currNode = currPath[-1] # current node you are on is the last node in the path + if currNode == destination_vertex: + return currPath + if currNode not in visited: + visited.add(currNode) + for neigbor in self.vertices[currNode]: + newPath = list(currPath) # make copy of curr path + newPath.append(neigbor) + stack.append(newPath) def dfs_recursive(self, starting_vertex, destination_vertex): """ @@ -131,9 +165,7 @@ def dfs_recursive(self, starting_vertex, destination_vertex): ''' print(graph.vertices) - graph.remove_edge(8,1) - - print(graph.vertices) + # graph.remove_edge(8,1) ''' Valid BFT paths: @@ -159,8 +191,8 @@ def dfs_recursive(self, starting_vertex, destination_vertex): 1, 2, 4, 7, 6, 3, 5 1, 2, 4, 6, 3, 5, 7 ''' - graph.dft(1) - graph.dft_recursive(1) + # graph.dft(1) + # graph.dft_recursive(1) ''' # Valid BFS path: @@ -173,5 +205,6 @@ def dfs_recursive(self, starting_vertex, destination_vertex): # [1, 2, 4, 6] # [1, 2, 4, 7, 6] # ''' - # print(graph.dfs(1, 6)) + print(graph.dfs(1, 6)) # print(graph.dfs_recursive(1, 6)) + From 089bba9c08bfe7ef8e1b8de52b3b2fe1bdcca3f1 Mon Sep 17 00:00:00 2001 From: kmk028 Date: Wed, 11 Nov 2020 23:06:09 -0800 Subject: [PATCH 03/10] dft recursive done --- projects/graph/graph.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/projects/graph/graph.py b/projects/graph/graph.py index 459554860..99e268d09 100644 --- a/projects/graph/graph.py +++ b/projects/graph/graph.py @@ -95,7 +95,12 @@ def dft_recursive(self, starting_vertex,visited=set()): This should be done using recursion. """ - pass # TODO + + if starting_vertex not in visited: + print(starting_vertex) + visited.add(starting_vertex) + for neighbor in self.vertices[starting_vertex]: + self.dft_recursive(neighbor,visited) def bfs(self, starting_vertex, destination_vertex): """ @@ -182,7 +187,7 @@ def dfs_recursive(self, starting_vertex, destination_vertex): 1, 2, 4, 3, 7, 6, 5 1, 2, 4, 3, 7, 5, 6 ''' - graph.bft(1) + #graph.bft(1) ''' Valid DFT paths: @@ -191,8 +196,8 @@ def dfs_recursive(self, starting_vertex, destination_vertex): 1, 2, 4, 7, 6, 3, 5 1, 2, 4, 6, 3, 5, 7 ''' - # graph.dft(1) - # graph.dft_recursive(1) + #graph.dft(1) + graph.dft_recursive(1) ''' # Valid BFS path: @@ -205,6 +210,6 @@ def dfs_recursive(self, starting_vertex, destination_vertex): # [1, 2, 4, 6] # [1, 2, 4, 7, 6] # ''' - print(graph.dfs(1, 6)) + # print(graph.dfs(1, 6)) # print(graph.dfs_recursive(1, 6)) From 567dcf15c17f14a1c15fc3f46cf52c73c8521039 Mon Sep 17 00:00:00 2001 From: kmk028 Date: Wed, 11 Nov 2020 23:14:07 -0800 Subject: [PATCH 04/10] BFS complete --- projects/graph/graph.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/projects/graph/graph.py b/projects/graph/graph.py index 99e268d09..ab7934a3e 100644 --- a/projects/graph/graph.py +++ b/projects/graph/graph.py @@ -108,7 +108,20 @@ def bfs(self, starting_vertex, destination_vertex): starting_vertex to destination_vertex in breath-first order. """ - pass # TODO + queue = deque() + visited = set() + queue.append([starting_vertex]) + while len(queue)>0: + currPath = queue.popleft() + currNode = currPath[-1] + if currNode == destination_vertex: + return currPath + if currNode not in visited: + visited.add(currNode) + for neighbor in self.vertices[currNode]: + newPath = list(currPath) + newPath.append(neighbor) + queue.append(newPath) def dfs(self, starting_vertex, destination_vertex): @@ -197,13 +210,13 @@ def dfs_recursive(self, starting_vertex, destination_vertex): 1, 2, 4, 6, 3, 5, 7 ''' #graph.dft(1) - graph.dft_recursive(1) + # graph.dft_recursive(1) ''' # Valid BFS path: # [1, 2, 4, 6] # ''' - # print(graph.bfs(1, 6)) + print(graph.bfs(1, 6)) # ''' # Valid DFS paths: From 2f2c3ffaad563f8e00af9c5c97df2d2d1d97ef80 Mon Sep 17 00:00:00 2001 From: kmk028 Date: Sun, 15 Nov 2020 15:51:00 -0800 Subject: [PATCH 05/10] DFS recursive complete --- projects/graph/graph.py | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/projects/graph/graph.py b/projects/graph/graph.py index ab7934a3e..668b36839 100644 --- a/projects/graph/graph.py +++ b/projects/graph/graph.py @@ -95,7 +95,6 @@ def dft_recursive(self, starting_vertex,visited=set()): This should be done using recursion. """ - if starting_vertex not in visited: print(starting_vertex) visited.add(starting_vertex) @@ -154,7 +153,40 @@ def dfs_recursive(self, starting_vertex, destination_vertex): This should be done using recursion. """ - pass # TODO + visited=set() + return self.dfs_recursive_helper([starting_vertex],destination_vertex,visited) + + # return path to goal vertex if it exists , if not it will return empty array. + def dfs_recursive_helper(self,curr_path,destination_vertex,visited): + curr_vertex = curr_path[-1] + #Base-Case + if curr_vertex == destination_vertex: + return curr_path + + visited.add(curr_vertex) + + # find neighbors of current vertex and make a copy of current path. + # If neighbor is not in visited then append it to copy of curr path + # recurse over copy of curr path , until goal vertex is reached. + for neighbor in self.vertices[curr_vertex]: + if neighbor not in visited: + new_path = list(curr_path) + new_path.append(neighbor) + res = self.dfs_recursive_helper(new_path,destination_vertex,visited) + if len(res)>0: + return res + + return [] + + + + + + + + + + if __name__ == '__main__': graph = Graph() # Instantiate your graph @@ -216,7 +248,7 @@ def dfs_recursive(self, starting_vertex, destination_vertex): # Valid BFS path: # [1, 2, 4, 6] # ''' - print(graph.bfs(1, 6)) + # print(graph.bfs(1, 6)) # ''' # Valid DFS paths: @@ -224,5 +256,5 @@ def dfs_recursive(self, starting_vertex, destination_vertex): # [1, 2, 4, 7, 6] # ''' # print(graph.dfs(1, 6)) - # print(graph.dfs_recursive(1, 6)) + print(graph.dfs_recursive(1, 6)) From 1f31f5b5419749cb48dcabe4e59f372e8a78a203 Mon Sep 17 00:00:00 2001 From: kmk028 Date: Sun, 15 Nov 2020 17:42:19 -0800 Subject: [PATCH 06/10] WordList problem from lecture --- projects/wordlist/lecture.py | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 projects/wordlist/lecture.py diff --git a/projects/wordlist/lecture.py b/projects/wordlist/lecture.py new file mode 100644 index 000000000..0001d9c6c --- /dev/null +++ b/projects/wordlist/lecture.py @@ -0,0 +1,76 @@ +""" +Given two words (begin_word and end_word), and a dictionary's word list, return the shortest transformation sequence from begin_word to end_word, such that: + +Only one letter can be changed at a time. +Each transformed word must exist in the word list. Note that begin_word is not a transformed word. +Note: + +Return None if there is no such transformation sequence. +All words contain only lowercase alphabetic characters. +You may assume no duplicates in the word list. +You may assume begin_word and end_word are non-empty and are not the same. + +Sample: +beginWord = "hit", +endWord = "cog", +wordList = ["hot","dot","dog","lot","log","cog"] +["hit", "hot", "dot", "dog", "cog"] + +beginWord = "hit", +endWord = "cog", +wordList = ["hot","dot","dog","lot","log"] +[] + +PLAN: +Translate in Graph terminology +Build Graph +Traverse graph + +Vertex : Word +Edge: a possible 1 letter transformation from a word to another word +Weights: None +Path: 1 letter Transformations from begin word to end word + +Build Graph: +Creating all possible transformations in an adjecency list will be too expensive +how to find out next vertex by determining if its a valid vertex from word list. +we should visit a vertex if its in the wordlist + +Traverse graph : +Shortest -> BFS +start from begin word and generate word transformations from it +enqueue transformations that are in the word list, ignore rest +once we find endword, return path we took to get there +""" +from collections import deque + +alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] + +def findLadders(beginWord,endWord,wordlist): + words = set(wordlist) + visited = set() + queue = deque() + queue.append([beginWord]) + + while len(queue)>0: + currPath = queue.popleft() + currWord = currPath[-1] + if currWord in visited: + continue + + visited.add(currWord) + + if currWord == endWord: + return currPath + + for i in range (len(currWord)): + for letter in alphabet: + transformedWord = currWord[:i]+ letter + currWord[i+1:] + if transformedWord in wordlist: + newPath = list(currPath) + newPath.append(transformedWord) + queue.append(newPath) + + return [] + +print (findLadders("hit","cog",["hot","dot","dog","lot","log","cog"])) \ No newline at end of file From 8b8d1018a0057471240602a9e8351a75c13dc63e Mon Sep 17 00:00:00 2001 From: kmk028 Date: Tue, 17 Nov 2020 19:59:21 -0800 Subject: [PATCH 07/10] earliest ancestor complete and workoing --- projects/ancestor/ancestor.py | 43 +++++++++++++++++++++++++++++++++-- projects/graph/graph.py | 4 ++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/projects/ancestor/ancestor.py b/projects/ancestor/ancestor.py index 3bd003098..4e4d7fa57 100644 --- a/projects/ancestor/ancestor.py +++ b/projects/ancestor/ancestor.py @@ -1,3 +1,42 @@ -def earliest_ancestor(ancestors, starting_node): - pass \ No newline at end of file +from collections import deque, defaultdict + +def earliest_ancestor(ancestors,starting_node): + graph = createGraph(ancestors) + + earliest_ancestor = (starting_node,0) + + stack = deque() + stack.append((starting_node,0)) + visited = set() + + while len(stack)>0: + curr = stack.pop() + currNode, dist = curr[0],curr[1] + visited.add(curr) + + if currNode not in graph: + if dist > earliest_ancestor[1]: + earliest_ancestor = curr + elif ((dist == earliest_ancestor[1]) and (currNode < earliest_ancestor[0])): + earliest_ancestor = curr + else: + for ancestor in graph[currNode]: + if ancestor not in visited: + stack.append((ancestor,dist+1)) + + if earliest_ancestor[0] != starting_node: + return earliest_ancestor[0] + else: + return -1 + +# vertices = {} +# ancestors = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[8,9],[11,8],[10,1]] + +def createGraph(paths): + graph = defaultdict(set) + for edge in paths: + origin,dest = edge[0],edge[1] + graph[dest].add(origin) + return graph + diff --git a/projects/graph/graph.py b/projects/graph/graph.py index 668b36839..b54298bd2 100644 --- a/projects/graph/graph.py +++ b/projects/graph/graph.py @@ -241,7 +241,7 @@ def dfs_recursive_helper(self,curr_path,destination_vertex,visited): 1, 2, 4, 7, 6, 3, 5 1, 2, 4, 6, 3, 5, 7 ''' - #graph.dft(1) + graph.dft(1) # graph.dft_recursive(1) ''' @@ -256,5 +256,5 @@ def dfs_recursive_helper(self,curr_path,destination_vertex,visited): # [1, 2, 4, 7, 6] # ''' # print(graph.dfs(1, 6)) - print(graph.dfs_recursive(1, 6)) + #print(graph.dfs_recursive(1, 6)) From e913a2bfebb87ce51a2a4589371dcc65a1541a3a Mon Sep 17 00:00:00 2001 From: kmk028 Date: Sun, 29 Nov 2020 13:39:42 -0800 Subject: [PATCH 08/10] earliest ancestor UPER comments --- projects/ancestor/ancestor.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/projects/ancestor/ancestor.py b/projects/ancestor/ancestor.py index 4e4d7fa57..e5a62bebd 100644 --- a/projects/ancestor/ancestor.py +++ b/projects/ancestor/ancestor.py @@ -1,13 +1,29 @@ from collections import deque, defaultdict +''' +PLAN: +Vertex = People +Edges = parent-child relationships +Weights = not needed +Path = persons family tree + +Build Graph: +build graph based on edges given, each user has a directed edge to its ancestor/parent. + +Traverse Graph: +traverse all paths starting from start node. +Keep track of farthest node with lowest user ID +output that node. +''' + def earliest_ancestor(ancestors,starting_node): graph = createGraph(ancestors) earliest_ancestor = (starting_node,0) stack = deque() - stack.append((starting_node,0)) + stack.append((starting_node,0)) # tuple with node ID and its distance from starting node visited = set() while len(stack)>0: @@ -15,7 +31,7 @@ def earliest_ancestor(ancestors,starting_node): currNode, dist = curr[0],curr[1] visited.add(curr) - if currNode not in graph: + if currNode not in graph: # this means its a terminal node (node with no parent, it won't be the key in graph) if dist > earliest_ancestor[1]: earliest_ancestor = curr elif ((dist == earliest_ancestor[1]) and (currNode < earliest_ancestor[0])): @@ -33,7 +49,7 @@ def earliest_ancestor(ancestors,starting_node): # vertices = {} # ancestors = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[8,9],[11,8],[10,1]] -def createGraph(paths): +def createGraph(paths): # Building out a graph with child as key and parent as value (directional edge from child to parent.) graph = defaultdict(set) for edge in paths: origin,dest = edge[0],edge[1] From 47445094a42862eacae8015a4792cb0e5d2f4691 Mon Sep 17 00:00:00 2001 From: kmk028 Date: Sun, 29 Nov 2020 15:42:56 -0800 Subject: [PATCH 09/10] populate graph complete --- projects/social/social.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/projects/social/social.py b/projects/social/social.py index 8609d8800..1f71fa474 100644 --- a/projects/social/social.py +++ b/projects/social/social.py @@ -1,3 +1,5 @@ +import random +import math class User: def __init__(self, name): self.name = name @@ -42,11 +44,25 @@ def populate_graph(self, num_users, avg_friendships): self.last_id = 0 self.users = {} self.friendships = {} - # !!!! IMPLEMENT ME # Add users + for i in range (num_users): + self.add_user("User {i}") + + # create frienships using add_friendship + possible_frienships = [] + for user_id in self.users: + for friend_id in range(user_id+1,self.last_id+1): + possible_frienships.append((user_id,friend_id)) + + # shuffle that list + random.shuffle(possible_frienships) # Create friendships + #generate all possible frienships beween users and put them them in list + for i in range (math.floor(num_users*avg_friendships/2)): + friendship = possible_frienships[i] + self.add_friendship(friendship[0],friendship[1]) def get_all_social_paths(self, user_id): """ From 8248995f38ef9f004eef2b3f7bdccc409edf810d Mon Sep 17 00:00:00 2001 From: kmk028 Date: Sun, 29 Nov 2020 22:02:28 -0800 Subject: [PATCH 10/10] adventure game completed --- projects/adventure/adv.py | 103 ++++++++++++++++++++++++++++++++------ projects/social/social.py | 2 +- 2 files changed, 88 insertions(+), 17 deletions(-) diff --git a/projects/adventure/adv.py b/projects/adventure/adv.py index 8bc540b5e..43e684cc2 100644 --- a/projects/adventure/adv.py +++ b/projects/adventure/adv.py @@ -1,13 +1,16 @@ from room import Room from player import Player from world import World - +from collections import deque import random from ast import literal_eval # Load world world = World() +#construct a traversal graph +#do dft for finding all the possible room player can move +#do bfs for finding unexplored direction # You may uncomment the smaller graphs for development and testing purposes. # map_file = "maps/test_line.txt" @@ -24,12 +27,82 @@ world.print_rooms() player = Player(world.starting_room) +player.current_room = world.starting_room # Fill this out with directions to walk # traversal_path = ['n', 'n'] traversal_path = [] - +backtrack = { + 'n': 's', + 'e': 'w', + 'w': 'e', + 's': 'n'} + +def bfs(curr_room): + visited = set() + queue = deque() + queue.append((curr_room,[])) + + while len(queue)>0: + (room,path) = queue.popleft() + if room in visited: + continue + visited.add(room) + for direction in visited_room[room]: + if visited_room[room][direction] == '?': + return [path,direction] + else: + newPath = path.copy() + newPath.append(direction) + next_room = visited_room[room][direction] + queue.append((next_room,newPath)) + +def dft(unexplored_diection): + stack = deque() + stack.append(unexplored_diection) + + while len(stack)>0: + curr_exit = stack.pop() + move_direction = curr_exit[-1] + if move_direction not in visited_room[player.current_room.id]: + continue + elif visited_room[player.current_room.id][move_direction] == '?': + prev_room = player.current_room.id + player.travel(move_direction) + traversal_path.append(move_direction) + + visited_room[prev_room][move_direction] = player.current_room.id + opposite_val = backtrack[move_direction] + + if player.current_room.id not in visited_room: + visited_room[player.current_room.id] = {opposite_val:prev_room} + else: + visited_room[player.current_room.id][opposite_val] = prev_room + + for direction in player.current_room.get_exits(): + if direction not in visited_room[player.current_room.id]: + visited_room[player.current_room.id][direction] = '?' + new_dir = [] + new_dir.append(direction) + stack.append(new_dir) + + unexplored_diection = bfs(player.current_room.id) + + if unexplored_diection != None: + for direction in unexplored_diection[0]: + player.travel(direction) + traversal_path.append(direction) + dft([unexplored_diection[1]]) + + +starting_dir = random.choice(player.current_room.get_exits()) + +visited_room = {player.current_room.id:{}} +for direction in player.current_room.get_exits(): + visited_room[player.current_room.id][direction] = '?' + +dft(starting_dir) # TRAVERSAL TEST visited_rooms = set() @@ -46,17 +119,15 @@ print("TESTS FAILED: INCOMPLETE TRAVERSAL") print(f"{len(room_graph) - len(visited_rooms)} unvisited rooms") - - -####### -# UNCOMMENT TO WALK AROUND -####### -player.current_room.print_room_description(player) -while True: - cmds = input("-> ").lower().split(" ") - if cmds[0] in ["n", "s", "e", "w"]: - player.travel(cmds[0], True) - elif cmds[0] == "q": - break - else: - print("I did not understand that command.") +# ####### +# # UNCOMMENT TO WALK AROUND +# ####### +# player.current_room.print_room_description(player) +# while True: +# cmds = input("-> ").lower().split(" ") +# if cmds[0] in ["n", "s", "e", "w"]: +# player.travel(cmds[0], True) +# elif cmds[0] == "q": +# break +# else: +# print("I did not understand that command.") diff --git a/projects/social/social.py b/projects/social/social.py index 1f71fa474..874a562cc 100644 --- a/projects/social/social.py +++ b/projects/social/social.py @@ -74,7 +74,7 @@ def get_all_social_paths(self, user_id): The key is the friend's ID and the value is the path. """ visited = {} # Note that this is a dictionary, not a set - # !!!! IMPLEMENT ME + return visited