Fishing Competition Python Advanced

Дава ми RunTime Error, а не мога да си намеря грешката.
 

def find_start_position(matrix):
    for i in range(len(matrix)):
        for j in range(len(matrix[i])):
            if matrix[i][j] == 'S':
                return i, j

def is_valid_move(matrix, row, col):
    return 0 <= row < len(matrix) and 0 <= col < len(matrix[0])

def fisherman_game(matrix_size, matrix, moves):
    total_fish_caught = 0
    current_row, current_col = find_start_position(matrix)

    for move in moves:
        matrix[current_row][current_col] = '-'
        
        if move == 'up':
            current_row -= 1
        elif move == 'down':
            current_row += 1
        elif move == 'left':
            current_col -= 1
        elif move == 'right':
            current_col += 1

        if not is_valid_move(matrix, current_row, current_col):
            if current_row < 0:
                current_row = matrix_size - 1
            elif current_row >= matrix_size:
                current_row = 0
            elif current_col < 0:
                current_col = matrix_size - 1
            elif current_col >= matrix_size:
                current_col = 0

        if matrix[current_row][current_col] == 'W':
            print(f"You fell into a whirlpool! The ship sank and you lost the fish you caught. Last coordinates of the ship: [{current_row},{current_col}]")
            return

        elif matrix[current_row][current_col].isdigit():
            fish_caught = int(matrix[current_row][current_col])
            total_fish_caught += fish_caught
            matrix[current_row][current_col] = '-'

        if total_fish_caught >= 20:
            print("Success! You managed to reach the quota!")
            break

    if total_fish_caught < 20:
        lack_of_fish = 20 - total_fish_caught
        print(f"You didn't catch enough fish and didn't reach the quota!\nYou need {lack_of_fish} tons of fish more.")

    if total_fish_caught > 0:
        print(f"Amount of fish caught: {total_fish_caught} tons.")

    for row in matrix:
        print(' '.join(row))

# Example usage:
matrix_size = int(input())
matrix = [list(input()) for _ in range(matrix_size)]
moves = [input() for _ in range(int(input()))]

fisherman_game(matrix_size, matrix, moves)