def is_eye(self, position, owner, stack=[]):
		if not self.is_eyeish(position, owner):
			return False
		# (as in Fuego/Michi/etc) ensure that num "bad" diagonals is 0 (edges) or 1
		# where a bad diagonal is an opponent stone or an empty non-eye space
		num_bad_diagonal = 0
		# if in middle of board, 1 bad neighbor is allowable; zero for edges and corners
		allowable_bad_diagonal = 1 if len(self._neighbors(position)) == 4 else 0

		for d in self._diagonals(position):
			# opponent stones count against this being eye
			if self.board[d] == -owner:
				num_bad_diagonal += 1
			# empty spaces (that aren't themselves eyes) count against it too
			# the 'stack' keeps track of where we've already been to prevent
			# infinite loops of recursion
			elif self.board[d] == EMPTY and d not in stack:
				stack.append(position)
				if not self.is_eye(d, owner, stack):
					num_bad_diagonal += 1
				stack.pop()
			# at any point, if we've surpassed # allowable, we can stop
			if num_bad_diagonal > allowable_bad_diagonal:
				return False
		return True
No Git templates can be found.
dataset/ETHPy150Open Rochester-NRT/RocAlphaGo/AlphaGo/go.py/GameState.is_eye--crossover with--dataset/ETHPy150Open robmadole/jig/src/jig/commands/tests/test_sticky.py/TestStickyCommand.test_templates_missing