Riker visits CaptainJean-Luc Picard in his ready room to report only to find Picard puzzling over Fermat's last theorem. Picard's interest in this theorem goes beyond the difficulty of the puzzle; he also feels humbled that despite their advanced 24th century technology, they are still unable to solve a problem set forth by a man who had no computer. At this point, Riker informs Picard of the debris they found in the atmosphere and advises that it be beamed aboard.

A few minutes later, Miles O'Brien and Riker are down in the transporter room targeting the debris. Picard joins them and Riker tells him that they have found a piece with markings on it. Picard asks what kinds of markings. Riker admits that he does not know, then orders the piece beamed aboard. He and O'Brien then pick up the large chunk of hull beamed aboard and turn it to face the captain, revealing the word NASA and the United States of America flag on the panel. Picard then marvels at the puzzle that they have discovered.

In the conference lounge, Lieutenant CommanderData reports at the staff briefing that the debris is definitely terrestrial, from the mid-21st century. Picard doubts that any ship from that time could have traveled that far but Data holds to his conclusion based on the markings. Deanna Troi asks if Data knows what destroyed the ship. Data reports that several surfaces have disintegrated molecules.

"Well, this is what we came here for."

Riker asks how this could have happened and Data speculates that a weapon of their own time would have had this effect. "Curiouser and curiouser," Picard remarks. Wesley Crusher reports over the comm that they have found a structure on the surface of the planet and that the building is situated on frozen methane in the middle of a structure. The fact that the structure is surrounded by breathable air baffles Riker, but he still advises that he take an away team down. Picard agrees to a minimal team. Riker, Data and Lt.Worfbeam down to the narrow patch.

On the surface, they find a revolving door, seemingly free standing. Data insists that the structure is there but somehow invisible. Riker reports back to the ship their findings and Picard orders them to proceed. The away team passes through the door to enter into the lobby of a casino bustling with life. Upon entering, their signal is lost. The Enterprise cannot communicate with them or beam them up. Lt. Geordi La Forge begins rotating through different frequencies to find one that will cut through the interference. Back on the planet, Data advises that they should beam back up.

"Earth. What do you call it?"

Riker insists that they should look around since there is no apparent danger. A bellboy passes near them, informing them to check in at the front desk, where the assistant manager welcomes them to the HotelRoyale. The Bellboy from before asks the assistant manager if Rita called. The assistant manager pulls him aside and tells him to forget about Rita. The bellboy denies being afraid of Mickey D and the assistant manager tells him he is a fool for not being so. The bellboy leaves, insisting that he be told if Rita calls. The assistant manager turns his attention back to the away team, explaining that Rita is too much for the kid and Mickey D will beat him up for it. The away team then receives their room keys and a few casino chips.

Worf asks where they are and how the assistant manager got there. He tells them that they are at the Royale and that his personal life is none of their business. Riker explains that they meant what planet they are on. The assistant manager says that they are on Earth, rather than Theta VIII, then leaves to sort mail. Data wanders off and starts scanning the hotel only to find that none of the people are emitting life signs. The bewildered Riker asks what they are, only to be met by confused looks from his team.

Worf asks if they are machines or illusions. Data says that they are not illusions; they do exist, but they are neither machines nor human. He explains that the man who just walked up to them has no DNA. The man, who overhears, says that Data sounds like his ex-wife, then leaves to "get down to bidness." Data, confused by this saying, follows the man.

"It's unlike Commander Riker not to follow procedure."

Back on the Enterprise, Picard asks for a status report. Wesley and La Forge report that they are trying different encoding schemes to break through. Picard asks if an intelligent being could be causing the interference and La Forge reports that they have no idea. Returning to his command chair, Picard expresses worry that Riker has not followed protocol, returning to the beam down coordinates when they lost contact. Troi says that she does not feel that he is in any danger. He is, instead, amused. Picard accepts this but dislikes it.

