compute reverse index for moves