Moses Christensen, of Corser Street, Stourbridge, had been walking for 20 miles when he came across 70-year-old Richard Hall on Brown Clee Hill in south Shropshire last August.
Mr Hall, from Perton, South Staffordshire, was found dead with dozens of stab wounds and Christensen arrived on a nearby woman's doorstep to report that he had killed him.
Christensen is on trial at Stafford Crown Court because he denies murder by reason of diminished responsibility.
The case so far:
The trial heard on Friday from Dr James Collins, a consultant forensic psychiatrist at the secure Ashworth hospital where Christensen was previously a patient.
The doctor provided evidence to the trial following his own interviews with Christensen and conversations with his family.
Dr Collins painted a picture of a man who had once been a "caring, sensitive and thoughtful boy" but who by the age of 13 had begun experiencing severe paranoia, psychosis and delusions about the people around him – the court heard that he came to believe that other people in his life were "props" in a fake world that had been arranged specifically to make his life miserable.
Christensen began seriously struggling in school and social situations and said he wanted to kill a number of his teachers.
As a teenager and young adult Christensen withdrew from the world he hated so much, "barricading" himself in his bedroom and watching violent videos on the internet while his paranoia grew, the court heard.
In conversations with psychiatrists he expressed his desire to kill every other human being on the planet "on an atomic level".
He would research psychopathy and the Columbine High School massacre online.
Dr Collins said that the "thoughtful, caring Moses" was "warring with the evil Moses" who "told him 'everyone hates you'".
At times Christensen pursued ambitions of joining the Royal Marines and of kayaking around the country with his dog, and spent time living rough in the countryside.
At the time he met Mr Hall in the Shropshire countryside, he had "nothing but the clothes on his back", the court heard.
The trial continues.