загружаю дз без 1 ки
This commit is contained in:
parent
3c010fa85a
commit
f46f4acfb7
|
@ -6,7 +6,7 @@ buttons = []
|
||||||
|
|
||||||
field_size = 10
|
field_size = 10
|
||||||
ship_size = 4
|
ship_size = 4
|
||||||
ship_direction = 1
|
ship_direction = 0
|
||||||
|
|
||||||
empty_field = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
empty_field = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||||
|
@ -120,13 +120,13 @@ def check_possible(field, row, col):
|
||||||
# Здесь мы знаем, что корабль помещается на поле.
|
# Здесь мы знаем, что корабль помещается на поле.
|
||||||
if field_size - row >= ship_size:
|
if field_size - row >= ship_size:
|
||||||
# Теперь нужно проверить, не заблокировано ли какое-то из полей,
|
# Теперь нужно проверить, не заблокировано ли какое-то из полей,
|
||||||
for i in range(row, row + ship_size + 1):
|
for i in range(row, row + 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 i in range(col, col + ship_size + 1):
|
for i in range(col, col + ship_size):
|
||||||
if check_blocked(field, row, col):
|
if check_blocked(field, row, col):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue