Implement Entombed's lookup table Background
Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards. In recent times, the game has been subject to research — despite the strict hardware limitations of the Atari 2600, it somehow manages to create solvable mazes every time. By disassembling the game's ROM, researchers discovered that this is done with the help of a mysterious lookup table.
When a tile X is to be generated, the game first looks at the states of 5 tiles A, B, C, D, and E which are around it:
$$
\bbox[5px, border: 1px solid white]{\color{white}{\mathsf{x}}}
\bbox[6px, border: 1px solid black]{\mathtt{C}}\,
\bbox[6px, border: 1px solid black]{\mathtt{D}}\,
\bbox[6px, border: 1px solid black]{\mathtt{E}}\\
\;
\bbox[6px, border: 1px solid black]{\mathtt{A}}\,
\bbox[6px, border: 1px solid black]{\mathtt{B}}\,
\bbox[6px, border: 1px solid white]{{\mathtt{X}}}\,
\bbox[10px, border: 1px solid white]{\color{white}{\mathsf{x}}}\,
$$
These five values then index into the following 32-byte lookup table to determine what should appear at X — a wall, an empty space, or either a wall or an empty space, chosen at random:
A B C D E    X
0 0 0 0 0    1
0 0 0 0 1    1
0 0 0 1 0    1
0 0 0 1 1    R
0 0 1 0 0    0
0 0 1 0 1    0
0 0 1 1 0    R
0 0 1 1 1    R
0 1 0 0 0    1
0 1 0 0 1    1
0 1 0 1 0    1
0 1 0 1 1    1
0 1 1 0 0    R
0 1 1 0 1    0
0 1 1 1 0    0
0 1 1 1 1    0
1 0 0 0 0    1
1 0 0 0 1    1
1 0 0 1 0    1
1 0 0 1 1    R
1 0 1 0 0    0
1 0 1 0 1    0
1 0 1 1 0    0
1 0 1 1 1    0
1 1 0 0 0    R
1 1 0 0 1    0
1 1 0 1 0    1
1 1 0 1 1    R
1 1 1 0 0    R
1 1 1 0 1    0
1 1 1 1 0    0
1 1 1 1 1    0

Here R represents a value to be chosen randomly.
Task
Given values for A, B, C, D, and E as input, your program or function should output the correct value for X (either 0 or 1, depending on which row of the table the input corresponds to). However, if the input corresponds to a row in the table with an X value of R, your program should output either 0 or 1 uniformly randomly.
Rules

This is code-golf, so shortest answer in bytes wins.
Your input can be given in any reasonable format, e.g. a list of values, a string with the values in it, an integer in the range [0..31], etc.
When receiving input that corresponds to an X value of R in the table, your output has to be non-deterministic.
Jelly, 21 19 15 bytes
ị“£ṅ@kṃżF’b3¤BX

Try it online!
-4 bytes after inspiration from @Neil's Charcoal Answer (binary!).
Try all testcases listed out in a grid (each row is one input tested multiple times).
How?
ị“£ṅ@kṃżF’b3¤BX     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0,1]
                          # (2 =&gt; R; 1 =&gt; 1; 0 =&gt; 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             B            # convert to binary: 2 =&gt; [0,1], 1 =&gt; [1], 0 =&gt; [0]
              X           # Pick a random element from that list


19 byte version
(I personally like this one more because it uses special properties of ị and X)
Try it online!
Try all testcases.
ị“©½B.ọṅc’b3¤Hị1,0X     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [2,2,1,0,0,1,1,2,2,2,2,1,0,0,0,2,2,2,1,0,0,0,0,1,0,2,1,1,0,0,0,2]
                          # (2 =&gt; 1; 1 =&gt; R; 0 =&gt; 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             H            # Halve: [2,1,0] =&gt; [1,0.5,0]
              ị1,0        # Index into 1,0 (again 1-indexed)
                            # 1 gives 1, and 0 gives 0
                            # 0.5 gives [0,1]; since it is a fractional index, it gives both the element corresponding to floor(0.5) and ceil(0.5)
                  X       # Random; 3 different functions
                            # 0 =&gt; 0
                            # 1 =&gt; random integer from 1 to 1 =&gt; 1
                            # [0,1] =&gt; random element of [0,1]