def print_pos(self, coordinates=None, pos=None):
        '''Print the chessboard'''
        if not pos:
            pos = self.pos
        self.graph = [list(map(self._transform, pos[i])) for i in self.pos_range]
        xaxis = ' '.join([chr(ASC_ONE + _) for _ in range(min(self.board_size, MAX_NUM))])
        if (self.board_size > MAX_NUM):
            xaxis += ' '
            xaxis += ' '.join([chr(ASC_A + _ - MAX_NUM) for _ in range(MAX_NUM, min(self.board_size, MAX_CAP))])
        if (self.board_size > MAX_CAP):
            xaxis += ' '
            xaxis += ' '.join([chr(ASC_a + _ - MAX_CAP) for _ in range(MAX_CAP, self.board_size)])
        print('  ', end='')
        print(xaxis)
        for i in range(self.board_size):
            out = '|'.join(self.graph[i])
            if i < MAX_NUM:
                print(chr(i + ASC_ONE), end='')
            elif MAX_NUM <= i < MAX_CAP:
                print(chr(i - MAX_NUM + ASC_A), end='')
            elif MAX_CAP <= i < MAX_LOW:
                print(chr(i - MAX_CAP + ASC_a), end='')
            print('|', end='')
            #Colorful print
            if coordinates:
                for j in range(self.board_size):
                    if (i, j) in coordinates:
                        new_print = cprint
                        params = {
                            'color': 'w',
                            'bcolor': 'r',
                        }
                    else:
                        new_print = print
                        params = {}
                    new_print(self._transform(pos[i][j]), end='', **params)
                    print('|', end='') 
                else:
                    print()
            else:
                print(out, end='')
                print('|')
def print_pos ( self , coordinates = None , pos = None ) : if not pos : pos = self . pos self . graph = [ list ( map ( self . _transform , pos [ i ] ) ) for i in self . pos_range ] xaxis = ' ' . join ( [ chr ( ASC_ONE + _ ) for _ in range ( min ( self . board_size , MAX_NUM ) ) ] ) if ( self . board_size > MAX_NUM ) : xaxis += ' ' xaxis += ' ' . join ( [ chr ( ASC_A + _ - MAX_NUM ) for _ in range ( MAX_NUM , min ( self . board_size , MAX_CAP ) ) ] ) if ( self . board_size > MAX_CAP ) : xaxis += ' ' xaxis += ' ' . join ( [ chr ( ASC_a + _ - MAX_CAP ) for _ in range ( MAX_CAP , self . board_size ) ] ) print ( '  ' , end = '' ) print ( xaxis ) for i in range ( self . board_size ) : out = '|' . join ( self . graph [ i ] ) if i < MAX_NUM : print ( chr ( i + ASC_ONE ) , end = '' ) elif MAX_NUM <= i < MAX_CAP : print ( chr ( i - MAX_NUM + ASC_A ) , end = '' ) elif MAX_CAP <= i < MAX_LOW : print ( chr ( i - MAX_CAP + ASC_a ) , end = '' ) print ( '|' , end = '' ) if coordinates : for j in range ( self . board_size ) : if ( i , j ) in coordinates : new_print = cprint params = { 'color' : 'w' , 'bcolor' : 'r' , } else : new_print = print params = { } new_print ( self . _transform ( pos [ i ] [ j ] ) , end = '' , ** params ) print ( '|' , end = '' ) else : print ( ) else : print ( out , end = '' ) print ( '|' )
Print the chessboard