Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Check rows
- for x from 0 to (max_x - pieces_in_line):
- for y from 0 to (max_y - 1):
- // initialise some variable - colour is the colour the next pieces have to be to win
- win = true
- colour = board[x][y]
- // check the next pieces
- for i from 1 to (pieces_in_line - 1):
- if board[x+i][y] != colour:
- // this piece is a different colour, so its not a win
- win = false
- break
- if win:
- colour wins!!
- // Check columns
- for x from 0 to (max_x - 1):
- for y from 0 to (max_y - pieces_in_line):
- // initialise some variable - colour is the colour the next pieces have to be to win
- win = true
- colour = board[x][y]
- // check the next pieces
- for i from 1 to (pieces_in_line - 1):
- if board[x][y+i] != colour:
- // this piece is a different colour, so its not a win
- win = false
- break
- if win:
- colour wins!!
- // Check diagonals
- for x from 0 to (max_x - pieces_in_line):
- // Going up
- for y from 0 to (max_y - pieces_in_line):
- // initialise some variable - colour is the colour the next pieces have to be to win
- win = true
- colour = board[x][y]
- // check the next pieces
- for i from 1 to (pieces_in_line - 1):
- if board[x+i][y+i] != colour:
- // this piece is a different colour, so its not a win
- win = false
- break
- if win:
- colour wins!!
- // Going down
- for y from (pieces_in_line - 1) to (max_y - 1):
- // initialise some variable - colour is the colour the next pieces have to be to win
- win = true
- colour = board[x][y]
- // check the next pieces
- for i from 1 to (pieces_in_line - 1):
- if board[x+i][y-1] != colour:
- // this piece is a different colour, so its not a win
- win = false
- break
- if win:
- colour wins!!
Add Comment
Please, Sign In to add comment