U : Up
B : Bottom
L : Left
R : Right

U B L R   Id
0 0 0 0 : 0
0 0 0 1 : 1
0 0 1 0 : 2
0 0 1 1 : 3
0 1 0 0 : 4
0 1 0 1 : 5
0 1 1 0 : 6
0 1 1 1 : 7
1 0 0 0 : 8
1 0 0 1 : 9
1 0 1 0 : 10
1 0 1 1 : 11
1 1 0 0 : 12
1 1 0 1 : 13
1 1 1 0 : 14
1 1 1 1 : 15

To get the real Id, you have to add the base Id of wall to the Id of the table