|
@@ -113,7 +113,7 @@ class Application(tk.Frame):
|
113
|
113
|
#GENERIERUNG DES LABYRINTHS
|
114
|
114
|
class Maze(object):
|
115
|
115
|
|
116
|
|
- def __init__(self, width=21, height=21, exit_cell=(19,1)): #Initierung des Rahmens des Maze, sowie Start und Ziel Festlegung
|
|
116
|
+ def __init__(self, width=21, height=21, exit_cell=(width - 2,1)): #Initierung des Rahmens des Maze, sowie Start und Ziel Festlegung
|
117
|
117
|
self.width = width
|
118
|
118
|
self.height = height
|
119
|
119
|
self.exit_cell = exit_cell
|
|
@@ -147,15 +147,15 @@ class Maze(object):
|
147
|
147
|
# # # # # # # # # # # # # #
|
148
|
148
|
# b # a # b # # b # # # # #
|
149
|
149
|
# # # # # # # # # # # # # #
|
150
|
|
- # # # b # # # # # # # # # #
|
|
150
|
+ # # # b # # # # # # # # # #
|
151
|
151
|
# # # # # # # # # # # # # #
|
152
|
152
|
"""
|
153
|
153
|
x, y = cell
|
154
|
154
|
neighbors = []
|
155
|
155
|
|
156
|
|
- # links
|
157
|
|
- if x - 2 > 0:
|
158
|
|
- neighbors.append((x-2, y))
|
|
156
|
+ # links #die Koordinaten der Zelle wird mit den Koordinaten der moeglichen
|
|
157
|
+ if x - 2 > 0: #Nachbarzelle abgeglichen. Sind die Koordinaten verfuegbar,
|
|
158
|
+ neighbors.append((x-2, y)) #entsteht eine Nachbarzelle
|
159
|
159
|
# rechts
|
160
|
160
|
if x + 2 < self.width:
|
161
|
161
|
neighbors.append((x+2, y))
|
|
@@ -169,7 +169,7 @@ class Maze(object):
|
169
|
169
|
return neighbors
|
170
|
170
|
|
171
|
171
|
def _remove_wall(self, cell, neighbor):
|
172
|
|
- """
|
|
172
|
+ """
|
173
|
173
|
Entferne die Wand zwischen den beiden Zellen
|
174
|
174
|
Beispiel:
|
175
|
175
|
Die Wand zwischen a und b ist w
|
|
@@ -181,7 +181,7 @@ class Maze(object):
|
181
|
181
|
"""
|
182
|
182
|
x0, y0 = cell
|
183
|
183
|
x1, y1 = neighbor
|
184
|
|
- # vertikal
|
|
184
|
+ # vertikal #
|
185
|
185
|
if x0 == x1:
|
186
|
186
|
x = x0
|
187
|
187
|
y = (y0 + y1) / 2
|
|
@@ -191,6 +191,8 @@ class Maze(object):
|
191
|
191
|
y = y0
|
192
|
192
|
self.maze[y][x] = 0
|
193
|
193
|
|
|
194
|
+
|
|
195
|
+#RUECKVERFOLGUNG DES WEGES
|
194
|
196
|
def _update_start_cell(self, cell, depth):
|
195
|
197
|
if depth > self.recursion_depth:
|
196
|
198
|
self.recursion_depth = depth
|
|
@@ -213,8 +215,10 @@ class Maze(object):
|
213
|
215
|
print "Steps from A to B:", self.steps
|
214
|
216
|
|
215
|
217
|
|
216
|
|
-if __name__ == '__main__':
|
217
|
218
|
|
|
219
|
+#ZUSATZ: OPTIONEN/HILFEN
|
|
220
|
+if __name__ == '__main__': #optparse wird eingesetzt, um den jeweiligen Stand/Status abzufragen
|
|
221
|
+
|
218
|
222
|
from optparse import OptionParser
|
219
|
223
|
|
220
|
224
|
parser = OptionParser(description="Random maze game")
|
|
@@ -226,7 +230,7 @@ if __name__ == '__main__':
|
226
|
230
|
help="cell size (default 10)")
|
227
|
231
|
args, _ = parser.parse_args()
|
228
|
232
|
|
229
|
|
- for arg in ('width', 'height'):
|
|
233
|
+ for arg in ('width', 'height'): #Option verfuegbar, die Hoehe und Breite zu aendern
|
230
|
234
|
if getattr(args, arg) % 2 == 0:
|
231
|
235
|
setattr(args, arg, getattr(args, arg) + 1)
|
232
|
236
|
print "Warning: %s muss ungerade sein, benutze %d stattdessen" % \
|