示例#1
0
 def get_block(self, block_pos: Position) -> Block:
     if block_pos.get_row() < 0 or block_pos.get_column() < 0:
         raise MoveError('use positive notch numbers please')
     try:
         return self.__blocks[block_pos.get_row()][block_pos.get_column()]
     except IndexError:
         raise MoveError('block does not exist')
示例#2
0
 def play(self, marble: Marble, pos: Position):
     new_notches = deepcopy(self.__notches)
     if pos.get_row() < 0 or pos.get_column() < 0:
         raise MoveError('use positive notch numbers please')
     try:
         new_notches[pos.get_row()][pos.get_column()] = new_notches[pos.get_row()][pos.get_column()].play(marble)
     except IndexError:
         raise MoveError('notch does not exist')
     return Block(new_notches)
示例#3
0
 def __update_block(self, block_pos: Position, new_block: Block) -> 'Board':
     new_blocks = deepcopy(self.__blocks)
     new_blocks[block_pos.get_row()][block_pos.get_column()] = new_block
     return Board(new_blocks)
示例#4
0
 def get_notch(self, pos: Position):
     return self.get_row(pos.get_row())[pos.get_column()]