Guest User

Untitled

a guest
Apr 26th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. // Check rows
  2. for x from 0 to (max_x - pieces_in_line):
  3. for y from 0 to (max_y - 1):
  4. // initialise some variable - colour is the colour the next pieces have to be to win
  5. win = true
  6. colour = board[x][y]
  7.  
  8. // check the next pieces
  9. for i from 1 to (pieces_in_line - 1):
  10. if board[x+i][y] != colour:
  11. // this piece is a different colour, so its not a win
  12. win = false
  13. break
  14.  
  15. if win:
  16. colour wins!!
  17.  
  18.  
  19. // Check columns
  20. for x from 0 to (max_x - 1):
  21. for y from 0 to (max_y - pieces_in_line):
  22. // initialise some variable - colour is the colour the next pieces have to be to win
  23. win = true
  24. colour = board[x][y]
  25.  
  26. // check the next pieces
  27. for i from 1 to (pieces_in_line - 1):
  28. if board[x][y+i] != colour:
  29. // this piece is a different colour, so its not a win
  30. win = false
  31. break
  32.  
  33. if win:
  34. colour wins!!
  35.  
  36.  
  37. // Check diagonals
  38. for x from 0 to (max_x - pieces_in_line):
  39. // Going up
  40. for y from 0 to (max_y - pieces_in_line):
  41. // initialise some variable - colour is the colour the next pieces have to be to win
  42. win = true
  43. colour = board[x][y]
  44.  
  45. // check the next pieces
  46. for i from 1 to (pieces_in_line - 1):
  47. if board[x+i][y+i] != colour:
  48. // this piece is a different colour, so its not a win
  49. win = false
  50. break
  51.  
  52. if win:
  53. colour wins!!
  54.  
  55. // Going down
  56. for y from (pieces_in_line - 1) to (max_y - 1):
  57. // initialise some variable - colour is the colour the next pieces have to be to win
  58. win = true
  59. colour = board[x][y]
  60.  
  61. // check the next pieces
  62. for i from 1 to (pieces_in_line - 1):
  63. if board[x+i][y-1] != colour:
  64. // this piece is a different colour, so its not a win
  65. win = false
  66. break
  67.  
  68. if win:
  69. colour wins!!
Add Comment
Please, Sign In to add comment