Artificial intelligence (AI) may not be ready to write the next blockbuster movie, but a team of AI researchers from the Massachusetts Institute of Technology’s (MIT) Media Lab successfully used machine learning to teach computers about emotional arcs in movies.

The researchers, which collaborated for this project with McKinsey, used machine learning to analyze thousands of videos, including movies, TV shows and short films found on Vimeo. “We developed machine-learning models that rely on deep neural networks to ‘watch’ small slices of video—movies, TV, and short online features—and estimate their positive or negative emotional content by the second,” the team wrote in a blog post Monday morning.

The approach didn’t just pay attention to the general plot line of a movie, but also to more subtle aspects, including the score, and close-ups of a person’s face. Using these clues, the project’s machine learning algorithms were able to identify positive and negative emotions, and map out the extend to which each scene would provoke emotional responses — something the researchers called “visual valence.”

Taken together, this would result in a movie’s or video’s emotional arc — as shown below for the opening scene of Pixar’s “Up:”

In other words: Just by analyzing the visual elements of a movie, the algorithms could detect where the tear jerkers would be, and how the overall emotional arc of a story would develop. Researchers also used a control group of human volunteers to map out their response to some of the movies analyzed by computers, and then used that data to refine their models.

By comparing all of the emotional arcs analyzed by their AI, researchers found that most movies and short films follow simple formulas for their emotional arc. They also compared how audiences responded to each of these formulas by looking at comments left on 1500 short films on Vimeo — only to find that even Vimeo viewers like happy endings.

That in itself ma not be that surprising — but the fact that artificial intelligence can be used to analyze the emotional arc of a movie, and with that predict an audience response, could be profound for Hollywood, the researchers argued.

“As storytellers increasingly realize the value of AI, and as these tools become more readily available, we could see a major change in the way video stories are created,” they wrote. “In the same way directors can now integrate motion capture in their work, writers and storyboarders might work alongside machines, using their capabilities to sharpen their stories and amplify their emotional pull.”