-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunused.py
49 lines (40 loc) · 1.73 KB
/
unused.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# unused code
import numpy
def count_row_empty(self, board: numpy.ndarray, y: int) -> int:
"""Count the amount of empty cells in row <y> of the board"""
count = 0
for x in range(self.boardX):
if board[y][x] == 0:
count += 1
return count
def count_col_empty(self, board: numpy.ndarray, x: int) -> int:
"""Count the amount of empty cells in column <x> of the board"""
count = 0
for y in range(self.boardY):
if board[y][x] == 0:
count += 1
return count
def row_is_full(self, board: numpy.ndarray, y: int) -> bool:
"""Returns true iff the row <y> of the board is full"""
for x in range(self.boardX):
if board[y][x] == 0:
return False
return True
def col_is_full(self, board: numpy.ndarray, x: int) -> bool:
"""Returns true iff the row <x> of the board is full"""
for y in range(self.boardY):
if board[y][x] == 0:
return False
return True
# The following code used to belong in the recursion for loop:
# If a move causes an entire row or col to be filled and there are adjacent empty cells on both sides, halt
# if (direction == "U" or direction == "D") and self.col_is_full(newboard, result[0]):
# # check if the adjacent columns have any empty squares
# if result[0] == 0 or self.col_is_full(newboard, result[0] - 1):
# if result[0] == self.boardX - 1 or self.col_is_full(newboard, result[0] + 1):
# return [False, ""]
#
# if (direction == "L" or direction == "R") and self.row_is_full(newboard, result[1]):
# if result[1] == 0 or self.row_is_full(newboard, result[1] - 1):
# if result[1] == self.boardY - 1 or self.row_is_full(newboard, result[1] + 1):
# return [False, ""]