Interestingly, I don't necessarily think it was Twain's experience of life on the Mississippi river that gave him the inspiration for this excellent story of humour and farce so much as his time spent prospecting for gold in Nevada. Twain, during the Civil War, spent a little while serving as a solder in a company of Confederate irregulars, but he quickly found that military life was not to his taste and therefore he started his new life looking for gold. We are told that he found little gold there, but what this stage of his life did do for him was that he uncovered rich seams of storytelling within himself. This story is one that he had heard from his time mining from other miners, and Twain transforms it into a classic of American humour.
Thus whilst this tale owes a lot to Twain's own experiences in life, it is not his experiences on the Mississippi river that contributed to the creation of this story, but rather his time spent as a gold miner in Nevada.