forked from berickcook/AIRIS_Public
-
Notifications
You must be signed in to change notification settings - Fork 1
/
puzzle_game_driver.py
1297 lines (1106 loc) · 49.6 KB
/
puzzle_game_driver.py
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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import pygame
import time, sys
from pygame.locals import QUIT, KEYDOWN
from game_objects import *
from airis_stable import AIRIS
from constants import *
from other_useful_functions import pprint
import datetime
class PyGameView(object):
'''
PyGameView controls the display
'''
def __init__(self, model):
self.model = model
self.screen = pygame.display.set_mode(GAME_SCREEN_SIZE) # a pygame screen
self.surface = pygame.Surface(GAME_SCREEN_SIZE) # a pygame surface is the thing you draw on
self.show_view = True # toggle display
self.show_controls = False # toggle control display
self.mind_index_prev = 0
self.rep_map = []
w, h = GAME_MAP_GRID
for x in range(w):
self.rep_map.append([])
for y in range(h):
self.rep_map[x].append(0)
def draw(self):
# commented out because we're only updating squares if they change
# # fill background
# self.surface.fill(pygame.Color('black'))
self.draw_game_map()
self.draw_representation_map()
# draw control key
if self.show_controls:
for n, line in enumerate(PUZZLE_GAME_CONTROL_KEY):
self.draw_text(line, PUZZLE_GAME_CONTROL_KEY_START[0], \
PUZZLE_GAME_CONTROL_KEY_START[1]+14*n, 20)
# update display
pygame.display.update()
def draw_game_map(self):
# variable setup
w, h = GAME_MAP_GRID # number of positions wide and high
ms = GAME_MAP_START
# draw each position in the grid
for x in range(w):
for y in range(h):
if self.model.change_in_game_map[x][y]:
self.model.game_map[x][y].draw_game_image(self, x, y)
def draw_representation_map(self):
# variable setup
w, h = REP_MAP_GRID # number of positions wide and high
ms = REP_MAP_START
if not self.model.controller.bypass and self.model.airis.display_hold:
self.model.controller.mind_len = len(self.model.airis.display_plan)
if self.mind_index_prev != self.model.controller.mind_index:
print('Viewing plan step ' + str(self.model.controller.mind_index) + ' of ' + str(
self.model.controller.mind_len - 1) + ' (predicted result)')
self.mind_index_prev = self.model.controller.mind_index
# draw each position in the grid
try:
for x in range(w):
for y in range(h):
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 0:
self.rep_map[x][y] = self.model.floor
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 1:
self.rep_map[x][y] = self.model.character
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 2:
self.rep_map[x][y] = self.model.wall
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 3:
self.rep_map[x][y] = self.model.battery
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 4:
self.rep_map[x][y] = self.model.door
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 5:
self.rep_map[x][y] = self.model.key
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 6:
self.rep_map[x][y] = self.model.extinguisher
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 7:
self.rep_map[x][y] = self.model.fire
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 8:
self.rep_map[x][y] = self.model.right_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 9:
self.rep_map[x][y] = self.model.left_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 10:
self.rep_map[x][y] = self.model.down_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 11:
self.rep_map[x][y] = self.model.up_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 12:
self.rep_map[x][y] = self.model.open_door
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 13:
self.rep_map[x][y] = self.model.character_on_right_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 14:
self.rep_map[x][y] = self.model.character_on_left_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 15:
self.rep_map[x][y] = self.model.character_on_down_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 16:
self.rep_map[x][y] = self.model.character_on_up_arrow
if self.model.airis.models[self.model.airis.display_plan[self.model.controller.mind_index]].vis_env[x][y] == 17:
self.rep_map[x][y] = self.model.character_on_open_door
self.rep_map[x][y].draw_representation_image(self, x, y)
except:
pass
else:
for x in range(w):
for y in range(h):
if self.model.change_in_game_map[x][y]:
self.model.game_map[x][y].draw_representation_image(self, x, y)
def draw_text(self, text, x, y, size, color = (100, 100, 100)):
basicfont = pygame.font.SysFont(None, size)
text_render = basicfont.render(
text, True, color)
self.surface.blit(text_render, (x, y))
class Model(object):
'''
Model represents the state of all entities in
the environment and drawing parameters
'''
# this function initializes the model
def __init__(self, controller, airis_controlled):
'''
initialize model, environment, and default keyboard controller states
Args:
width (int): width of window in pixels
height (int): height of window in pixels
'''
# game setup parameters
self.show = True # show current model
self.controller = controller
# maze game setup
self.make_singletons()
self.current_maze = 0
self.get_next_maze()
self.player_action = "up"
# AGI setup
self.screen_input = []
for x in range(GAME_MAP_GRID[0]):
self.screen_input.append([])
for y in range(GAME_MAP_GRID[1]):
self.screen_input[x].append(0.0)
self.aux_input = [self.keys_collected, self.extinguishers_collected]
action_space = ['up', 'down', 'left', 'right', 'nothing']
#action_output_list = output range of each action [min, max, increment size]
action_output_list = [
[1, 2, 1],
[1, 2, 1],
[1, 2, 1],
[1, 2, 1],
[1, 2, 1]
]
self.airis = AIRIS(self.screen_input, self.aux_input, action_space, action_output_list)
self.airis_controlled = airis_controlled
if not airis_controlled:
self.airis.goal_type = 'Observe'
self.airis.goal_type_default = 'Observe'
self.time_counter = 0
# this function updates the model
def update(self):
pprint('-------------------------------------------- TIME STEP %d --------------------------------------------'
% self.time_counter, new_line_start=True, draw_line=False)
self.time_counter += 1
self.set_change_in_game_map(False)
# get user input
if not self.airis.display_hold or self.controller.bypass:
self.player_action = 'up'
if not self.airis_controlled:
self.player_action = self.get_action()
# input environment to airis
self.current_environment()
if self.airis_controlled:
self.player_action, _, _ = self.airis.capture_input(
self.screen_input,
self.aux_input,
self.player_action, prior=True)
else:
self.airis.capture_input(
self.screen_input,
self.aux_input,
self.player_action, prior=True)
pprint('ACTION:\t%s' % self.player_action, new_line_start=True, draw_line=False)
if self.airis.display_hold and not self.controller.bypass:
self.controller.paused = True
self.controller.mind_index = 0
print ('Awaiting plan approval...')
if not self.controller.paused or self.controller.bypass:
self.airis.display_hold = False
# update the model according to the player's input
self.game_logic(self.player_action)
# go to next level if player beats the current level
if self.batteries_collected == self.num_batteries:
self.get_next_maze()
# reset the maze if the character dies
if self.maze_reset:
self.get_next_maze()
# input environment to airis
self.current_environment()
self.airis.capture_input(
self.screen_input,
self.aux_input,
self.player_action, prior=False)
# user_input = input()
# sys.exit()
# these functions interact with AIRIS
def get_action(self):
return self.controller.player_input
def current_environment(self):
for x in range(GAME_MAP_GRID[0]):
for y in range(GAME_MAP_GRID[1]):
self.screen_input[x][y] = self.game_map[x][y].id
self.aux_input[0] = self.keys_collected
self.aux_input[1] = self.extinguishers_collected
# these functions controls game logic
def game_logic(self, player_input):
if player_input != 'nothing':
if player_input == 'up':
character_new_pos = \
(self.character_current_pos[0], \
self.character_current_pos[1] - 1)
if player_input == 'down':
character_new_pos = \
(self.character_current_pos[0], \
self.character_current_pos[1] + 1)
if player_input == 'left':
character_new_pos = \
(self.character_current_pos[0] - 1, \
self.character_current_pos[1])
if player_input == 'right':
character_new_pos = \
(self.character_current_pos[0] + 1, \
self.character_current_pos[1])
new_tile = self.game_map[character_new_pos[0]][character_new_pos[1]]
if isinstance(new_tile, Floor):
self.move_character(new_tile, character_new_pos, self.character)
elif isinstance(new_tile, Wall):
pass
elif isinstance(new_tile, Battery):
self.move_character(new_tile, character_new_pos, self.character)
self.collect_battery(character_new_pos)
elif isinstance(new_tile, RightArrow):
if player_input != 'left':
self.move_character(new_tile, \
character_new_pos, self.character_on_right_arrow)
elif isinstance(new_tile, LeftArrow):
if player_input != 'right':
self.move_character(new_tile, \
character_new_pos, self.character_on_left_arrow)
elif isinstance(new_tile, UpArrow):
if player_input != 'down':
self.move_character(new_tile, \
character_new_pos, self.character_on_up_arrow)
elif isinstance(new_tile, DownArrow):
if player_input != 'up':
self.move_character(new_tile, \
character_new_pos, self.character_on_down_arrow)
elif isinstance(new_tile, Fire):
if self.extinguishers_collected == 0:
self.reset_maze()
else:
self.move_character(new_tile, character_new_pos, self.character)
self.character_current_floor = self.floor
self.extinguishers_collected -= 1
elif isinstance(new_tile, Extinguisher):
self.move_character(new_tile, character_new_pos, self.character)
self.collect_extinguisher(character_new_pos)
elif isinstance(new_tile, Door):
if self.keys_collected == 0:
pass
else:
self.move_character(new_tile, \
character_new_pos, self.character_on_open_door)
self.keys_collected -= 1
elif isinstance(new_tile, OpenDoor):
self.move_character(new_tile, character_new_pos, self.character_on_open_door)
elif isinstance(new_tile, Key):
self.move_character(new_tile, character_new_pos, self.character)
self.collect_key(character_new_pos)
def move_character(self, new_tile, character_new_pos, character_and_floor):
character_old_floor = self.character_current_floor
character_old_pos = self.character_current_pos
if character_and_floor != self.character_on_open_door:
self.character_current_floor = new_tile
else:
self.character_current_floor = self.open_door
self.character_current_pos = character_new_pos
self.game_map\
[self.character_current_pos[0]] \
[self.character_current_pos[1]] \
= character_and_floor
self.change_in_game_map\
[self.character_current_pos[0]] \
[self.character_current_pos[1]] \
= True
self.game_map\
[character_old_pos[0]] \
[character_old_pos[1]] \
= character_old_floor
self.change_in_game_map\
[character_old_pos[0]] \
[character_old_pos[1]] \
= True
def collect_battery(self, character_new_pos):
self.batteries_collected += 1
self.character_current_floor = self.floor
def collect_extinguisher(self, character_new_pos):
self.extinguishers_collected += 1
self.character_current_floor = self.floor
def collect_key(self, character_new_pos):
self.keys_collected += 1
self.character_current_floor = self.floor
def reset_maze(self):
self.current_maze -= 1
self.maze_reset = True
# self.update()
# these functions initialize the maze levels
def test_maze(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# test every type of tile
game_map[0][1] = self.character
game_map[0][2] = self.floor
game_map[0][3] = self.wall
game_map[0][4] = self.fire
game_map[0][5] = self.extinguisher
game_map[0][6] = self.battery
game_map[0][7] = self.key
game_map[0][8] = self.door
game_map[0][9] = self.open_door
game_map[1][1] = self.right_arrow
game_map[1][2] = self.left_arrow
game_map[1][3] = self.down_arrow
game_map[1][4] = self.up_arrow
game_map[1][5] = self.character_on_right_arrow
game_map[1][6] = self.character_on_left_arrow
game_map[1][7] = self.character_on_down_arrow
game_map[1][8] = self.character_on_up_arrow
game_map[1][9] = self.character_on_open_door
self.num_batteries = 1
self.game_map = game_map
self.character_start_pos = (0,1)
self.character_current_pos = (0,1)
self.character_current_floor = self.floor
def maze1(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 4, 16, 2)
game_map = self.draw_wall_row(game_map, 4, 16, 12)
game_map = self.draw_wall_row(game_map, 7, 15, 5)
game_map = self.draw_wall_col(game_map, 3, 11, 4)
game_map = self.draw_wall_col(game_map, 3, 11, 16)
game_map = self.draw_wall_col(game_map, 8, 11, 8)
game_map = self.draw_wall_col(game_map, 8, 11, 12)
game_map[5][8] = self.wall
game_map[7][8] = self.wall
game_map[9][8] = self.wall
game_map[11][8] = self.wall
game_map[13][8] = self.wall
game_map[15][8] = self.wall
# initialize all the batteries
game_map[15][3] = self.battery
game_map[6][10] = self.battery
game_map[14][10] = self.battery
self.num_batteries = 3
# initialize the character
game_map[10][10] = self.character
self.character_start_pos = (10, 10)
self.character_current_pos = (10, 10)
self.character_current_floor = self.floor
self.game_map = game_map
def maze2(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 5, 13, 1)
game_map = self.draw_wall_row(game_map, 2, 5, 5)
game_map = self.draw_wall_row(game_map, 2, 5, 9)
game_map = self.draw_wall_row(game_map, 5, 13, 13)
game_map = self.draw_wall_col(game_map, 5, 9, 2)
game_map = self.draw_wall_col(game_map, 1, 5, 5)
game_map = self.draw_wall_col(game_map, 9, 13, 5)
game_map = self.draw_wall_col(game_map, 4, 10, 8)
game_map = self.draw_wall_col(game_map, 4, 6, 10)
game_map = self.draw_wall_col(game_map, 8, 10, 10)
game_map = self.draw_wall_col(game_map, 1, 13, 13)
# initialize all the arrows
game_map = self.draw_arrow_row(game_map, 6, 7, 5, 'd')
game_map = self.draw_arrow_row(game_map, 11, 12, 4, 'u')
game_map[9][4] = self.up_arrow
game_map[10][7] = self.left_arrow
game_map[9][10] = self.up_arrow
# initialize all the batteries
game_map[6][4] = self.battery
game_map[9][2] = self.battery
game_map[9][7] = self.battery
game_map[12][5] = self.battery
self.num_batteries = 4
# initialize the character
game_map[4][7] = self.character
self.character_start_pos = (4, 7)
self.character_current_pos = (4, 7)
self.character_current_floor = self.floor
self.game_map = game_map
def maze3(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 3, 16, 5)
game_map = self.draw_wall_row(game_map, 3, 16, 9)
game_map = self.draw_wall_col(game_map, 5, 9, 3)
game_map = self.draw_wall_col(game_map, 5, 9, 16)
# initialize all the arrows
game_map[7][6] = self.up_arrow
game_map[8][6] = self.right_arrow
game_map[9][6] = self.down_arrow
game_map[10][6] = self.right_arrow
game_map[11][6] = self.right_arrow
game_map[12][6] = self.up_arrow
game_map[7][7] = self.right_arrow
game_map[8][7] = self.right_arrow
game_map[9][7] = self.right_arrow
game_map[10][7] = self.left_arrow
game_map[11][7] = self.right_arrow
game_map[12][7] = self.right_arrow
game_map[7][8] = self.right_arrow
game_map[8][8] = self.left_arrow
game_map[9][8] = self.right_arrow
game_map[10][8] = self.right_arrow
game_map[11][8] = self.up_arrow
game_map[12][8] = self.right_arrow
# initialize all the batteries
game_map[5][7] = self.battery
self.num_batteries = 1
# initialize the character
game_map[14][7] = self.character
self.character_start_pos = (14, 7)
self.character_current_pos = (14, 7)
self.character_current_floor = self.floor
self.game_map = game_map
def maze4(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 3, 17, 0)
game_map = self.draw_wall_row(game_map, 5, 8, 5)
game_map = self.draw_wall_row(game_map, 12, 15, 5)
game_map = self.draw_wall_row(game_map, 5, 8, 9)
game_map = self.draw_wall_row(game_map, 12, 15, 9)
game_map = self.draw_wall_row(game_map, 3, 17, 14)
game_map = self.draw_wall_col(game_map, 0, 14, 3)
game_map = self.draw_wall_col(game_map, 2, 5, 8)
game_map = self.draw_wall_col(game_map, 9, 12, 8)
game_map = self.draw_wall_col(game_map, 2, 5, 12)
game_map = self.draw_wall_col(game_map, 9, 12, 12)
game_map = self.draw_wall_col(game_map, 0, 14, 17)
# initialize all the arrows
game_map[8][1] = self.right_arrow
game_map[12][1] = self.right_arrow
game_map = self.draw_arrow_row(game_map, 9, 11, 2, 'r')
game_map[4][5] = self.up_arrow
game_map[16][5] = self.down_arrow
game_map = self.draw_arrow_col(game_map, 6, 8, 5, 'r')
game_map = self.draw_arrow_col(game_map, 6, 8, 15, 'l')
game_map[4][9] = self.up_arrow
game_map[16][9] = self.down_arrow
game_map = self.draw_arrow_row(game_map, 9, 11, 12, 'u')
game_map[8][13] = self.left_arrow
game_map[12][13] = self.left_arrow
# initialize all the batteries
game_map[6][3] = self.battery
game_map[14][3] = self.battery
game_map[6][11] = self.battery
game_map[14][11] = self.battery
self.num_batteries = 4
# initialize the character
game_map[10][7] = self.character
self.character_start_pos = (10, 7)
self.character_current_pos = (10, 7)
self.character_current_floor = self.floor
self.game_map = game_map
def maze5(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 1, 18, 1)
game_map = self.draw_wall_row(game_map, 1, 3, 3)
game_map = self.draw_wall_row(game_map, 7, 8, 3)
game_map = self.draw_wall_row(game_map, 14, 16, 3)
game_map = self.draw_wall_row(game_map, 1, 2, 5)
game_map = self.draw_wall_row(game_map, 4, 6, 5)
game_map = self.draw_wall_row(game_map, 14, 16, 5)
game_map = self.draw_wall_row(game_map, 10, 12, 6)
game_map = self.draw_wall_row(game_map, 1, 4, 7)
game_map = self.draw_wall_row(game_map, 3, 8, 9)
game_map = self.draw_wall_row(game_map, 13, 15, 9)
game_map = self.draw_wall_row(game_map, 3, 5, 11)
game_map = self.draw_wall_row(game_map, 11, 14, 11)
game_map = self.draw_wall_row(game_map, 1, 18, 13)
game_map = self.draw_wall_col(game_map, 1, 13, 1)
game_map = self.draw_wall_col(game_map, 9, 11, 3)
game_map = self.draw_wall_col(game_map, 1, 3, 5)
game_map = self.draw_wall_col(game_map, 5, 7, 6)
game_map = self.draw_wall_col(game_map, 11, 13, 7)
game_map = self.draw_wall_col(game_map, 3, 9, 8)
game_map = self.draw_wall_col(game_map, 11, 13, 9)
game_map = self.draw_wall_col(game_map, 3, 6, 10)
game_map = self.draw_wall_col(game_map, 8, 9, 10)
game_map = self.draw_wall_col(game_map, 9, 11, 11)
game_map = self.draw_wall_col(game_map, 3, 4, 12)
game_map = self.draw_wall_col(game_map, 6, 7, 12)
game_map = self.draw_wall_col(game_map, 7, 9, 13)
game_map = self.draw_wall_col(game_map, 3, 5, 14)
game_map = self.draw_wall_col(game_map, 5, 9, 15)
game_map = self.draw_wall_col(game_map, 7, 9, 17)
game_map = self.draw_wall_col(game_map, 1, 13, 18)
game_map[16][11] = self.wall
# initialize all the arrows
game_map[10][2] = self.left_arrow
game_map[5][4] = self.left_arrow
game_map[13][5] = self.up_arrow
game_map[10][7] = self.right_arrow
game_map[7][10] = self.left_arrow
game_map[14][10] = self.right_arrow
game_map[14][12] = self.right_arrow
# initialize all the batteries
game_map[2][4] = self.battery
game_map[7][4] = self.battery
game_map[15][4] = self.battery
game_map[11][8] = self.battery
game_map[14][8] = self.battery
game_map[4][10] = self.battery
game_map[8][12] = self.battery
game_map[17][12] = self.battery
self.num_batteries = 8
# initialize the character
game_map[2][2] = self.character
self.character_start_pos = (2, 2)
self.character_current_pos = (2, 2)
self.character_current_floor = self.floor
self.game_map = game_map
def maze6(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 6, 14, 2)
game_map = self.draw_wall_row(game_map, 6, 11, 6)
game_map = self.draw_wall_row(game_map, 13, 14, 6)
game_map = self.draw_wall_row(game_map, 6, 14, 11)
game_map = self.draw_wall_col(game_map, 2, 11, 6)
game_map = self.draw_wall_col(game_map, 2, 6, 10)
game_map = self.draw_wall_col(game_map, 2, 11, 14)
# initialize all the doors
game_map[8][6] = self.door
# initialize all the keys
game_map[12][4] = self.key
# initialize all the batteries
game_map[8][4] = self.battery
self.num_batteries = 1
# initialize the character
game_map[10][9] = self.character
self.character_start_pos = (10, 9)
self.character_current_pos = (10, 9)
self.character_current_floor = self.floor
self.game_map = game_map
def maze7(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 7, 13, 1)
game_map = self.draw_wall_row(game_map, 7, 13, 12)
game_map = self.draw_wall_col(game_map, 1, 12, 7)
game_map = self.draw_wall_col(game_map, 1, 12, 13)
# initialize all the fire
game_map[8][2] = self.fire
game_map[9][2] = self.fire
game_map[10][2] = self.fire
game_map[11][3] = self.fire
game_map[9][4] = self.fire
game_map[10][5] = self.fire
game_map[8][6] = self.fire
game_map[11][6] = self.fire
game_map[9][7] = self.fire
game_map[12][7] = self.fire
game_map[10][8] = self.fire
game_map[8][9] = self.fire
game_map[12][9] = self.fire
# initialize all the batteries
game_map[11][2] = self.battery
self.num_batteries = 1
# initialize the character
game_map[10][10] = self.character
self.character_start_pos = (10, 10)
self.character_current_pos = (10, 10)
self.character_current_floor = self.floor
self.game_map = game_map
def maze8(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 2, 17, 2)
game_map = self.draw_wall_row(game_map, 5, 18, 6)
game_map = self.draw_wall_row(game_map, 5, 18, 8)
game_map = self.draw_wall_row(game_map, 2, 17, 12)
game_map = self.draw_wall_col(game_map, 2, 12, 2)
game_map = self.draw_wall_col(game_map, 2, 6, 5)
game_map = self.draw_wall_col(game_map, 8, 12, 5)
game_map = self.draw_wall_col(game_map, 2, 6, 9)
game_map = self.draw_wall_col(game_map, 8, 9, 9)
game_map = self.draw_wall_col(game_map, 11, 12, 9)
game_map = self.draw_wall_col(game_map, 2, 6, 13)
game_map = self.draw_wall_col(game_map, 8, 12, 13)
game_map = self.draw_wall_col(game_map, 2, 12, 17)
game_map = self.draw_wall_col(game_map, 6, 8, 18)
# initialize all the fire
game_map[17][7] = self.fire
# initialize all the doors
game_map[6][6] = self.door
game_map[11][6] = self.door
game_map[16][6] = self.door
game_map[6][8] = self.door
game_map[11][8] = self.door
game_map[16][8] = self.door
# initialize all the keys
game_map[7][4] = self.key
game_map[15][4] = self.key
game_map[3][11] = self.key
game_map[4][11] = self.key
game_map[7][10] = self.key
game_map[11][10] = self.key
# initialize all the batteries
#game_map[3][3] = self.battery
game_map[11][4] = self.battery
game_map[15][10] = self.battery
self.num_batteries = 2
# initialize the character
game_map[3][7] = self.character
self.character_start_pos = (3, 7)
self.character_current_pos = (3, 7)
self.character_current_floor = self.floor
self.game_map = game_map
def maze9(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 2, 12, 1)
game_map = self.draw_wall_row(game_map, 12, 16, 4)
game_map = self.draw_wall_row(game_map, 2, 8, 5)
game_map = self.draw_wall_row(game_map, 12, 16, 8)
game_map = self.draw_wall_row(game_map, 8, 12, 12)
game_map = self.draw_wall_col(game_map, 1, 5, 2)
game_map = self.draw_wall_col(game_map, 5, 12, 8)
game_map = self.draw_wall_col(game_map, 1, 4, 12)
game_map = self.draw_wall_col(game_map, 8, 12, 12)
game_map = self.draw_wall_col(game_map, 4, 8, 16)
# initialize all the fire
game_map = self.draw_fire_row(game_map, 9, 11, 8)
game_map = self.draw_fire_col(game_map, 5, 7, 12)
game_map = self.draw_fire_col(game_map, 5, 7, 13)
# initialize all the extinguishers
game_map[10][3] = self.extinguisher
game_map[9][10] = self.extinguisher
game_map[11][10] = self.extinguisher
# initialize all the batteries
game_map[15][6] = self.battery
game_map[10][10] = self.battery
self.num_batteries = 2
# initialize the character
game_map[4][3] = self.character
self.character_start_pos = (4, 3)
self.character_current_pos = (4, 3)
self.character_current_floor = self.floor
self.game_map = game_map
def maze10(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 6, 14, 2)
game_map = self.draw_wall_row(game_map, 10, 14, 6)
game_map = self.draw_wall_row(game_map, 13, 14, 6)
game_map = self.draw_wall_row(game_map, 6, 14, 10)
game_map = self.draw_wall_col(game_map, 2, 10, 6)
game_map = self.draw_wall_col(game_map, 2, 6, 10)
game_map = self.draw_wall_col(game_map, 2, 10, 14)
game_map[8][6] = self.wall
# initialize all the doors
game_map[10][4] = self.door
# initialize all the keys
game_map[12][8] = self.key
# initialize all the extinguishers
game_map[8][4] = self.extinguisher
# initialize all the fire
game_map[11][4] = self.fire
# initialize all the batteries
game_map[12][4] = self.battery
self.num_batteries = 1
# initialize the character
game_map[8][8] = self.character
self.character_start_pos = (8, 8)
self.character_current_pos = (8, 8)
self.character_current_floor = self.floor
self.game_map = game_map
def maze11(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 9, 13, 1)
game_map = self.draw_wall_row(game_map, 5, 7, 2)
game_map = self.draw_wall_row(game_map, 1, 18, 5)
game_map = self.draw_wall_row(game_map, 1, 18, 9)
game_map = self.draw_wall_row(game_map, 5, 7, 12)
game_map = self.draw_wall_row(game_map, 9, 13, 13)
game_map = self.draw_wall_col(game_map, 5, 9, 1)
game_map = self.draw_wall_col(game_map, 2, 5, 5)
game_map = self.draw_wall_col(game_map, 9, 12, 5)
game_map = self.draw_wall_col(game_map, 2, 5, 7)
game_map = self.draw_wall_col(game_map, 9, 12, 7)
game_map = self.draw_wall_col(game_map, 1, 5, 9)
game_map = self.draw_wall_col(game_map, 9, 13, 9)
game_map = self.draw_wall_col(game_map, 1, 5, 13)
game_map = self.draw_wall_col(game_map, 9, 13, 13)
game_map = self.draw_wall_col(game_map, 5, 9, 14)
game_map = self.draw_wall_col(game_map, 5, 9, 18)
# initialize all the fire
game_map = self.draw_fire_col(game_map, 6, 8, 12)
game_map = self.draw_fire_col(game_map, 6, 8, 13)
game_map[6][5] = self.fire
game_map[15][7] = self.fire
# initialize all the extinguishers
game_map[11][2] = self.extinguisher
game_map[8][6] = self.extinguisher
game_map[6][11] = self.extinguisher
game_map[11][12] = self.extinguisher
# initialize all the doors
game_map[11][5] = self.door
game_map[14][7] = self.door
game_map[6][9] = self.door
game_map[11][9] = self.door
# initialize all the keys
game_map[6][3] = self.key
game_map[11][3] = self.key
game_map[8][8] = self.key
game_map[11][11] = self.key
# initialize all the batteries
game_map[17][7] = self.battery
self.num_batteries = 1
# initialize the character
game_map[3][7] = self.character
self.character_start_pos = (3, 7)
self.character_current_pos = (3, 7)
self.character_current_floor = self.floor
self.game_map = game_map
def maze12(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 1, 18, 1)
game_map = self.draw_wall_row(game_map, 1, 5, 5)
game_map = self.draw_wall_row(game_map, 10, 18, 5)
game_map = self.draw_wall_row(game_map, 1, 5, 9)
game_map = self.draw_wall_row(game_map, 10, 18, 9)
game_map = self.draw_wall_row(game_map, 1, 18, 13)
game_map = self.draw_wall_col(game_map, 1, 13, 1)
game_map = self.draw_wall_col(game_map, 5, 9, 5)
game_map = self.draw_wall_col(game_map, 1, 13, 10)
game_map = self.draw_wall_col(game_map, 1, 13, 14)
game_map = self.draw_wall_col(game_map, 1, 13, 18)
# initialize all the fire
game_map = self.draw_fire_col(game_map, 2, 4, 5)
game_map = self.draw_fire_col(game_map, 2, 4, 13)
# initialize all the arrows
game_map = self.draw_arrow_row(game_map, 11, 13, 9, 'u')
game_map = self.draw_arrow_col(game_map, 2, 4, 10, 'r')
game_map = self.draw_arrow_col(game_map, 6, 8, 14, 'r')
game_map[10][7] = self.left_arrow
game_map[15][9] = self.down_arrow
game_map[16][9] = self.down_arrow
game_map[17][9] = self.left_arrow
game_map[10][11] = self.right_arrow
game_map[14][10] = self.left_arrow
game_map[14][11] = self.left_arrow
game_map[14][12] = self.up_arrow
# initialize all the extinguishers
game_map[3][4] = self.extinguisher
game_map[3][7] = self.extinguisher
# initialize all the doors
game_map[14][3] = self.door
game_map[3][9] = self.door
# initialize all the keys
game_map[3][2] = self.key
game_map[16][7] = self.key
# initialize all the batteries
game_map[16][3] = self.battery
self.num_batteries = 1
# initialize the character
game_map[3][11] = self.character
self.character_start_pos = (3, 11)
self.character_current_pos = (3, 11)
self.character_current_floor = self.floor
self.game_map = game_map
def maze13(self):
# initialize everything to a floor tile
game_map = self.floor_init()
# initialize all the walls
game_map = self.draw_wall_row(game_map, 0, 19, 0)
game_map = self.draw_wall_row(game_map, 0, 4, 3)
game_map = self.draw_wall_row(game_map, 8, 19, 4)
game_map = self.draw_wall_row(game_map, 0, 8, 6)
game_map = self.draw_wall_row(game_map, 0, 8, 8)
game_map = self.draw_wall_row(game_map, 10, 19, 8)
game_map = self.draw_wall_row(game_map, 8, 12, 10)
game_map = self.draw_wall_row(game_map, 16, 19, 11)
game_map = self.draw_wall_row(game_map, 0, 8, 12)
game_map = self.draw_wall_row(game_map, 0, 19, 14)
game_map = self.draw_wall_col(game_map, 0, 14, 0)
game_map = self.draw_wall_col(game_map, 0, 6, 4)
game_map = self.draw_wall_col(game_map, 8, 14, 4)
game_map = self.draw_wall_col(game_map, 0, 14, 8)
game_map = self.draw_wall_col(game_map, 4, 10, 10)
game_map = self.draw_wall_col(game_map, 0, 4, 12)
game_map = self.draw_wall_col(game_map, 10, 14, 12)
game_map = self.draw_wall_col(game_map, 4, 8, 14)
game_map = self.draw_wall_col(game_map, 11, 14, 16)
game_map = self.draw_wall_col(game_map, 0, 14, 19)
# initialize all the fire
game_map[2][8] = self.fire
# initialize all the extinguishers
game_map[1][13] = self.extinguisher
# initialize all the doors
game_map[4][1] = self.door
game_map[8][2] = self.door
game_map[12][2] = self.door
game_map[13][4] = self.door
game_map[15][4] = self.door
game_map[2][6] = self.door
game_map[6][6] = self.door
game_map[8][7] = self.door
game_map[6][8] = self.door
game_map[18][8] = self.door
game_map[12][12] = self.door
game_map[4][13] = self.door
game_map[8][13] = self.door
game_map[16][13] = self.door
# initialize all the keys
game_map[1][1] = self.key
game_map[1][2] = self.key
game_map[17][2] = self.key
game_map[1][4] = self.key
game_map[3][4] = self.key
game_map[9][5] = self.key
game_map[11][5] = self.key
game_map[11][7] = self.key