The glorious “Queen of Katwe” (Disney) applies the traditional formula of an uplifting sports drama to the real-life story of a Ugandan chess prodigy.

The film then goes in unexpected directions to expose the scars horrific poverty can leave on the human soul.

The principal characters are all presented obliquely as Christian, and Phiona Mutesi’s (Madina Nalwanga) first exposure to chess comes through a sports ministry. But religious faith and practice aren’t really shown here.

The hero is Robert Katende (David Oyelowo), a missionary and former soccer player who starts a chess club in an abandoned church in Katwe, a shantytown outside Uganda’s capital city, Kampala.

He turns down an opportunity to pursue a lucrative career in engineering so he can teach the village children a skill that will enable them to expand their minds. “This is a place for fighters,” he tells them.

Phiona is illiterate, since her widowed mother, Harriet (Lupita Nyong’o), a vegetable peddler, can’t afford to send her children to school. Her older sister, Night (Taryn “Kay” Kyaze), has temporarily escaped the shantytown squalor by living with an older man who provides her with money that she passes on to Harriet.

Phiona’s introduction to chess is a simple explanation from another girl who tells her what each piece does, finishing with “They all kill each other.”

Phiona’s an outcast even among other poor children; they’ve decided that she smells bad. She faces further scorn any time she defeats a boy.

In adapting Tim Crothers’ book “The Queen of Katwe,” director Mira Nair and screenwriter William Wheeler don’t attempt to explain the vagaries of chess, other than to demonstrate, in one scene, Phiona’s particular talent with three-dimensional thinking. Instead they concentrate on her relationships with the people around her.

The scrappy poor kids of Katwe eventually take on wealthy, educated youngsters at a college tournament, and from there on, Phiona’s exposure to the outside world grows. It’s accompanied by a sudden outbreak of low self-esteem, however, as she realizes that her life has had severely limited possibilities.

From this point on, the story picks up speed as it observes the sports-film formula. Phiona has a major defeat at a Russian tournament, suffers from despair, successfully wrestles with her inner demons and steels herself for future victories.

There’s no condescension to the poverty, which is shown matter-of-factly — and without a trace of self-pity. The result is a remarkably inspirational movie about the strength of the human spirit in the face of adversity.

The film contains references to cohabitation. (A-II, PG)