This is a terrific question. Pi has to use everything he knows and believes in order to survive his circumstances--both physically and mentally.
The first thing he does is to eliminate the humans in his mind. By replacing the humans with animals, he can better justify and explain their horrific actions. Animals act according to natural instinct; humans by reason. In this case, however, the humans lost all reason and acted in a way more according with beasts. Pi salvages his sanity by changing his reality into something he could justify, explain, and understand.
The second, and possibly more important, thing he does is to use his own rational mind to explore the religious systems he had encountered at home. By taking good from each of them, he is able to rest in his own humanity and determine his own fate not to become as savage as the others had. By appealing to a higher authority, Pi was able to rise above the circumstances that could easily have killed him or made him murderous and insane---as happened to everyone else on the lifeboat.
Learning to find self in higher logic and faith is a key to coming of age. He saw the savage terror of the people and determined NOT to become one of those. In order to do so, he retreated into both an imaginative and logical world where faith and reason worked together. Nothing could restore his innocent belief in humanity as a whole, but by protecting himself, he came to understand that there is both good and evil in the world. Evil plays closer to the bestial instincts, while good remains the dwelling place for reason and faith.