Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
178652bf37
|
@ -2,7 +2,8 @@ from tkinter import *
|
|||
from enum import Enum
|
||||
|
||||
field_size = 10
|
||||
ship_size = []
|
||||
ship_size = 4
|
||||
ship_direction = 1
|
||||
|
||||
buttons = []
|
||||
|
||||
|
@ -99,14 +100,16 @@ def check_possible(field, row, col):
|
|||
|
||||
if ship_direction == 0:
|
||||
if field_size - row >= ship_size:
|
||||
for r in range(col, col + ship_size):
|
||||
if check_blocked(field, row, col):
|
||||
for r in range(row, row + ship_size + 1):
|
||||
if not check_blocked(field, r, col):
|
||||
return False
|
||||
return True
|
||||
|
||||
if ship_direction == 1:
|
||||
if field_size - col >= ship_size:
|
||||
for c in range(row, row + ship_size):
|
||||
if check_blocked(field, row, col):
|
||||
for c in range(col, col + ship_size + 1):
|
||||
if not check_blocked(field, row, c):
|
||||
return False
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -146,20 +149,23 @@ colorize(my_field, buttons)
|
|||
|
||||
#window.mainloop()
|
||||
|
||||
# for r in range(0, field_size):
|
||||
# blocked_string = ''
|
||||
# ship_string = ''
|
||||
# for c in range(0, field_size):
|
||||
# blocked_string += str(check_blocked(my_field, r, c))[0] + ', '
|
||||
# ship_string += my_field[r * field_size + c] + ', '
|
||||
for r in range(0, field_size):
|
||||
blocked_string = ''
|
||||
ship_string = ''
|
||||
for c in range(0, field_size):
|
||||
blocked_string += str(check_blocked(my_field, r, c))[0] + ', '
|
||||
ship_string += my_field[r * field_size + c] + ', '
|
||||
|
||||
# print(blocked_string[:-2] + ' ' + ship_string[:-2])
|
||||
print(blocked_string[:-2] + ' ' + ship_string[:-2])
|
||||
|
||||
# for r in range(0, field_size):
|
||||
# blocked_string = ''
|
||||
# ship_string = ''
|
||||
# for c in range(0, field_size):
|
||||
# blocked_string += str(check_possible(my_field, r, c))[0] + ', '
|
||||
# ship_string += my_field[r * field_size + c] + ', '
|
||||
print("#########################################################################")
|
||||
|
||||
# print(blocked_string[:-2] + ' ' + ship_string[:-2])
|
||||
|
||||
for r in range(0, field_size):
|
||||
possible_string = ''
|
||||
impossible_string = ''
|
||||
for c in range(0, field_size):
|
||||
possible_string += str(check_possible(my_field, r, c))[0] + ', '
|
||||
impossible_string += my_field[r * field_size + c] + ', '
|
||||
|
||||
print(possible_string[:-2] + ' ' + impossible_string[:-2])
|
Loading…
Reference in New Issue