As you might expect, the whole rotting in prison thing weighs heavily upon Edmond. He asks for any and every kind of change: to be thrust deeper into darkness, to be given fresh air and exercise; he asks for a cellmate, even if he's the crazy abbé. Deprived of real human contact, he talks to his jailer, despite the fact that his jailer won't talk back.
Eventually, he turns to God, praying fervently and furiously ever day, but his prayers aren't answered. He becomes obsessed with the idea that his life, so promising, was destroyed by fate.
He begins to curse his jailer. He throws himself against the walls of his cell.
He decides, at one point, that human hatred, not divine vengeance, must be responsible for his plight; he decides, too, that proper retribution requires a punishment crueler than death.
His thoughts turn to suicide, and the simple thought that he could end his life, the knowledge that he retains some power over his fate, eases his pain. He decides there are two ways for him to go: hanging and starvation.
Four years into his imprisonment, he decides to starve himself. He throws away his food each day until he becomes so weak that he cannot even summon the strength to do that.
That evening, he hears a strange scratching, unlike the noise of vermin that he has become accustomed to. He writes it off as a hallucination.
He hears the same noise, louder now, a few hours later. Edmond is intrigued. When the jailer comes in with his lunch, he makes sure to talk loudly, in order that he might cover up the noise – he's sure that a fellow prisoner, a fellow human being is responsible for it.
Still, he can't be sure, at least not yet. Driven on by hope, he begins eating again, then sets about finding a way to test his hypothesis about the noise.
He decides to knock on the wall: if the work resumes quickly thereafter, he'll know it's being done by a workman; if it ceases until the evening, he'll know it's a prisoner.
The noise does not resume that evening, nor the next day, nor the day after that. It's only three days later that he hears even the faintest scratching.
Encouraged, he begins to look for some tool he can use to work at the cement between the stones in the wall.
He decides to break his water pitcher and sharpen the end of its handle into a point. He works all night, making little progress, but he's happy nonetheless.
The next day, the jailer doesn't seem too concerned about the broken pitcher; he merely finds Edmond a new one.
Edmond realizes that, had he spent the last few years working like this, he could have been out, or at least been closer to escaping; though he's disheartened, he doesn't give up, and in three day's time he's managed to loosen a stone.
Unfortunately, he can't seem to move the stone any further, at least not with his current tools.
To make a long story short, he comes up with a way to get a hold of the metal handle on the tin soup pot the jailer brings every day.
Using the handle, he's able to dig deeper, but he runs into an obstacle: a large beam in the wall.
He cries out in despair only to hear a voice from below answer his cry.
The two voices get to talking. Edmond introduces himself and, when asked, describes the location of his cell.
The other voice/person is distressed. He was under the impression that he'd been digging toward an exterior wall and would soon open up a tunnel to the sea, from which he could escape.
The voice then introduces himself as Number 27. He tells Edmond to close up his hole, conceal everything and wait for his signal.
Edmond, afraid of never hearing from 27 again, pleads with him to return soon.
Number 27, reassured by Edmond's youth, promises to return soon.
After sealing up the hole, Edmond is overcome with joy.
Number 27 calls the next day, soon after the jailer leaves Edmond's cell. They decide that the coast is clear and, like that, a man, a whole man emerges from the hole.