Advertisement
Guest User

maze.py

a guest
Jun 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. class Maze:
  2.  
  3. def __init__(self):
  4. self.mazeIndex = 0
  5. self.mazes = []
  6. self.mazes.append({"tiles":
  7. [['#','#','#','#','#','#','#','#','#','#','#'],
  8. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  9. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  10. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  11. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  12. ['#',' ',' ','#',' ',' ',' ','#',' ',' ','#'], #Level 1
  13. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  14. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  15. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  16. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  17. ['#','#','#','#','#','#','#','#','#','#','#']],
  18. "sprouts":1, "width":11, "height":11})
  19.  
  20. self.mazes.append({"tiles":
  21. [['#','#','#','#','#','#','#','#','#','#','#'],
  22. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  23. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  24. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  25. ['#',' ',' ',' ',' ',' ','#',' ',' ',' ','#'],
  26. ['#',' ',' ',' ',' ',' ','#',' ',' ',' ','#'], #Level 2
  27. ['#',' ',' ',' ','#',' ',' ',' ',' ',' ','#'],
  28. ['#',' ',' ',' ','#',' ',' ',' ',' ',' ','#'],
  29. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  30. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  31. ['#','#','#','#','#','#','#','#','#','#','#']],
  32. "sprouts":1, "width":11, "height":11})
  33.  
  34. self.mazes.append({"tiles":
  35. [['#','#','#','#','#','#','#','#','#','#','#'],
  36. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  37. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  38. ['#',' ','#',' ',' ',' ',' ',' ','#',' ','#'],
  39. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  40. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'], #Level 3
  41. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  42. ['#',' ','#',' ',' ',' ',' ',' ','#',' ','#'],
  43. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  44. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  45. ['#','#','#','#','#','#','#','#','#','#','#']],
  46. "sprouts":1, "width":11, "height":11})
  47.  
  48. self.mazes.append({"tiles":
  49. [['#','#','#','#','#','#','#','#','#','#','#'],
  50. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  51. ['#',' ',' ',' ','#',' ','#',' ','#',' ','#'],
  52. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  53. ['#',' ','#',' ',' ',' ','#',' ','#',' ','#'],
  54. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  55. ['#',' ','#',' ','#',' ',' ',' ','#',' ','#'],
  56. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'], #Level 4
  57. ['#',' ','#',' ','#',' ','#',' ',' ',' ','#'],
  58. ['#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'],
  59. ['#','#','#','#','#','#','#','#','#','#','#']],
  60. "sprouts":1, "width":11, "height":11})
  61.  
  62.  
  63.  
  64.  
  65. self.currentMaze = self.mazes[0]
  66.  
  67.  
  68. def eatSprouts(self):
  69. self.currentMaze["sprouts"] -= 1
  70. if self.currentMaze["sprouts"] == 0:
  71. self.mazeIndex += 1
  72. if self.mazeIndex == len(self.mazes):
  73. print("You win!")
  74. else:
  75. self.currentMaze = self.mazes[self.mazeIndex]
  76.  
  77. def toString(self):
  78. pass
  79.  
  80. def placeseeker(self, seeker_char, row, col):
  81. self.currentMaze["tiles"][row][col] = seeker_char
  82.  
  83. def clearAtPos(self, row, col):
  84. self.currentMaze["tiles"][row][col] = " "
  85.  
  86. def getWidth(self):
  87. return self.currentMaze["width"]
  88.  
  89. def getHeight(self):
  90. return self.currentMaze["height"]
  91.  
  92. def getCharAtPos(self, row, col):
  93. return self.currentMaze["tiles"][row][col]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement