Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. def add_piece(self, pos_x, pos_y, piece):
  2. if pos_x + piece.shape[0] > self._length:
  3. print('Please move your piece more to the left')
  4. add_piece(pos_x, pos_y, piece)
  5. if pos_y + piece.shape[1] > self._length:
  6. print('Please move your piece more upwards')
  7. add_piece(pos_x, pos_y, piece)
  8. else:
  9. for i in range(piece.shape[0]):
  10. for j in range(piece.shape[1]):
  11. if piece.item(i, j) != 0 and self._board[pos_x+i][pos_y+j] == 0:
  12. self._board[i+pos_x][j+pos_y] = piece.item(i,j)
  13. elif self._board[pos_x+i][pos_y+j] != 0 and piece.item(i,j) == 0:
  14. print('Field is occupied. Please put somewhere else.')
  15. add_piece(pos_x, pos_y, piece)
  16. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement