Silver Linings Playbook seems like a losing proposition.

The main characters are Philadelphia sports fans and mentally unbalanced people (no jokes about how those two things seemingly go together), and they may or may not be saved by dancing. Plus, there's the weirdness of pairing, on screen, 37-year-old Bradley Cooper and 22-year-old Jennifer Lawrence. And it's a comedy with dramatic leanings.

Seriously. It sounds terrible.

What a pleasant surprise it is that Silver Linings Playbook is excellent. It is, possibly, even wonderful. Writer-director David O Russell (working from a novel by Matthew Quick) has a history of turning seemingly difficult material into good movies—Spanking the Monkey deals with incest and Three Kings tackles the 1991 Iraq War, for example—so it should be no surprise that he makes us care about a patently unlikable lead character.

That patently unlikable character is Cooper's Pat, who has just been released from a mental hospital after an eight-month stint. He was inside for nearly beating his wife's lover to death after he found them in the shower together. Now living with his parents (Robert De Niro and Jacki Weaver), Pat is convinced he's going to get back together with his wife, despite the fact that she has a restraining order against him and he's suffering from bipolar disorder.

One could argue Pat's mom and dad need hospitalization, too: dad for gambling and mom for putting up with her insane family.

Add to that Lawrence's Tiffany, who's reeling from the death of her police officer husband and is called a slut by others in the community for using sex to cope with the loss. Worse yet, she agrees with those people. In other words, she hates herself.

But one thing Pat understands is self-hatred. So when a friend of Pat's—who happens to be married to Tiffany's older sister (Julia Stiles), who's also Pat's wife's best friend—brings Pat and Tiffany together on a stealth double date, they hit it off even if they don't realize it. They feign not liking each other much, but they agree on one thing: Medications to treat mental illness suck.

From that meeting, a plot is hatched. Tiffany will help Pat communicate with his wife via letter if Pat helps Tiff compete in a dance competition. He agrees. There's a subplot with Pat's dad, who's a bookie (of course), betting his longtime gambling friend and rival that Pat and Tiffany will earn a particular score from the competition's judges.

Any hesitation you feel toward leaping in with both feet to cheer these characters on is perfectly understandable. In addition to the far-fetched story threads, the characters scream at each other a lot and make it hard for us to like them.

But somehow we do like them. At this point in his career, Cooper is well versed in making terrible people our friends. When in doubt, remember that he gets us to root for his character in The Hangover, Phil, scumbag of scumbags. We want him to find Doug!

And here, we want him to find whatever it is he has to find.

Silver Linings Playbook demands a lot from its audience but also rewards patience. All that shouting, self-delusion and magical thinking pays off in the end.

A bonus is the steady stream of excellent character work. De Niro takes a break from appearing in bad movies and gives Pat's dad—Pat Sr., and we can see why junior is so fucked up—a human quality that makes his compulsive gambling and bookmaking seem less a character flaw than the thing Pat Jr. needs to rise above the muck that is past. Chris Tucker pops up (where has he been since Rush Hour 3?) and supplies a minor supporting character with some gravitas, simply because he's portrayed by Chris Tucker.

If you've seen the trailer, you should be able to guess how Silver Linings Playbook ends. Even if you haven't, it's no surprise. But watching all these twisted souls make good is a lot of fun, even if you know what's coming.

Directed by David O Russell / With Bradley Cooper, Jennifer Lawrence and Robert De Niro / Regal Santa Fe Stadium 14/ R / 122 min.