Guest User

Untitled

a guest
Apr 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.20 KB | None | 0 0
  1. # Functions
  2. #
  3. # Draw a grid(done)
  4. # Find out who goes first(done)
  5. # Rules!(done)
  6. # Devise a method for entering moves(done)
  7. # Get next move
  8. # Update grid(done)
  9. # Check wins/draws
  10. # If true then:
  11. # Congratulate player
  12. # Else rerun from 'Get next move' and switch player
  13.  
  14.  
  15. # Data needed
  16. #
  17. # Record of moves
  18. # Player one name
  19. # Player two name
  20. # Current player
  21.  
  22.  
  23. # Check wins/draws
  24. # Input = record of moves
  25. # Output = 'x', 'o', 'd', 'f'
  26.  
  27. # a = moves()
  28. # b = whofirst()
  29.  
  30.  
  31.  
  32.  
  33. def gridupdate():
  34.     print ("Here is the grid!")
  35.     print (" ")
  36.     print ("  |  0  |  1  |  2  |")
  37.     print (" -|-----|-----|-----|")
  38.     print ("  |     |     |     |")
  39.     print ("0 | ", a[0][0]," | ", a[0][1]," | ", a[0][2]," |")
  40.     print ("  |     |     |     |")
  41.     print (" -|-----|-----|-----|")
  42.     print ("  |     |     |     |")
  43.     print ("1 | ", a[1][0]," | ", a[1][1]," | ", a[1][2]," |")
  44.     print ("  |     |     |     |")
  45.     print (" -|-----|-----|-----|")
  46.     print ("  |     |     |     |")
  47.     print ("2 | ", a[2][0]," | ", a[2][1]," | ", a[2][2]," |")
  48.     print ("  |     |     |     |")
  49.     print (" -|-----|-----|-----|")
  50.  
  51.  
  52. def rules():
  53.     print ("Welcome to my Noughts and Crosses game! The rules are simple")
  54.     print ("Each player takes one turn after the other, this happens until:")
  55.     print ("- 3 of the same marker are next to each other")
  56.     print ("- No more spaces left")
  57.     print (" ")
  58.     print ("Just follow through the instructions and get ready.")
  59.     print ("This is the most intensive Noughts and Crosses game ever!")
  60.     print ("When promted, enter your names")
  61.     print ("Once the game has started, use the coordinates on the grid to place your marker   'eg. 0,0'")
  62.     print ("Now just enjoy...")
  63.     print ("---------------------------------------------------------------------------------------------")
  64.     input ("Shall we begin? Just hit enter when you're ready")
  65.  
  66. def whofirst():
  67.     playernames = []
  68.     p1 = input ("Who is player one? ")
  69.     print (" ")
  70.     print ("You are noughts")
  71.     print (" ")
  72.     p2 = input ("Who is player two? ")
  73.     print (" ")
  74.     print ("You are crosses")
  75.     print (" ")
  76.     playernames = ([p1, p2])
  77.     print ("---------------------------------------------------------------------------------------------")
  78.     return playernames
  79.  
  80.  
  81. def nextmove(whichplayer):
  82.     if whichplayer == 1:
  83.         print (b[whichplayer])
  84.         whichplayer = whichplayer - 1
  85.     else:
  86.         print (b[whichplayer])
  87.         whichplayer = whichplayer + 1
  88.     nextplace = input ("Where would you like to go?")
  89.     nextplace = str(nextplace)
  90.     return nextplace
  91.    
  92.  
  93. def movecalc(c):
  94.     move1 = c[0]
  95.     move2 = c[1]
  96.     move1 = int(move1)
  97.     move2 = int(move2)
  98.     if whichplayer == 1:
  99.         a[c[0]][c[1]] = 'O'
  100.     else:
  101.         a[c[0]][c[1]] = 'X'
  102.    
  103.  
  104.    
  105. def moves():
  106.     movelist = ([[' ', ' ', ' ',],[' ', ' ', ' ',],[' ', ' ', ' ',]])
  107.     return movelist
  108.  
  109.  
  110. # Main Program
  111. whichplayer = 1
  112. NumMoves = 0
  113. a = moves()
  114. #rules()
  115. #gridupdate()
  116. #print (" ")
  117. #print ("So then!")
  118. #print (" ")
  119. b = whofirst()
  120. while NumMoves < 9:
  121.     c = nextmove(whichplayer)
  122.     d = movecalc(c)
  123.     NumMoves = NumMoves + 1
Add Comment
Please, Sign In to add comment