From 3c010fa85ae0fe66cd3b51d1286f34d2c919c62c Mon Sep 17 00:00:00 2001 From: ehermakov Date: Mon, 27 Nov 2023 20:44:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B6=D0=B0?= =?UTF-8?q?=D1=8E=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=B7=20=D1=81=201=D0=BA=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HNS/Excercises/ShipCraft/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/HNS/Excercises/ShipCraft/main.py b/HNS/Excercises/ShipCraft/main.py index beef5a3..a4b9eb7 100644 --- a/HNS/Excercises/ShipCraft/main.py +++ b/HNS/Excercises/ShipCraft/main.py @@ -5,7 +5,7 @@ import math buttons = [] field_size = 10 -ship_size = 3 +ship_size = 4 ship_direction = 1 empty_field = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', @@ -34,9 +34,9 @@ class ShootResult(Enum): def set_ship(row, col, size, direction): - if row < 0 or row > field_size - 1: + if row < 0 or row > field_size: return - if col < 0 or col > field_size - 1: + if col < 0 or col > field_size: return index = row * field_size + col if direction == 0: @@ -120,13 +120,13 @@ def check_possible(field, row, col): # Здесь мы знаем, что корабль помещается на поле. if field_size - row >= ship_size: # Теперь нужно проверить, не заблокировано ли какое-то из полей, - for i in range(row, row + ship_size): + for i in range(row, row + ship_size + 1): if check_blocked(field, row, col): return True if ship_direction == 1: if field_size - col >= ship_size: - for i in range(col, col + ship_size): + for i in range(col, col + ship_size + 1): if check_blocked(field, row, col): return True return False