original_docstring: Checks for a winner in the board based off the last move of the game
  
          :rtype: int
          
docstring: Checks for a winner in the board based off the last move of the game
docstring_tokens: Checks for a winner in the board based off the last move of the game
code: def check_for_winner(self):
          """Checks for a winner in the board based off the last move of the game
  
          :rtype: int
          """
  
          # Get the row and column of the last move
          row, column = self.last_move
          
          # Check for horizontals by iterating through offsets 1 - 4
          #   once a left or right bound is reached OR 
          #   a left or right piece is not the same as the last move's piece
          #   don't add to the left or right values
          left = right = 0
          add_to_left = add_to_right = True
          for offset in range(1, 5):
              if column - offset < 0 or self.board[row][column - offset] != self.board[row][column]:
                  add_to_left = False
              if column + offset >= self.width or self.board[row][column + offset] != self.board[row][column]:
                  add_to_right = False
              left += 1 if add_to_left else 0
              right += 1 if add_to_right else 0
          if left + right + 1 == 5 and self.board[row][column] != None:
              return OmokBoard.WIN if self.board[row][column] else OmokBoard.LOSS
  
          # Check for verticals by iterating through offsets 1 - 4
          #   once an up or down bound is reached OR 
          #   an up or down piece is not the same as the last move's piece
          #   don't add to the up or down values
          up = down = 0
          add_to_up = add_to_down = True
          for offset in range(1, 5):
              if row - offset < 0 or self.board[row - offset][column] != self.board[row][column]:
                  add_to_up = False
              if row + offset >= self.width or self.board[row + offset][column] != self.board[row][column]:
                  add_to_down = False
              up += 1 if add_to_up else 0
              down += 1 if add_to_down else 0
          if up + down + 1 == 5 and self.board[row][column] != None:
              return OmokBoard.WIN if self.board[row][column] else OmokBoard.LOSS
  
          # Check for left diagonals
          left_upper = right_lower = 0
          add_to_upper = add_to_lower = True
          for offset in range(1, 5):
              if row - offset < 0 or column - offset < 0 or self.board[row - offset][column - offset] != self.board[row][column]:
                  add_to_upper = False
              if row + offset >= self.height or column + offset >= self.width or self.board[row + offset][column + offset] != self.board[row][column]:
                  add_to_lower = False
              left_upper += 1 if add_to_upper else 0
              right_lower += 1 if add_to_lower else 0
          if left_upper  + right_lower + 1 == 5 and self.board[row][column] != None:
              return OmokBoard.WIN if self.board[row][column] else OmokBoard.LOSS
  
          # Check for right diagonals
          left_lower = right_upper = 0
          add_to_lower = add_to_upper = True
          for offset in range(1, 5):
              if row + offset >= self.height or column - offset < 0 or self.board[row + offset][column - offset] != self.board[row][column]:
                  add_to_upper = False
              if row - offset < 0 or column + offset >= self.width or self.board[row - offset][column + offset] != self.board[row][column]:
                  add_to_lower = False
              left_lower += 1 if add_to_lower else 0
              right_upper += 1 if add_to_upper else 0
          if left_lower  + right_upper + 1 == 5 and self.board[row][column] != None:
              return OmokBoard.WIN if self.board[row][column] else OmokBoard.LOSS
          
          # No winner yet
          return 0
code_tokens: def check_for_winner ( self ) : row , column = self . last_move left = right = 0 add_to_left = add_to_right = True for offset in range ( 1 , 5 ) : if column - offset < 0 or self . board [ row ] [ column - offset ] != self . board [ row ] [ column ] : add_to_left = False if column + offset >= self . width or self . board [ row ] [ column + offset ] != self . board [ row ] [ column ] : add_to_right = False left += 1 if add_to_left else 0 right += 1 if add_to_right else 0 if left + right + 1 == 5 and self . board [ row ] [ column ] != None : return OmokBoard . WIN if self . board [ row ] [ column ] else OmokBoard . LOSS up = down = 0 add_to_up = add_to_down = True for offset in range ( 1 , 5 ) : if row - offset < 0 or self . board [ row - offset ] [ column ] != self . board [ row ] [ column ] : add_to_up = False if row + offset >= self . width or self . board [ row + offset ] [ column ] != self . board [ row ] [ column ] : add_to_down = False up += 1 if add_to_up else 0 down += 1 if add_to_down else 0 if up + down + 1 == 5 and self . board [ row ] [ column ] != None : return OmokBoard . WIN if self . board [ row ] [ column ] else OmokBoard . LOSS left_upper = right_lower = 0 add_to_upper = add_to_lower = True for offset in range ( 1 , 5 ) : if row - offset < 0 or column - offset < 0 or self . board [ row - offset ] [ column - offset ] != self . board [ row ] [ column ] : add_to_upper = False if row + offset >= self . height or column + offset >= self . width or self . board [ row + offset ] [ column + offset ] != self . board [ row ] [ column ] : add_to_lower = False left_upper += 1 if add_to_upper else 0 right_lower += 1 if add_to_lower else 0 if left_upper + right_lower + 1 == 5 and self . board [ row ] [ column ] != None : return OmokBoard . WIN if self . board [ row ] [ column ] else OmokBoard . LOSS left_lower = right_upper = 0 add_to_lower = add_to_upper = True for offset in range ( 1 , 5 ) : if row + offset >= self . height or column - offset < 0 or self . board [ row + offset ] [ column - offset ] != self . board [ row ] [ column ] : add_to_upper = False if row - offset < 0 or column + offset >= self . width or self . board [ row - offset ] [ column + offset ] != self . board [ row ] [ column ] : add_to_lower = False left_lower += 1 if add_to_lower else 0 right_upper += 1 if add_to_upper else 0 if left_lower + right_upper + 1 == 5 and self . board [ row ] [ column ] != None : return OmokBoard . WIN if self . board [ row ] [ column ] else OmokBoard . LOSS return 0
short_docstring: Checks for a winner in the board based off the last move of the game
short_docstring_tokens: Checks for a winner in the board based off the last move of the game
comment: """Checks for a winner in the board based off the last move of the game
  
          :rtype: int
          """$SEP$# Get the row and column of the last move$SEP$# Check for horizontals by iterating through offsets 1 - 4$SEP$#   once a left or right bound is reached OR $SEP$#   a left or right piece is not the same as the last move's piece$SEP$#   don't add to the left or right values$SEP$# Check for verticals by iterating through offsets 1 - 4$SEP$#   once an up or down bound is reached OR $SEP$#   an up or down piece is not the same as the last move's piece$SEP$#   don't add to the up or down values$SEP$# Check for left diagonals$SEP$# Check for right diagonals$SEP$# No winner yet