MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / dropOnColumn

Method dropOnColumn

inprogress/dropspin.py:74–95  ·  view source on GitHub ↗
(self, column)

Source from the content-addressed store, hash-verified

72
73
74 def dropOnColumn(self, column):
75 if self.board[(column, 0)] == FILLED:
76 # This column is completely full, do nothing:
77 return
78
79 # Check if the column is entirely empty:
80 columnIsEmpty = True
81 for row in range(self.size):
82 if self.board[(column, row)] == FILLED:
83 columnIsEmpty = False
84 if columnIsEmpty:
85 # There are no blocks in this column, fill in the last one:
86 self.board[(column, self.size - 1)] = FILLED
87 self.rememberBoard()
88 return
89
90 # Find the first block from the top, and place a block above it:
91 for row in range(1, self.size):
92 if self.board[(column, row)] == FILLED:
93 self.board[(column, row - 1)] = FILLED
94 self.rememberBoard()
95 return
96
97
98 def rotateRight(self):

Callers 2

_generateRandomMethod · 0.95
dropspin.pyFile · 0.80

Calls 1

rememberBoardMethod · 0.95

Tested by

no test coverage detected