This commit is contained in:
danii 2023-11-27 19:14:10 +01:00
parent 9e7f15d57a
commit ade5101030
1 changed files with 9 additions and 9 deletions

View File

@ -99,13 +99,13 @@ def check_possible(field, row, col):
if ship_direction == 0: if ship_direction == 0:
if field_size - row >= ship_size: if field_size - row >= ship_size:
for r in range(row, row + ship_size): for r in range(col, col + ship_size):
if check_blocked(field, row, col): if check_blocked(field, row, col):
return True return True
if ship_direction == 1: if ship_direction == 1:
if field_size - col >= ship_size: if field_size - col >= ship_size:
for c in range(col, col + ship_size): for c in range(row, row + ship_size):
if check_blocked(field, row, col): if check_blocked(field, row, col):
return True return True
@ -155,11 +155,11 @@ colorize(my_field, buttons)
# print(blocked_string[:-2] + ' ' + ship_string[:-2]) # print(blocked_string[:-2] + ' ' + ship_string[:-2])
for r in range(0, field_size): # for r in range(0, field_size):
blocked_string = '' # blocked_string = ''
ship_string = '' # ship_string = ''
for c in range(0, field_size): # for c in range(0, field_size):
blocked_string += str(check_possible(my_field, r, c))[0] + ', ' # blocked_string += str(check_possible(my_field, r, c))[0] + ', '
ship_string += my_field[r * field_size + c] + ', ' # ship_string += my_field[r * field_size + c] + ', '
print(blocked_string[:-2] + ' ' + ship_string[:-2]) # print(blocked_string[:-2] + ' ' + ship_string[:-2])