In the hotel, the man Data was following has sat down at a blackjack table next to a young woman. Data comes over, and the man puts his own ten-gallon hat on Data's head, inviting him to join the game. Data accesses the rules for the game, reciting them to the wonder of the other two at the table. He then cuts the deck single-handed, also amusing the other two. The cards are dealt and the young woman becomes worried. The man, whom she calls Texas, advises her to take a hit, which puts her over 21. Similarly, he takes a card, putting him at 21.

Data asks for one card, then another. Texas asks if Data is done, to which he states that if he is supposed to get to 21, he will need at least one more card. Texas insists that this is foolish but Data asks for the card anyway. He then reveals that he, too, has 21. The man then asks if Data was counting cards, a phrase that baffles him. Riker walks over, insisting that they leave. Texas offers to watch Data's chips in his absence, then asks for his hat back.

"Having fun, Data?"

Picard asks for another report. Wesley and La Forge report that the interference has a random nature that is impossible to predict. Picard understands the problem and then expressed wonder at the difficulty of the calculations La Forge is running through the computer. He reports that he is attempting to find out if the interference bubble would withstand their phasers but does not yet know if they can get through it. He needs one more test, to which Picard agrees.

As the away team tries to exit, the revolving door only sends them back into the hotel. They try again to the same effect. Annoyed, Riker leads them in trying to find another way out. Data starts to ask one lady if she knows of another exit, but she leaves. He tries again but the second woman is distracted by winning on her slot machine.

Riker has similar luck, being ignored by multiple people. Worf moves a slot machine, looking for an exit behind the machine. Riker allows him to use a phaser to try to blast through but even on the highest setting, the phaser leaves no signs of damage. Data reports his failure, believing them to be trapped.

Aboard the Enterprise, La Forge reports that they have almost cut through the interference. Troi reports that she can sense Riker's tense feelings of being trapped.

"Our options appear to be quite limited."

Worf reports that the phaser does not work on anything around them. Data states that they have very few options. Riker, concluding they will only make it out on their own, goes back to the front desk for some answers. The bell boy then takes a gun out of a drawer but is found by the assistant manager, who tries to stop him. The kid insists that he will make Mickey D leave Rita alone. The assistant manager says it will not work, but the bell boy will have none of it. After the bell boy leaves, Riker tells the assistant manager he wants to leave.

The assistant manager says that the exits are clearly marked, but Riker tells him that that is not good enough. The assistant manager says that if he has any complaints, he should tell the manager about them. Riker asks to see the manager, but he is told that the manager is very busy. Finally, Picard is able to get through to Riker, though he still has to fight heavy interference to do so. He asks why the away team has not yet left. Riker explains that they cannot, but maintains that they are not in danger. Picard explains that they are trying to help, then ends communications, still confused by the situation.

Data reports that he has found Human DNA elsewhere in the hotel. Worf suggests that the nearby "turbolifts" might take them where they want to go. After overcoming the non-automatic doors, they take the elevator to one of the guest floors. There, they follow the signal into one of the hotel rooms.

"What a terrible way to die."

Under the covers of the bed, Riker finds a skeleton. Data reports that it is the body of a Human male. Riker speculates that he died in his sleep, a horrible death by Worf's standards. Data extrapolates that the man died 283 years ago, his corpse preserved by the sterile environment. Riker wonders why someone would go to the trouble of making a false casino for a dead man. In the closet, Worf finds the man's uniform. On the sleeve is a version of the United States flag with 52 stars, which places it between AD 2033 and AD 2079, the same time frame as the debris in orbit. Also on the uniform is the name of ColonelS. Richey.

Finally, stable communications are established and Riker reports that they are stuck. Picard reports similar failures on their part to beam them back. Riker also reports that they have found Human remains, asking that they search their database for his name. Worf finds a novel on the nightstand, titled Hotel Royale. At Riker's request, Data reads the book in a matter of seconds. Picard reports back with the colonel's identity, explaining that the corpse is that of Colonel Stephen G. Richey, who was the commanding officer of the Charybdis when it launched on July 23rd, 2037. It was the third manned attempt to leave the confines of Earth's solar system. It was never heard from again after its telemetry failed. Riker then reports the novel that they have found, which Data then summarizes.

"Seems to be exactly what's happening at this hotel."

Riker explains that the novel is being played out around them. He also reports that they have found a diary with only one entry, which he reads aloud. The colonel had written that he was the sole survivor of an aliencontaminant that killed all the others on his ship. He then found himself in the Hotel Royale, exactly as described in the novel he found in his room. He managed to survive there for 38 years, learning that the aliens created the hotel for him out of guilt, using the novel on the shuttle as a guide.

Unknown to the aliens, the recreation of the clichéd and shallow characters of the book only served as a hell for the colonel. He welcomed death as it would release him from it. Picard, grateful for understanding how the hotel came to be, still wonders why they cannot leave.

Picard reports that might be able to cut a hole through the bubble with the ship's phasers, allowing them to beam the away team out. Data calculates that they would have only twelve seconds before the hazardous atmosphere of the planet rushed in and killed them. Dr.Katherine Pulaski confirms this, stating that they would be instantly frozen but she could revive them, theoretically.

"It may get better."

Surprisingly, the telephone in the room begins to ring. Worf answers, reporting that a woman is asking if they want room service. Data speculates that they are being asked if they want the room cleaned. Worf tells her no, then is told that the kitchen is open at all times should they change their minds. Riker orders Data and Worf to the lobby while he explores the rest of the hotel.

In his ready room, Picard and Troi begin reading the novel Hotel Royale by Todd Matthews, whose complete text they have found in the Enterprise's library, and quickly realize the questionable quality of the writing. Picard is dismayed, but Troi shows optimism; she says, "It may get better."

Back in the hotel, Data suggest that they try to blend in with the other guests in an attempt to learn something useful. Data returns to the blackjack table from before and asks Texas where he is from and how he got to the hotel. When he reports that he drove there in a car, Data asks where it is and if he could see it. The man refuses and Data speculates that they are both trapped. Texas explains that he is simply trying to help the young lady, who has been losing hand after hand.

She reveals her cards, asking for advice. The man advises her to take a hit, while Data advises the opposite. She takes a card, losing again. She then worries that she's almost lost all of her money. The man comforts her. Riker comes back down to see the assistant manager telling the bell boy that Rita had called, crying. Mickey D enters through the revolving door and walks over to the bellboy.

"Well why don't we just go outside and talk about it?"

The assistant manager tries to tell them to take it outside, but they do not. Back on the Enterprise, Troi and Picard are listening in; Troi expresses disbelief that Humans actually talked that way, and Picard explains that the dialogue was all taken from a second-rate novel. Troi leaves Picard to listen to the overdone dialogue. Mickey D and the bellboy finally agree to go outside. As the bellboy walks to the door, Mickey D pulls out his gun and shoots him in the back, killing him. He walks to the slain bellboy, telling him that Rita wasn't worth dying for, then he leaves. Riker asks Picard how that was possible and he explains that it happened on page 244.

He then summarizes the ending of the novel, explaining that the hotel is bought out. When Riker asks by whom, Picard explains that it is not specific, the novel just says that foreign investors bought it for 12.5 million dollars then return home, leaving the assistant manager in charge. Riker brightens and exclaims, "That's how we're getting out. We're buying this place!"

Data explains that craps is a simple game of probabilities, then explains the rules. Riker asks if he can win them the money they need and Data believes he can. The away team goes over to a nearby craps table where Texas and the lady from the blackjack game are playing. On her first roll, the lady rolls a two – snake eyes, and Data explains that they are not desirable. She rolls again, getting a seven. The dice are then given to Data, who rolls them, getting a six.

At Riker's confusion, Data explains that he must then get another six before getting a seven. Confused at the roughly equal probabilities of rolling a six or a seven, Data explains that there is a degree of random fortune involved, hence gambling. He rolls but gets a seven – loses his bet. Texas, however, feels confident in their ability and wants him to roll again. Data notices that the dice are loaded, and then re-weights them in his favor, proclaiming he "needs a new pair of shoes". He then rolls successfully several times over, much to the delight of Vanessa and Texas.

"When the train comes in, EVERYBODY rides!"

Riker reports that they are having good luck but Picard warns them to stay in character. He then explains that the investors are "flamboyantly generous." At that, Riker insists that they bet all 12.3 million dollars, giving out some of their winnings to those around them. Texas however, decides to bet against the away team, reasoning that their luck is running out, over objections from Data. Upon winning again, Texas complains to Data he knew the roll would work in the android's favor. Data rebuffs saying he tried to warn him. Afterwards they buy the hotel, and spread the remainder of the cash to the patrons and staff, fulfilling their roles as the foreign investors in the novel. Texas, impressed with their style, offers to buy them a drink, but Riker politely declines his offer, and instead tells them to enjoy the game, but reminds them "not to change the dice". With their roles finished, they finally leave through the revolving doors and beam back up to the ship.

Back on the ship, Riker visits Picard in his ready room. Riker still wonders how such a primitive ship made it this far. Picard suggests that maybe the aliens who made the casino brought the colonel there but also suggests that, like Fermat's Last Theorem, they may never solve the puzzle of the Hotel Royale.

"What planet is this?""I beg your pardon?""This planet. What do you call it?""Earth. What do you call it?""We call it Theta VIII.""How charming."

- Riker, Clerk, and Worf

"How did you get here?""Vegas? Drove my car.""Can you take me there?"

- Data and "Texas"

"We'd like to get out of here, now."
"The Royale's exits are clearly marked."

- Riker and Clerk

"No woman is worth dying for. Killing for, not dying for."

- Mickey D, after killing the bellhop

"Perhaps those turbolifts can take us there."
(He stands in front of the door, expecting it to open automatically like those of the Enterprise turbolifts, but it does not.)
"Seems to be malfunctioning..."

- Worf, about the hotel lift

"Whew, nasty!"

- Geordi La Forge, on Theta VIII

"Looks like the poor devil died in his sleep.""What a terrible way to die."

- Riker and Worf

"When the train comes in, EVERYBODY rides!"

- Riker

"Look who's talking. Man, you sound just like my ex-wife!"

- Texas, to Data

"There is a female voice asking if we want "room service"."
"I believe she is asking if we want the room... cleaned?"
"Tell her no."

- Worf answers a phone, while Data and Riker misunderstand the concept of room service

"Revolving door? Number One, proceed with caution."

- Picard

"Baby needs a new pair of shoes."

- Data

"I write this in the hope that it will someday be read by Human eyes. I can only surmise at this point, but apparently our exploratory shuttle was contaminated by an alien life form which infected and killed all personnel except myself. I awakened to find myself here in the Royale Hotel, precisely as described in the novel I found in my room. And for the last thirty-eight years I have survived here. I have come to understand that the alien contaminators created this place for me out of some sense of guilt, presuming that the novel we had on board the shuttle about the Hotel Royale was in fact a guide to our preferred lifestyle and social habits. Obviously, they thought this was the world from which I came. I hold no malice toward my benefactors. They could not possibly know the hell they have put me through... for it was such a badly written book, filled with endless cliché and shallow characters... that I shall welcome death when it comes."

- Riker, reading Col. Richey's sole diary entry

"'It was a dark and stormy night...' Not a promising beginning.""It may get better."

- Picard and Troi, reading the beginning of Hotel Royale

"Alright! Time to get down to bidness.""What sort of 'bidness' do you suppose he is getting down to?"

