Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add_piece(self, pos_x, pos_y, piece):
- if pos_x + piece.shape[0] > self._length:
- print('Please move your piece more to the left')
- add_piece(pos_x, pos_y, piece)
- if pos_y + piece.shape[1] > self._length:
- print('Please move your piece more upwards')
- add_piece(pos_x, pos_y, piece)
- else:
- for i in range(piece.shape[0]):
- for j in range(piece.shape[1]):
- if piece.item(i, j) != 0 and self._board[pos_x+i][pos_y+j] == 0:
- self._board[i+pos_x][j+pos_y] = piece.item(i,j)
- elif self._board[pos_x+i][pos_y+j] != 0 and piece.item(i,j) == 0:
- print('Field is occupied. Please put somewhere else.')
- add_piece(pos_x, pos_y, piece)
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement