I could not find a way to build a look-up table, so I went with the repetitive pattern in the dictionary. The mechanism in the bottom right splits the barrels in groups of four. The mechanism on the left converts them according to the dictionary pattern: 3->2, 2->1, and 1->3. Groups of 4 remain intact by adding an extra barrel on the bottom right.