Scans of the planet reveal a small anomalous area capable of supporting human life, so Commander Riker, Lt. Worf, and Lt.
Upon reading Richey's diary, they learn that his starship had launched in 2037, been accidentally contaminated by an unknown alien race, then transported through a wormhole across the galaxy; he was the only survivor.
Riker, Data, and Worf realize that the plot has been recreated in detail by the aliens and is playing out around them, and surmise that they might be able to leave if the story dictates that they do so.
Data begins to play craps, using his winnings from an earlier visit to the blackjack table, but soon senses that the dice are loaded to favor the house.
The three Starfleet officers then announce themselves as the foreign investors and buy the hotel with their winnings, give the rest of the money away to the staff and other gamblers, and depart as stated in the novel.