#NEWLINE# def test_get_liberties( self ) : #NEWLINE# #INDENT# gs = simple_board ( ) #NEWLINE# pp = Preprocess ( [ 'liberties' ] ) #NEWLINE# feature = pp . state_to_tensor ( gs ) [ 0 ] . transpose ( ( 1 , 2 , 0 ) ) #NEWLINE# one_hot_liberties = np . zeros ( ( gs . size , gs . size , 8 ) ) #NEWLINE# one_hot_liberties [ ( 4 , 4 , 0 ) ] = 1 #NEWLINE# one_hot_liberties [ 0 , 0 : 3 , 1 ] = 1 #NEWLINE# one_hot_liberties [ ( 3 , 4 , 1 ) ] = 1 #NEWLINE# one_hot_liberties [ ( 5 , 4 , 1 ) ] = 1 #NEWLINE# one_hot_liberties [ 1 , 0 : 2 , 2 ] = 1 #NEWLINE# one_hot_liberties [ ( 4 , 5 , 2 ) ] = 1 #NEWLINE# one_hot_liberties [ ( 3 , 3 , 2 ) ] = 1 #NEWLINE# one_hot_liberties [ ( 5 , 3 , 2 ) ] = 1 #NEWLINE# one_hot_liberties [ ( 4 , 2 , 3 ) ] = 1 #NEWLINE# for i in range ( 8 ) : #NEWLINE# #INDENT# self . assertTrue ( np . all ( ( feature [ : , : , i ] == one_hot_liberties [ : , : , i ] ) ) , ( 'bad expectation: stones with %d liberties' % ( i + 1 ) ) )