-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgavinsPart.py
More file actions
628 lines (604 loc) · 28 KB
/
Copy pathgavinsPart.py
File metadata and controls
628 lines (604 loc) · 28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
import time
global override
override = False
class Cell:
def __init__(self, cols, rows): # constructor
self.cols = cols
self.rows = rows
self.value = 99
self.wallN = False
self.wallS = False
self.wallE = False
self.wallW = False
self.onBestPath = False
def setOnBestPath(self): # makes something on the best path
self.onBestPath = True
def setWall(self, direction): # makes a wall at specified direction
if direction == "N":
self.wallN = True
if direction == "S":
self.wallS = True
if direction == "E":
self.wallE = True
if direction == "W":
self.wallW = True
def updateWalls(self): # updates the walls of the cell with the walls of adjacent cells
if self.cols < cols - 1:
if array_2d[self.rows][self.cols + 1].wallW:
self.wallE = True
if self.cols > 0:
if array_2d[self.rows][self.cols - 1].wallE:
self.wallW = True
if self.rows < rows - 1:
if array_2d[self.rows + 1][self.cols].wallN:
self.wallS = True
if self.rows > 0:
if array_2d[self.rows - 1][self.cols].wallS:
self.wallN = True
def setVal(self, value): # sets the value(cells from center) of the cell
self.value = value
def updateVal(self): # updates the value of the cell with the value of adjacent cells
if self.cols < cols - 1:
if array_2d[self.rows][self.cols + 1].value + 1 < self.value and not self.wallE:
self.value = array_2d[self.rows][self.cols + 1].value + 1
"""
if the cell to the right of the cell's value + 1 is less than the
current cell's value, then it sets the current cell's value to the
right cell's value + 1
"""
if self.cols > 0:
if array_2d[self.rows][self.cols - 1].value + 1 < self.value and not self.wallW:
self.value = array_2d[self.rows][self.cols - 1].value + 1
if self.rows < rows - 1:
if array_2d[self.rows + 1][self.cols].value + 1 < self.value and not self.wallS:
self.value = array_2d[self.rows + 1][self.cols].value + 1
if self.rows > 0:
if array_2d[self.rows - 1][self.cols].value + 1 < self.value and not self.wallN:
self.value = array_2d[self.rows - 1][self.cols].value + 1
# setting up base values and the array itself
rows, cols = 16, 16
array_2d = [[Cell(j, i) for j in range(cols)] for i in range(rows)]
array_2d[7][7].setVal(0)
array_2d[8][7].setVal(0)
array_2d[7][8].setVal(0)
array_2d[8][8].setVal(0)
def printArrayVals(): # prints the array with the values of the cells accounting for if it is on the best path or not and if there are walls in a specified direction
print("\n\n")
for i in range (rows):
print("[ ", end = "")
for j in range (cols):
if(array_2d[i][j].value < 10):
if(array_2d[i][j].wallE and j < 15):
if(array_2d[i][j].wallS and i < 15):
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + "\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = "\x1B[4m" + " " + "\x1B[0m" + "|")
else:
print("\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = "\x1B[4m" + " " + "\x1B[0m" + "|")
else:
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + str(array_2d[i][j].value) + "\x1B[0m", end = " |")
else:
print(array_2d[i][j].value, end = " |")
else:
if(array_2d[i][j].wallS and i < 15):
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + "\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = "\x1B[4m" + " " + "\x1B[0m" + " ")
else:
print("\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = "\x1B[4m" + " " + "\x1B[0m" + " ")
else:
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + str(array_2d[i][j].value) + "\x1B[0m", end = " ")
else:
print(array_2d[i][j].value, end = " ")
else:
if(array_2d[i][j].wallE and j < 15):
if(array_2d[i][j].wallS and i < 15):
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + "\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = "|")
else:
print("\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = "|")
else:
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + str(array_2d[i][j].value) + "\x1B[0m", end = "|")
else:
print(array_2d[i][j].value, end = "|")
else:
if(array_2d[i][j].wallS and i < 15):
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + "\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = " ")
else:
print("\x1B[4m" + str(array_2d[i][j].value) + "\x1B[0m", end = " ")
else:
if(array_2d[i][j].onBestPath):
print("\x1b[35m" + str(array_2d[i][j].value) + "\x1B[0m", end = " ")
else:
print(array_2d[i][j].value, end = " ")
print ("]")
print("^^^")
def findDistance(self): # finds the distnce of the furthest cell in a a straight line that is on the best path and moves the mouse to that cell
if(self.direction == "E"):
val = 0
for i in range (1, cols):
if(self.col < cols - i and self.maze[self.row][self.col + i].onBestPath and not self.maze[self.row][self.col + (i - 1)].wallE):
val += 1
else:
break
if(val == 1 and diag):
print("diag")
diagonal(self)
else:
self.moveForward(val)
if(self.direction == "W"):
val = 0
for i in range (1, cols):
if(self.col > i - 1 and self.maze[self.row][self.col - i].onBestPath and not self.maze[self.row][self.col - (i - 1)].wallW):
val += 1
else:
break
if(val == 1 and diag):
print("diag")
diagonal(self)
else:
self.moveForward(val)
if(self.direction == "N"):
val = 0
for i in range (1, rows):
if(self.row > i - i and self.maze[self.row - i][self.col].onBestPath and not self.maze[self.row - (i - 1)][self.col].wallN):
val += 1
else:
break
if(val == 1 and diag):
print("diag")
diagonal(self)
else:
self.moveForward(val)
if(self.direction == "S"):
val = 0
for i in range (1, rows):
if(self.row < rows - i and self.maze[self.row + i][self.col].onBestPath and not self.maze[self.row + (i - 1)][self.col].wallS):
val += 1
else:
break
if(val == 1 and diag):
print("diag")
diagonal(self)
else:
self.moveForward(val)
def findDistanceDiag(self): # finds the distnce of the furthest cell in a a diagonal line that is on the best path and moves the mouse to that cell
print(self.direction)
if(self.direction == "E"):
val = 0
for i in range (1, cols):
if(self.col < cols - i and self.maze[self.row][self.col + i].onBestPath and not self.maze[self.row][self.col + (i - 1)].wallE):
val += 1
else:
break
if(val == 1 and diag):
print("diag (fake)")
return True
else:
return False
if(self.direction == "W"):
val = 0
for i in range (1, cols):
if(self.col > i - 1 and self.maze[self.row][self.col - i].onBestPath and not self.maze[self.row][self.col - (i - 1)].wallW):
val += 1
else:
break
if(val == 1 and diag):
print("diag (fake)")
return True
else:
return False
if(self.direction == "N"):
val = 0
for i in range (1, rows):
if(self.row > i - i and self.maze[self.row - i][self.col].onBestPath and not self.maze[self.row - (i - 1)][self.col].wallN):
val += 1
else:
break
if(val == 1 and diag):
print("diag (fake)")
return True
else:
return False
if(self.direction == "S"):
val = 0
for i in range (1, rows):
if(self.row < rows - i and self.maze[self.row + i][self.col].onBestPath and not self.maze[self.row + (i - 1)][self.col].wallS):
val += 1
else:
break
if(val == 1 and diag):
print("diag (fake)")
return True
else:
return False
def diagonal(self): # moves the mouse diagonally to the end of the diagonal line
next = True
while(next):
next = mouse1.followBestPath(False)
def updateArrayVals(): # updates the values of the cells in the array accounting for new walls
for s in range (99):
for i in range (rows):
for j in range (cols):
array_2d[i][j].updateVal()
def resetArrayVals(): # resets the values of the cells in the array (called in conjunction with updateArrayVals())
global override
for i in range (rows):
for j in range (cols):
array_2d[i][j].setVal(99)
if(not override):
array_2d[7][7].setVal(0)
array_2d[8][7].setVal(0)
array_2d[7][8].setVal(0)
array_2d[8][8].setVal(0)
else:
array_2d[0][0].setVal(0)
def updateArrayWalls(): # updates the walls of the cells in the array
for i in range (rows):
for j in range (cols):
array_2d[i][j].updateWalls()
def findBestPath(rowS, colS): # finds the best path from the mouse's current position to the center using the cell values(does not account for diagonal turns being slightly faster despite more distance)
resetBestPath()
rowsC = rowS
colsC = colS
currentCell = array_2d[rowsC][colsC]
for i in range (99):
currentCell.setOnBestPath()
if(colsC < cols - 1):
if(array_2d[rowsC][colsC + 1].value == currentCell.value - 1 and not currentCell.wallE):
currentCell = array_2d[rowsC][colsC + 1]
if(colsC > 0):
if(array_2d[rowsC][colsC - 1].value == currentCell.value - 1 and not currentCell.wallW):
currentCell = array_2d[rowsC][colsC - 1]
if(rowsC < rows - 1):
if(array_2d[rowsC + 1][colsC].value == currentCell.value - 1 and not currentCell.wallS):
currentCell = array_2d[rowsC + 1][colsC]
if(rowsC > 0):
if(array_2d[rowsC - 1][colsC].value == currentCell.value - 1 and not currentCell.wallN):
currentCell = array_2d[rowsC - 1][colsC]
rowsC = currentCell.rows
colsC = currentCell.cols
def resetBestPath(): # resets the best path of the cells in the array (called in conjunction with findBestPath())
for i in range (rows):
for j in range (cols):
array_2d[i][j].onBestPath = False
class Mouse: # defines the class of mouse and its base values and methods
def __init__(self, maze):
self.direction = "E"
self.row = 0
self.col = 0
self.wallN = False
self.wallS = False
self.wallE = False
self.wallW = False
self.wallF = False
self.wallR = False
self.wallL = False
self.maze = maze
self.currentCell = self.maze[self.row][self.col]
def turn90(self): # turns the mouse 90 degrees to the right
if(self.direction == "N"):
self.direction = "E"
return
if(self.direction == "E"):
self.direction = "S"
return
if(self.direction == "S"):
self.direction = "W"
return
if(self.direction == "W"):
self.direction = "N"
return
def turnNeg90(self): # turns the mouse 90 degrees to the left
if(self.direction == "N"):
self.direction = "W"
return
if(self.direction == "W"):
self.direction = "S"
return
if(self.direction == "S"):
self.direction = "E"
return
if(self.direction == "E"):
self.direction = "N"
return
def moveForward(self, amount): # moves the mouse forward a specified amount of cells
if(self.direction == "N"):
self.row -= amount
if(self.direction == "S"):
self.row += amount
if(self.direction == "E"):
self.col += amount
if(self.direction == "W"):
self.col -= amount
self.currentCell = self.maze[self.row][self.col]
def movePosForward(self, amount): # moves the mouse's position forward a specified amount of cells (used for diagonal movement)
if(self.direction == "N"):
self.row -= amount
if(self.direction == "S"):
self.row += amount
if(self.direction == "E"):
self.col += amount
if(self.direction == "W"):
self.col -= amount
self.currentCell = self.maze[self.row][self.col]
def detectWalls(self): # detects the walls around the mouse
if():
self.wallR = True
if():
self.wallL = True
if():
self.wallF = True
def updateWalls(self): # updates the walls of the cell the mouse is on with the walls the mouse detects
if(self.wallF):
self.currentCell.setWall(self.direction)
updateArrayWalls()
resetArrayVals()
updateArrayVals()
if(self.wallR):
if(self.direction == "N"):
self.currentCell.setWall("E")
if(self.direction == "W"):
self.currentCell.setWall("N")
if(self.direction == "S"):
self.currentCell.setWall("W")
if(self.direction == "E"):
self.currentCell.setWall("S")
updateArrayWalls()
resetArrayVals()
updateArrayVals()
if(self.wallL):
if(self.direction == "N"):
self.currentCell.setWall("W")
if(self.direction == "W"):
self.currentCell.setWall("S")
if(self.direction == "S"):
self.currentCell.setWall("E")
if(self.direction == "E"):
self.currentCell.setWall("N")
updateArrayWalls()
resetArrayVals()
updateArrayVals()
def followBestPath(self, real): # follows the best path from the mouse's current position to the center using the cell values(has different modes for mapping and diagonal movement)
findBestPath(self.row, self.col)
if(real):
if(mapping):
if(self.direction == "E"):
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.moveForward(1)
return
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turn90()
self.moveForward(1)
return
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turnNeg90()
self.moveForward(1)
return
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turn90()
self.turn90()
self.moveForward(1)
return
if(self.direction == "W"):
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.moveForward(1)
return
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turnNeg90()
self.moveForward(1)
return
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turn90()
self.moveForward(1)
return
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turn90()
self.turn90()
self.moveForward(1)
return
if(self.direction == "N"):
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.moveForward(1)
return
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turn90()
self.moveForward(1)
return
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turnNeg90()
self.moveForward(1)
return
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turn90()
self.turn90()
self.moveForward(1)
return
if(self.direction == "S"):
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.moveForward(1)
return
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turnNeg90()
self.moveForward(1)
return
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turn90()
self.moveForward(1)
return
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turn90()
self.turn90()
self.moveForward(1)
return
else:
if(self.direction == "E"):
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
findDistance(self)
return
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turn90()
findDistance(self)
return
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turnNeg90()
findDistance(self)
return
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turn90()
self.turn90()
findDistance(self)
return
if(self.direction == "W"):
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
findDistance(self)
return
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turnNeg90()
findDistance(self)
return
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turn90()
findDistance(self)
return
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turn90()
self.turn90()
findDistance(self)
return
if(self.direction == "N"):
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
findDistance(self)
return
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turn90()
findDistance(self)
return
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turnNeg90()
findDistance(self)
return
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turn90()
self.turn90()
findDistance(self)
return
if(self.direction == "S"):
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
findDistance(self)
return
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turnNeg90()
findDistance(self)
return
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turn90()
findDistance(self)
return
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turn90()
self.turn90()
findDistance(self)
return
else:
if(self.direction == "E"):
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turn90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turnNeg90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.direction == "W"):
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
self.turnNeg90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
self.turn90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.direction == "N"):
if(self.row > 0 and self.maze[self.row - 1][self.col].onBestPath and not self.maze[self.row][self.col].wallN):
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turn90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turnNeg90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.direction == "S"):
if(self.row < rows - 1 and self.maze[self.row + 1][self.col].onBestPath and not self.maze[self.row][self.col].wallS):
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.col < cols - 1 and self.maze[self.row][self.col + 1].onBestPath and not self.maze[self.row][self.col].wallE):
self.turnNeg90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
if(self.col > 0 and self.maze[self.row][self.col - 1].onBestPath and not self.maze[self.row][self.col].wallW):
self.turn90()
next = findDistanceDiag(self)
self.movePosForward(1)
return next
mouse1 = Mouse(array_2d)
printArrayVals()
updateArrayVals()
printArrayVals()
array_2d[7][7].setWall("N")
array_2d[7][7].setWall("W")
array_2d[8][7].setWall("W")
array_2d[7][8].setWall("N")
array_2d[8][8].setWall("E")
array_2d[8][8].setWall("S")
array_2d[8][7].setWall("S")
for i in range (rows - 10):
array_2d[i][i].setWall("S")
array_2d[i][i].setWall("W")
array_2d[i][i + 1].setWall("N")
array_2d[i][i + 1].setWall("E")
updateArrayWalls()
resetArrayVals()
updateArrayVals()
findBestPath(mouse1.row, mouse1.col)
printArrayVals()
mapping = False
diag = True
def loop():
global override
for i in range (99): # main loop
printArrayVals()
print(mouse1.row, mouse1.col, mouse1.currentCell.value, mouse1.currentCell.rows, mouse1.currentCell.cols, mouse1.direction)
updateArrayWalls()
resetArrayVals()
updateArrayVals()
if(mouse1.currentCell.value == 0):
time.sleep(3)
override = True
mouse1.followBestPath(True)
loop()
# Turn 45 implementation
# exiting diagonal turns
# turns during diagonals