How ‘The Good Place’ Is A Great Example of Recursion
Whether you watch it on primetime or binge-watched Season 1 on Netflix, NBC’s ‘The Good Place’ has gotten rave reviews (and was just picked up for Season 3).
But did you know it’s also a great example of recursion — a computer science method that can be used in most programming languages?
It is! In recursion, you solve a problem by creating a function and then calling that function again and again, within the original function, until you reach your desired result.
Did that paragraph (and that amazing animation) make you dizzy? Well, read on, because you’re about to see how ‘The Good Place’ models this concept.
(WARNING! MAJOR SEASON ONE SPOILERS AHEAD!)
The comedy ‘The Good Place’ tells the story of Eleanor Shellstrop (Kristen Bell), a woman who, upon her death, arrives at a magical world that she learns is ‘The Good Place’ — i.e., heaven, where people who were good on Earth spend eternal life in a constant state of bliss.
The problem is, Eleanor wasn’t a good person — she was actually a really, really, really bad person, and she doesn’t know why she would be picked for ‘The Good Place’.
She tries to hide this, first by lying about her past, then studying with philosophy professor Chidi (William Jackson Harper) in an attempt to change from bad to good. We also meet Tahani (Jameela Jamil) and Jason (Manny Jacinto) — two other ‘Good Place’ residents who don’t seem to quite belong.
At the end of Season 1, after many hijinks (watch the show — it’s hilarious!) Eleanor figures out that ‘The Good Place’ wasn’t ‘The Good Place’ after all — it’s actually a universe designed by ‘Bad Place’ demons specifically to torment Eleanor, Chidi, Tahani and Jason… for eternity.
When Eleanor and her friends discover this, they confront Michael (Ted Danson), the Head Demon, who promptly reboots the (actually bad) ‘Good Place’, vowing that each time they figure it out, he’ll wipe their memories and start over again.
rebootGoodPlace() that declares the four humans and their knowledge/deduction capacity, multiplies them together, and then reboots itself.
This code will create an infinite loop, repeating itself over and over again without stopping, for all eternity…
Which is actually pretty boring.
There’s one big element of the ‘Good Place’ that we haven’t talked about — and this is what leads to recursion. This element is a character named Janet (D’Arcy Carden).
Janet is a walking, talking computer who interacts with Eleanor and her friends. Every time Janet is rebooted, her software is improved and she becomes more and more intuitive — meaning she can respond to what is happening around her, notice context clues, and make larger and larger leaps in comprehension. Janet serves as a multiplier for the four humans’ knowledge.
Let’s declare variables for
Janet, to signify their knowledge. Since Michael built the whole system, we’ll say his knowledge is
100000. Janet, the multiplier for the humans, starts at
If you pass
rebootGoodPlace()— and call
rebootGoodPlace() from within itself, your new input would be
Janet + 1. If you call it again, it would be
(Janet + 1) + 1. And so on...
Janet changes the game. Even if Eleanor, Chidi, Tahani and Jason are reset each time, if you call
rebootGoodPlace() again within the same function, you’re running the same calculations with a slightly different Janet. (In computer science terms, you would say Janet is what makes the recursive change its state.)
But even though
totalKnowledge is going up, we’re still in an infinite loop, people! We still need a base case to enable Eleanor to exit the function. The base case is the set of conditions that need to be met in order to finally ‘exit the loop’ or ‘break the cycle.’
In ‘The Good Place,’ Eleanor wants to break the
rebootGoodPlace() cycle so she can keep her memory and stop being tortured by demons. (We’ve all got goals.)
So the recursive function, with base case, will look something like this:
Again, every time
rebootGoodPlace() runs from INSIDE itself, Janet’s skills go up by one.
You can see this play out in the first episode of Season 2. Michael has restarted the ‘Good Place’ and wiped the humans’ memory. But a smarter, more intuitive Janet puts two and two together and leads Jason to Eleanor — hastening the process of discovery for Eleanor and her companions (and leading to another reboot!).
You don’t have to know how many times the cycle will run — in fact, recursion is a typically used by a programmer when she doesn’t know how many times a cycle should run, but wants it to repeat until a solution is found.
Did you understand this description of ‘The Good Place’? If so, congratulations! You understand recursion! Here are a few more examples of recursion in popular culture:
- Tom Stoppard’s play Arcadia
- Arabic Folktale One Thousand And One Nights (idea credit: this Quora thread)
- The Droste Effect in visual art
And here are some more resources to understand recursion in computer science:
Questions? Comments? More pop culture examples? Ping me on Twitter.
(P.S. At the time of this writing in November 2017, I’ve watched all of Season 1 and the first episode of Season 2… So I have no idea if the show stays with this recursion idea or switches gears.)
Thanks to Jessica D Earley-Cha, Esther Weon, Sara Gudeman, Breanne Boland and Christina Stead for their awesome Girl Develop It San Francisco classes on recursion and other computer science methods. And HUGE thanks to Jessica Parsons for giving feedback on this draft!