Advertisement
bwukki

Untitled

Nov 8th, 2017
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. """
  2. Hangman
  3. Plays a basic game of hangman
  4.  
  5. Author: JJ Programmer
  6. Version: 0.01
  7. Date: 11/07/2017
  8. """
  9.  
  10. import random
  11.  
  12. def makeArt():
  13. art = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
  14. art[0] = ' +---------+'
  15. art[1] = ' | |'
  16. art[2] = ' |'
  17. art[3] = ' |'
  18. art[4] = ' |'
  19. art[5] = ' |'
  20. art[6] = ' |'
  21. art[7] = ' |'
  22. art[8] = ' |'
  23. art[9] = ' |'
  24. art[10] = ' |'
  25. art[11] = ' |'
  26. art[12] = ' |'
  27. art[13] = ' |'
  28. art[14] = ' |'
  29. art[15] = ' ------------------+'
  30. return art
  31.  
  32. def readWords():
  33. wordList = []
  34. with open('wordlist.10000.txt') as wordFile:
  35. count = 0
  36. for line in wordFile:
  37. if len(line) > 4 and len(line) < 7:
  38. wordList.append(line[0:-1])
  39.  
  40. return wordList
  41.  
  42. def printArt(art):
  43. for line in art:
  44. print(line)
  45.  
  46. def setParts():
  47. parts = {
  48. 1 : head,
  49. 2 : body,
  50. 3 : leftArm,
  51. 4 : rightArm,
  52. 5 : leftLeg,
  53. 6 : rightLeg,
  54. }
  55. return parts
  56.  
  57. def head(art):
  58. art[2] = ' +---+ |'
  59. art[3] = ' + + |'
  60. art[4] = ' +---+ |'
  61.  
  62. def body(art):
  63. art[5] = ' + |'
  64. art[6] = ' +-----+ |'
  65. art[7] = ' + + |'
  66. art[8] = ' + + |'
  67. art[9] = ' + + |'
  68. art[10] = ' +-----+ |'
  69.  
  70.  
  71. def leftArm(art):
  72. art[7] = ' -----+ + |'
  73. pass
  74.  
  75. def rightArm(art):
  76. art[7] = ' -----+ +----- |'
  77. pass
  78.  
  79. def leftLeg(art):
  80. art[11] = ' | |'
  81. art[12] = ' | |'
  82. art[13] = ' | |'
  83. pass
  84.  
  85. def rightLeg(art):
  86. art[11] = ' | | |'
  87. art[12] = ' | | |'
  88. art[13] = ' | | |'
  89. pass
  90.  
  91. def init():
  92. bodyParts = setParts()
  93. art = makeArt()
  94. words = readWords()
  95. return bodyParts, art, words
  96.  
  97. def main():
  98. bodyParts, art, words = init()
  99.  
  100. misses = 1
  101. bodyParts[misses](art)
  102.  
  103. misses = 2
  104. bodyParts[misses](art)
  105.  
  106. misses = 3
  107. bodyParts[misses](art)
  108.  
  109. misses = 4
  110. bodyParts[misses](art)
  111.  
  112. misses = 5
  113. bodyParts[misses](art)
  114.  
  115. misses = 6
  116. bodyParts[misses](art)
  117.  
  118. printArt(art);
  119.  
  120. for i in range(20):
  121. print(random.choice(words))
  122.  
  123. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement