@@ -87,7 +87,7 @@ def grid_search(self, grid, items):
8787
8888 :param string grid: The grid in which to search
8989 :param Boolean items: The items to search
90- :return:True if thegrid was converted
90+ :return:A dictionnary of theitems found
9191 """
9292items_found = {}
9393y = 0
@@ -102,13 +102,13 @@ def grid_search(self, grid, items):
102102
103103return items_found
104104
105- def vertices_to_grid (self ,mark_coords = [] ,wall = "#" ):
105+ def vertices_to_grid (self ,mark_coords = {} ,wall = "#" ):
106106"""
107107 Converts a set of coordinates to a text
108108
109109 The text will be separated by newline characters
110110
111- :paramlist mark_coords: List ofcoordonates to mark
111+ :paramdict mark_coords: List ofcoordinates to mark, with letter to use
112112 :param string wall: Which character to use as walls
113113 :return: True if the grid was converted
114114 """
@@ -117,19 +117,21 @@ def vertices_to_grid(self, mark_coords=[], wall="#"):
117117min_y ,max_y = int (max_imag (self .vertices )),int (min_imag (self .vertices ))
118118min_x ,max_x = int (min_real (self .vertices )),int (max_real (self .vertices ))
119119
120- if isinstance (next (iter (self .vertices )),dict ):
121- vertices = self .vertices .keys ()
122- else :
123- vertices = self .vertices
124-
125120for y in range (min_y ,max_y - 1 ,- 1 ):
126121for x in range (min_x ,max_x + 1 ):
127- if x + y * 1j in mark_coords :
128- grid += "X"
129- elif x + y * 1j in vertices :
130- grid += "."
131- else :
132- grid += wall
122+ try :
123+ grid += mark_coords [x + y * 1j ]
124+ except KeyError :
125+ if x + y * 1j in mark_coords :
126+ grid += "X"
127+ else :
128+ try :
129+ grid += self .vertices .get (x + y * 1j ,wall )
130+ except AttributeError :
131+ if x + y * 1j in self .vertices :
132+ grid += "."
133+ else :
134+ grid += wall
133135grid += "\n "
134136
135137return grid
@@ -160,7 +162,7 @@ def add_walls(self, vertices):
160162for vertex in vertices :
161163if vertex in self .edges :
162164del self .edges [vertex ]
163- del self .vertices [ vertex ]
165+ self .vertices . remove ( vertex )
164166changed = True
165167
166168self .edges = {