#NEWLINE# def is_eye( self , position , owner , stack = [ ] ) : #NEWLINE# #INDENT# "returns whether the position is a true eye of 'owner'\n\n\t\tRequires a recursive call; empty spaces diagonal to 'position' are fine\n\t\tas long as they themselves are eyes\n\t\t" #NEWLINE# if ( not self . is_eyeish ( position , owner ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# num_bad_diagonal = 0 #NEWLINE# allowable_bad_diagonal = ( 1 if ( len ( self . _neighbors ( position ) ) == 4 ) else 0 ) #NEWLINE# for d in self . _diagonals ( position ) : #NEWLINE# #INDENT# if ( self . board [ d ] == ( - owner ) ) : #NEWLINE# #INDENT# num_bad_diagonal += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( self . board [ d ] == EMPTY ) and ( d not in stack ) ) : #NEWLINE# #INDENT# stack . append ( position ) #NEWLINE# if ( not self . is_eye ( d , owner , stack ) ) : #NEWLINE# #INDENT# num_bad_diagonal += 1 #NEWLINE# #UNINDENT# stack . pop ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( num_bad_diagonal > d ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# return True