Ralph is supposed to make his decision regarding where he is going to sleep. Near the end of the novel, it becomes apparent that he has already made his decision. The obvious choice is to sleep in an empty shelter but he believes that it is not going to be safe for him.
He has decided that he will be sleeping in Castle Rock instead. If he decided to sleep at the beach, it would have been problematic for him as the other hunters would have seen the place that he has claimed for the night. By sleeping at Castle Rock, he was able to stay safe from Jack and the rest of the hunters.
Ralph decides to sleep at Castle Rock that night in order to circumvent Jack and his hunters. If he had slept at the beach, his "base", the hunters would have easily found him there beause it would be the first place they would look.