Advertisement
aIexandria

Untitled

Sep 21st, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. print ("Welcome to Checkers!", "\n")
  2. #Display the board
  3. board= [ [" - " , " x " , " - " , " x " , " - " , " x ", " - ", " x " , 8 ] ,
  4. [" x " , " - " , " x " , " - " , " x ", " - " , " x " , " - " , 7 ],
  5. [" - " , " x " , " - " , " x " , " - " , " x ", " - ", " x " , 6 ],
  6. [" - " , " - " , " - " , " - " , " - " , " - ", " - ", " - " , 5 ],
  7. [" - " , " - " , " - " , " - " , " - " , " - ", " - ", " - " , 4 ],
  8. [" o " , " - " , " o " , " - " , " o " , " - ", " o ", " - " , 3 ],
  9. [" - " , " o " , " - " , " o " , " - " , " o ", " - ", " o " , 2 ],
  10. [" o " , " - " , " o " , " - " , " o " , " - ", " o ", " - " , 1 ],
  11. [" A " , " B " , " C " , " D " , " E " , " F ", " G ", " H "] ]
  12. for i in range (len(board)) :
  13. for j in range (len(board[i])) :
  14. print (board[i][j], end = " ")
  15. print ()
  16. #Assign values for movements
  17. letter = {"A":0, "B":1 , "C":2 , "D":3 , "E":4 , "F":5 , "G":6, "H":7}
  18. number = {"8":0, "7":1, "6":2, "5":3, "4":4, "3":5, "2":6, "1":7}
  19. a = move[0]
  20. b = move[1]
  21. c = move[3]
  22. d = move[4]
  23. e = move[6]
  24. f = move[7]
  25. g = move[9]
  26. h = move[10]
  27. x1 = number[b]
  28. x1 = int(x1)
  29. y1 = letter[a]
  30. y1 = int(y1)
  31. x2 = number[d]
  32. x2 = int(x2)
  33. y2 = letter[c]
  34. y2 = int(y2)
  35. x3 = number[f]
  36. x3 = int(x3)
  37. y3 = letter[e]
  38. y3 = int(y3)
  39. x4 = number[h]
  40. x4 = int(x4)
  41. y4 = letter[g]
  42. y4 = int(y4)
  43. def movement(board,x1,y1,x2,y2):
  44. board[x1][y1],board[x2][y2]=board[x2][y2],board[x1][y1]
  45. return board
  46. def darkcapture(board,x1,y1,x2,y2,x3,y3):
  47. board[x1][y1] = " - "
  48. board[x2][y2] = " - "
  49. board[x3][y3] = " x "
  50. def lightcapture(board,x1,y1,x2,y2,x3,y3):
  51. board[x1][y1] = " - "
  52. board[x2][y2] = " - "
  53. board[x3][y3] = " o "
  54. def darkmove(board,x1,y1,x2,y2):
  55. global move
  56. move = input("Dark pieces to play. Enter your move:")
  57. movement(board,x1,y1,x2,y2)
  58. for i in range (len(board)) :
  59. for j in range (len(board[i])) :
  60. print (board[i][j], end = " ")
  61. print ()
  62. print ("\n","Dark player played:", move)
  63. def lightmove(board,x1,y1,x2,y2):
  64. global move
  65. move = input("Light pieces to play. Enter your move:") #PLayer 1 is the always the first one to move
  66. movement(board,x1,y1,x2,y2)
  67. for i in range (len(board)) :
  68. for j in range (len(board[i])) :
  69. print (board[i][j], end = " ")
  70. print ()
  71. print ("\n","Light player played:", move)
  72. turn = 1
  73. while turn>=1:
  74. if turn%2==0:
  75. darkmove(board,x1,y1,x2,y2)
  76. else:
  77. lightmove(board,x1,y1,x2,y2)
  78. turn +=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement