In the movie Cube the design is based heavily in math. I'm trying to figure out the approximate percentage of rooms that would be trapped.
His knowledge of the outer shell's size allows Leaven to determine that each side of the Cube is 26 rooms across, for 17,576 rooms in all.
Leaven determines that the numbers indicate the positions within the cube where each room rests between moves through the Cube
traps are not tagged by prime numbers, but by powers of prime numbers.
The fictional Cube device in the film was conceived by David W. Pravica, a mathematician. It consists of an outer cubical shell (the sarcophagus) and the inner cube. One side of the outer shell is 434 feet long. The inner cube consists of $26^3 = 17,576$ cubical rooms (minus an unknown amount of rooms to allow for movement, as shown in the film), each having a sidelength of 15.5 feet. There is a space of 15.5 feet between the cube and the shell. Each room is labelled with three identification numbers, for example, 517 478 565. These numbers encode the starting coordinates of the room and the x, y, and z coordinates are the sums of the digits of the first, second, and third number respectively. The numbers also determine the movement of the room and the subsequent positions are obtained by cyclically subtracting the digits from one another. The resulting numbers are then successively added to the starting numbers.
(the above is all from the wikipedia linked)
For a RPG scenario I'm going to stick the players in the Cube, I'd like to have an idea of how many rooms should be trapped. Also knowing coordinates of which rooms would be trapped would also be interesting, but for my purposes I'm just trying to figure out if trapped rooms are common, rare etc.
We are not told enough to be sure how the rooms are numbered. In particular the information about adding the digits of numbers representing $x,y,z$ coordinates seems to invite the possibility that several rooms might move to and occupy the same location!
A bit of Google searching led to the book Math Goes to the Movies by Burkard Polster and Marty Ross, and to a draft of a chapter for a different book by David Pravica and Heather Ries, CUBE: The Math Paper. The latter is probably going to be our most authoritative account of the numbering. I've revised my calculations accordingly.
Each room has three "physical" coordinates that tells where the room starts in the $26 \times 26 \times 26$ cube, and a nine digit identifier
xxx yyy zzzthat encodes not only that start location, but also how the room moves through a nine-step cycle.A room is "booby-trapped" if and only if one of groups of three digits within the nine digit identifier is a prime or a prime power. The "insane Mathematician" who designed the CUBE has a good bit of latitude in choosing what identifier to assign to a room, and the Pravica/Ries paper suggests that not every room moves, because some are designed to "collapse" to facilitate the movement of those rooms that do move. We shall ignore at present the further implications of that movement or collapsing.
But we must make some reasonable assumptions about the probability that coordinates are encoded as primes or prime powers. We have coordinates ranging from $1$ to $26$ (in each of three dimensions) and corresponding identifier subgroupings ranging from
001to998. So we begin by asking how many of these three digit strings represent primes or prime powers.As you can see, all but $26$ of these are (the first power of) a prime. The $0$th power is perhaps a questionable case, since every prime to the zero power gives $1$ as the result. Otherwise the prime powers are distinctly generated by the primes and the natural exponents. In many mathematical contexts $1$ would not be included as a prime power, or would be treated as a "trivial case", but I've left it in as slightly increasing the chances of a room being trapped.
If we count all the ways a coordinate from $1$ to $26$ can be represented by a prime or prime power, and divide that by the total number of ways that coordinate can be represented, we can then do a straight average of those ratios over all $26$ possible coordinate values. This is the chance of getting a prime for the three digits corresponding if choosing randomly among all possibilities, and it comes out to $0.2055$ approximately.
For a room with its three coordinates and three groupings of three digits, the only way not to be trapped is for all three groupings to be neither a prime nor a prime power. If this were chosen at random, independently for the three coordinates, then the chance of being trapped would be the complement of the chance all three coordinates avoid being represented by a prime or a prime power. The calculation comes out very close to half, namely probability of a room being trapped is $0.4984$.
A few words about how to do these calculations: The Prime Number Pages (maintained by Chris Caldwell of U. Tenn. at Martin) include this page with a Prime Counting Function applet. Enter a number in the box and click Submit, and you are told how many (positive) primes are less than or equal to the submitted number. Doing this with $998$ gives the number of first powers of primes up to that point, namely $168$. Repeating the procedure with the (floor of the) square root of $998$ gives the number of primes squared up to that threshold (there are $11$), and so on with the number of primes below the cube root of $998$ being $4$, etc..
For fifth powers of primes we are down to just powers of two or three. Five to the fifth power is too big, at $3125$. Three runs out after the sixth power, and only two makes it to the ninth power: $2^{9} = 512$.
A more complete tabulation of computations is as follows: