The Magic Labyrinth

The Magic Labyrinth (1980) is a science fiction novel by American writer Philip José Farmer, the fourth in the series of Riverworld books. The title is derived from lines in Sir Richard Francis Burton's poem "The Kasîdah of Hâjî Abdû El-Yezdî": 
Originally intended to be the final book in the series, this book continues the chronicles of the adventures of Sir Richard Burton, Cyrano de Bergerac, Alice Liddell, Tom Mix, and Samuel Clemens through a bizarre afterlife in which every human is simultaneously resurrected along a single river valley covering an entire planet. Many questions about the creation and purpose of the Riverworld are answered, but several are left unanswered, prompting Farmer to write a fifth and final novel, "Gods of Riverworld", in 1983.
Edgar L. Chapman wrote a 1984 biography of Farmer entitled "The Magic Labyrinth of Philip José Farmer".
Plot.
The book begins with the Mysterious Stranger, known as X, the renegade Ethical (one of the Riverworld's creators) who posed as the engineer Barry Thorne on the airship "Parseval" and there murdered Milton Firebrass and several others, all of whom were fellow Ethicals. He is now posing as a Mayan named Ah Qaaq, in the company of the Chinese poet Li Po. Through his internal reverie he reveals that his identity was discovered by Monat Grrautut, the director of the Riverworld project, who recalled 'X' to the Dark Tower to be judged. Against this, 'X' used a remote command to kill all the inhabitants of the tower and stop the resurrections of Riverworld's inhabitants. His reverie when the left bank's 'grailstones' (supplying food and stimulants) fail to operate and are not mended by the Ethicals, who are either dead or confined (like 'X' himself) to the river. After the grailstones fail, the inhabitants of the left bank invade the right for resources, and half of humanity dies in the conflict.
Concurrently, protagonist Richard Burton and his friends have joined the crew of King John's ship, the "Rex Grandissimus", where Burton, masquerading as a Dark Age British warrior, becomes King John's security chief. One day Tom Mix, Jack London, and Peter Jairus Frigate apply to join the crew; and Burton, recognizing Frigate, attacks him as a spy for the Ethicals. Realizing his mistake, Burton allies himself with Frigate, Mix, and London. Meanwhile, the Ethical Monat Grrautut has boarded Sam Clemens' ship, where he is murdered by the renegade Ethical.
Eventually, the two riverboats reach Virolando, a wide lake before the headwaters, home to the pacifist Church of the Second Chance, where Hermann Göring has become a priest. There, King John and Clemens begin an aerial dog-fight, and later a naval combat in which both riverboats are sunk and most of the crews die. King John is killed by Clemens and Clemens dies of a heart attack after being pulled from the water by his mortal enemy Erik Bloodaxe, who has become an adherent of the Church of the Second Chance, and seeks no revenge against Clemens. Among the survivors are Burton, Frigate, Alice, Kaz, Joe Miller, Li Po, Ah Qaaq, and Nur ed-Din ("Light of the Faith"), now joined by Tom Turpin, Aphra Behn, a man claiming to be Gilgamesh, and Baron de Marbot. They take the only craft to survive the fight upriver, then scale the waterfall at the end of the river and enter the polar sea. At the tower, they expose Ah Qaaq as the renegade Ethical and take him prisoner. He identifies himself as Loga, a grandson of King Priam of Troy, resurrected centuries ago and raised by the alien Ethicals on the Gardenworld. He reveals the current date is 2307 AD and other stories were false stories to throw off investigators. He reveals also that the Riverworld is a moral test, to allow humanity enlightenment. When the project is brought to a close the souls of those who have not achieved enlightenment will wander the universe aimlessly. Loga, being obsessed with sparing his earthly family this fate, awakened Burton prematurely, recruited Clemens and the others, and diverted a metal meteorite (disrupting social harmony) to Clemens.
The protagonists discover a malfunction in the computer which runs the tower, threatening to release the stored "wathans" (souls), of the people who died on the Riverworld. Göring attempts to fix the computer, but is killed by security measures put in place by Monat, who was a member of the fifth-generation sentient race to receive "wathans" from the First Race to have "wathans". Alice then devises a way to evade this programming, and deactivate the security. Loga is then able to repair the computer.
Reception.
Greg Costikyan reviewed "The Magic Labyrinth" in "Ares Magazine" #5 and commented that "One cannot but suspect that this type of work – the pursuit by characters of an explanation for an unusual world – is not the type of work for which Farmer is cut out."