Writer Tracy Tormé first pitched the story (then called "The Blue Moon Hotel") to Robert Lewin during the first season, and it was one of two scripts that won Tormé a staff job on TNG. According to Tormé: "There had been a lot of talk about doing it in the first year, but finally [in the second] year they gave me the green light and told me to go ahead and do it. It became 'The Royale,' and I wrote a draft which was, again, a bit of a departure for Star Trek. It was kind of a surrealistic piece, with a lot of comedy and lot of subtle satire in it." (Star Trek: The Next Generation Companion; Captains' Logs: The Unauthorized Complete Trek Voyages)

Tormé commented, "I've completely disowned the piece. I suppose skeletally it's my story, but when I started to reread the rewrite, I got ten pages through it and I got sort of a cold chill and had to put it down. An interesting thing is that the cast, the crew and even secretaries went out of their way to tell me how much they liked my draft, and they asked me in a totally puzzled manner, what on Earth had happened and why we had changed it. All I could do was shrug. Of course this is all my opinion, and you'd probably hear something different from the other side...I felt like a lot of the comedy was taken out. A lot of the surrealism was taken out. I feel that it's very heavy-handed now, and it's gone from being a strange episode to being a stupid episode." (Captains' Logs: The Unauthorized Complete Trek Voyages)

The dispute resulted in Tormé leaving active staff duty and taking on a lesser role as creative consultant. He would contribute to only one more episode, "Manhunt", where further script disputes led to Tormé's ultimate departure. (Star Trek: The Next Generation Companion)

Bole observed, "I thought Tracy's original story was much better. Different strokes for different folks. Sometimes you get a story and there's no backup to go to. If you have two on hand, you might make the move to do another one while you repair the first to make it better. Other times, time just crawls up your back and you have to shoot these every goddamned day...'The Royale' was one of those things that happen in television, where you have an idea and you have to get out there and shoot it because time is coming on you." (Captains' Logs: The Unauthorized Complete Trek Voyages)

In the original script, the astronaut survivor was the last of a crew of seven to die. His image was kept alive in the fantasy setting to be entertained by the Enterprise crew. In the end, a dead away team crew woman remains to keep the astronaut company, similar to "The Cage". (Star Trek: The Next Generation Companion)

La Forge states that Theta 116 has a surface temperature of −291 °C. That temperature is below absolute zero (−273.15 °C), and is therefore impossible to attain. Furthermore the planet's age is estimated to be 7.2e10×1010, or 72 billion earth years old, far older than the universe itself.

Fermat's last theorem is mentioned as being unproved for eight hundred years. In 1995 (six years after this episode was written), however, a proof was discovered by Andrew Wiles. It was later corrected for in the Star Trek: Deep Space Nine episode "Facets" when Jadzia Dax tells Tobin (embodied in ChiefO'Brien during Jadzia's zhian'tara) that many others have tried more original approaches to Fermat's Last Theorem since Wiles's original proof in the 1990s. Cliff Bole also directed "Facets." The implication is that the Wiles Proof, while correct, involved mathematics too complex for Fermat's time.

The idea of an advanced alien race recreating a suitable environment from a wayward astronaut's cultural artifacts in which to live out his final days was first detailed by notable science fiction author Arthur C. Clarke and film director Stanley Kubrick in the novel and movie 2001: A Space Odyssey. A somewhat similar concept is also explored in the Voyager episode "Displaced".

A United States flag with 52 stars

Data's gambling in the casino is similar to another script written by Roddenberry. In The Questor Tapes, the android discovers that the dice are counterfeit and changes the balance in order to win the game.

The 52-star United States flag seen in "The Royale" is unusual in that the field of stars rests on a red stripe instead of a white stripe. The fifteen-striped "Star-Spangled Banner" flown over Fort McHenry during the War of 1812 was the last such flag, and since then, all flags (then returning to thirteen instead of fifteen stripes) have had the familiar arrangement of the field being to the left of the first seven stripes and resting on the eighth, a white.

The mission patch on the dead astronaut's uniform is an Apollo 17 (1972) patch, with the word "Apollo" removed, still bearing the names of that mission's astronauts (Cernan, Evans, and Schmitt) and the number 17.

The debris of the Charybdis beamed aboard the Enterprise features the NASA "worm" logo. NASA retired this logo in 1992 (only three years after this episode was filmed), replacing it with the traditional "meatball" logo.

Director Cliff Bole remembered that "...there were budgetary problems. It suffered horribly from a budget situation and got cut back drastically. In my opinion, it was a rather claustrophobic show, but we did end up building a Vegas set out of nothing. That was right up my alley, because I had done every other episode of Vegas. We built the set with some curtains and a lot of tricks. Richard James, the designer, came up with some very quick and dirty angles, and it was all budgetary. The revolving door was just a revolving door sitting in black. That read, didn't it?" ("Cliff Bole - Of Redemption & Unification", The Official Star Trek: The Next Generation Magazine Vol. 17, p. 29)