Ex Machina is Alex Garland’s first film as a director but it’s very simpatico with his screenplays for movies like 28 Days Later, Sunshine, and Dredd. As a writer, Garland likes to work in compact universes — an abandoned city, a spaceship headed to the sun, a gang-infested high-rise — where characters are trapped together and pitted against one another. In Ex Machina’s story of a brilliant technologist who creates artificial intelligence, he’s found a man who fashions himself as something of an inquisitive god, and there’s a bit of that notion in Garland’s work as well — he builds little petrie dishes of life, testing mankind’s resolve under extreme stress to see whether we crack under the pressure. His findings are usually not promising.

The cinematic results, though, are; Ex Machina is a confident, engrossing debut, and easily the most thoughtful consideration of the future of computerized consciousness in the midst of a slew of movies on the subject. Cannily choosing not to bite off more than he could chew — or perhaps simply continuing that creative curiosity about closed-off ecosystems — Garland decided to focus on a small cast in one location, an ultra-modern home and research facility hidden away in some unspecified nature reserve. That is where Nathan (Oscar Isaac), genius computer programmer of the world’s leading search engine, lives as he works on his latest invention: An artificial intelligence so sophisticated it becomes indistinguishable from a human being.

One of Nathan’s employees, Caleb (Domhnall Gleeson), is flown to his private estate, believing he is the winner of a random contest to meet his reclusive boss. In fact, Nathan chose Caleb to give a “Turing test” to his A.I.’s current model, a sheepish robot named Ava (Alicia Vikander). For one week, Caleb and Ava will interact — although always through thick planes of unbreakable glass, because the paranoid Nathan is worried about intellectual property theft. At the end of the week Caleb will decide whether Ava is truly human, and thus passes or fails the Turing test. But Ava may have plans of her own. Each of the characters in this complicated triangle wants different things, and each may be lying to the others about what that might be. The viewer is left to perform their own sort of Turing test — gauging each character’s relative humanity.

Locked away in this gorgeous estate, sitting around for days on end discussing the nature of consciousness, Ex Machina could have gotten very boring very quickly. That it doesn’t is a credit to the richness of Garland’s screenplay and the leads’ performances. Isaac, who is quickly becoming one of the most dependable and interesting actors in Hollywood, takes his stock character type — the suspicious, secretive designer — and pushes him in surprising comic directions. In less tense moments, Isaac’s Nathan is chatty and charming; when he drinks his behavior gets even more hilariously erratic, including in one show-stopping sequence where he cuts loose in a way that is as delightful as it is unexpected.

Performing through a heavy but utterly convincing layer of special effects, with her head composited onto a body that’s mostly comprised of translucent plastic, Vikander is good as well; she manages to juggle Ava’s alienness and familiarity simultaneously. Gleeson’s Caleb is the least fleshed out of the trio — odd for a movie in which one of the three main characters has no actual flesh — but the air of mystery around his intentions works too. Chess gets cited several times (in the context of debating whether it’s efficient to test a chess computer simply by having it play chess) but the gamesmanship in Ex Machina is more like a high-level poker game. Everyone, man and cyborg alike, is playing their cards very close to their vest. But who is bluffing?

Ava’s body is unmistakably mechanical, but she has all the curves (and, we later learn from Nathan, the equipment) of a woman, and as the tensions between the characters deepen so does the sexual dimension of the film. The idea of this powerful man lording over this female robot — and an additional character, a maid who attends to Nathan’s every need but never speaks — suggests a reading of Ex Machina as a movie about gender inequality. It’s juicy subtext, though any kind of subversive anti-patriarchal reading is undermined somewhat by the sheer amount of female nudity (and leering camerawork) that permeates Ex Machina’s second and third acts.

Still, there’s a lot to chew on here; more than can be fully digested on a single viewing, and the film is so engrossing that a trip back to explore its ambiguities sounds like a pleasure. After more than a decade of collaboration with filmmakers like Danny Boyle and Mark Romanek, Garland more than proves himself as a director in his own right. Coincidentally, one of his unproduced screenplays is an adaptation of the popular Halo video game series that would have been directed by Neill Blomkamp. The film never materialized but in a peculiar bit of timing, both men have projects about artificial intelligence coming to theaters within weeks of one another. Contemplative, beautiful, and troubling, Ex Machina renders Blomkamp’s silly, simple Chappie instantly obsolete.