#NEWLINE# def test_get_liberties_after( self ) : #NEWLINE# #INDENT# gs = simple_board ( ) #NEWLINE# pp = Preprocess ( [ 'liberties_after' ] ) #NEWLINE# feature = pp . state_to_tensor ( gs ) [ 0 ] . transpose ( ( 1 , 2 , 0 ) ) #NEWLINE# one_hot_liberties = np . zeros ( ( gs . size , feature . size , 8 ) ) #NEWLINE# for ( x , y ) in gs . get_legal_moves ( ) : #NEWLINE# #INDENT# copy = gs . copy ( ) #NEWLINE# copy . do_move ( ( x , y ) ) #NEWLINE# libs = copy . liberty_counts [ ( x , y ) ] #NEWLINE# if ( libs < 7 ) : #NEWLINE# #INDENT# one_hot_liberties [ ( x , y , ( libs - 1 ) ) ] = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# one_hot_liberties [ ( x , y , 7 ) ] = 1 #NEWLINE# #UNINDENT# #UNINDENT# for i in range ( 8 ) : #NEWLINE# #INDENT# self . assertTrue ( np . all ( ( feature [ : , : , i ] == one_hot_liberties [ : , : , i ] ) ) , ( 'bad expectation: stones with %d liberties after move' % ( i + 1 ) ) )