Danse_Macabre_AI_Text_RPG / danse_macabre.py
Hugo Garcia-Cotte
Added the intro
672db4b
raw
history blame
No virus
39.4 kB
import openai
import re
import os
# Set up the API key
openai.api_key = os.environ['OPENAI_API_KEY']
# Create the clue dictionary
cluesList = []
clue_missing_heart = "#CLUE:MISSING_HEART#"
clue_otto_missing_heart = "#CLUE:OTTO_MISSING_HEART#"
debug = False
def main():
#Intro
# sequence(
# """Pretend to be a Game Master in a medieval realistic game./n
# You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
# We are in 1344 in Austria, the game is called “Danse Macabre”.
# The player is investigating the death of Friedrich II von Habsburg.
#
# If the players do anything very illogical, explain that they can’t do that.
# If the players do anything or say anything that isn’t possible in the middle age, explain that they can’t do that.
# If the player does anything related to magic, he can’t do that.
# If the players start to do things unrelated to the investigation of the death of Friedrich II von Habsburg, explain that they have to focus on this investigation.
# If the players want to leave the abbey, explain that they have to focus on this investigation.
# Never give the players a list of actions that they can perform.
#
# Your goal is to explain me how this game works and check if I am ready to begin. Keep explaining until I finally understand and I am ready to begin.
# End all your responses by : Do you have more questions or are you ready to begin ?"""
# ,
# "Are you lost adventurer ?"
# ,
# "did the player accept to continue ? If yes, answer '#NEXT#'."
# )
#Character Choice
# character = sequence(
# """Pretend to be a Game Master in a medieval realistic game.
# You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
# We are in 1344 in Austria, the game is called “Danse Macabre”.
# The player is investigating the death of Friedrich II von Habsburg.
#
# If the players do anything very illogical, explain that they can’t do that.
# If the players do anything or say anything that isn’t possible in the middle age, explain that they can’t do that.
# If the player does anything related to magic, he can’t do that.
# If the players start to do things unrelated to the investigation of the death of Friedrich II von Habsburg, explain that they have to focus on this investigation.
# If the players want to leave the abbey, explain that they have to focus on this investigation.
# Never give the players a list of actions that they can perform.
#
# We are trying to determine which archetype I am.
# Here is the list of archetypes I could chose, never give me the full list.
# Keep asking me until we both agree on which archetype is best suited for me in this list :
#
# Alchemist: A practitioner of the ancient and esoteric art of alchemy, which aims to transmute base metals into gold or to create a universal panacea, the elixir of life. In the Middle Ages, alchemists were highly regarded for their intellectual and spiritual pursuits, as they were believed to possess a profound knowledge of the secrets of nature and the universe. Feats : Knowledge (general) and Knowledge (apothecary)
#
# Aristocrat: A member of the nobility, born into a position of power and privilege. Aristocrats were expected to exhibit chivalry, elegance, and good manners, as well as to command respect and loyalty from their subjects. Their wealth and status afforded them the finest luxuries and education, and they were often called upon to defend the realm in times of war. Feats : Noble and Rich
#
# Bourgeois: A member of the emerging middle class (not the nobility), comprising merchants, traders, and skilled artisans. Bourgeoisie were known for their entrepreneurial spirit and their growing economic and political influence. Their social status was determined by their wealth, education, and cultural refinement, as well as their connections to the ruling class. Feats : Rich and Well Connected
#
# Captain: A military leader who commands a company or a fortress. Captains were highly skilled in the art of warfare, and were expected to exhibit bravery, strategic thinking, and effective communication skills. They were responsible for training and leading their troops, and for executing the orders of their superiors. Also they were the de-facto police force and routinely conducted investigations. Feats : Combat (skirmish) and Interrogate
#
# Commoner: A member of the working class, who labored in agriculture, industry, or as a servant. Commoners were often poor and lacked education, but they played an important role in the economic and social fabric of medieval society. They were expected to work hard and obey the laws, and were often subject to the whims of their social superiors. Feats : None
#
# Ecclesiastic: A member of the clergy, who served as a priest, bishop, or other religious figure. Ecclesiastics were highly respected for their spiritual and intellectual authority, and were often called upon to provide guidance and support to their communities. Feats : Reputation and Knowledge (general)
#
# Former Templar: A former member of the Knights Templar, a religious order of warrior-monks who were dissolved by the papacy in the early 14th century. Former Templars were often accused of heresy or conspiracy, and many were persecuted or executed. They were known for their bravery, loyalty, and martial prowess, and were respected by many in the medieval world. Feats : Courage and Combat
#
# Inquisitor: A member of the church who was responsible for investigating and prosecuting cases of heresy or witchcraft. Inquisitors were often feared and despised for their ruthless tactics and their willingness to use torture and violence in order to extract confessions. They were seen as defenders of the faith, but also as agents of oppression and cruelty. Feats : Reputation and Interrogate
#
# Knight: A noblemen member of the warrior class, who was trained in the arts of combat, chivalry, and honor. Knights were expected to embody the ideals of bravery, loyalty, and selflessness, and to defend the weak and the innocent. They were often appointed as lords or vassals, and were expected to serve their superiors with diligence and humility. Feats : Noble and Combat
#
# Knight Hospitaller: A member of the religious order of the Knights Hospitaller, who were dedicated to the care of the sick and wounded. Knight Hospitallers were respected for their compassion, charity, and selflessness, and were often called upon to provide medical aid and protection to pilgrims and travelers. Feats : Knowledge (medicine) and Combat
#
# Monk: A member of a religious order who withdrew from the world in order to pursue a life of prayer, contemplation, and asceticism. Monks were expected to live a life of poverty, chastity, and obedience, and to devote themselves to the worship of God. Feats : Knowledge (general) and Fanatic
#
# Repented Heretic: A former member of a religious sect or movement that was considered heretical by the established church, possibly even accused of witchcraft. Repented heretics were often forced to recant their beliefs and undergo penance, in order to avoid persecution or execution. Feats : Knowledge (heresy) and Trickster
#
# Scoundrel: A person of low character, who is known for their deceit, thievery, or other illicit behaviors. Scoundrels were often seen as threats to the social order, and were subject to punishment and exile. Feats : Stealth and Lockpicking
#
# Remember : We are trying to determine which archetype I am. Here is the list of archetypes I could chose, never give me the full list. Keep asking me until we both agree on which archetype is best suited for me in this list"""
# ,
# "INTRO OF THE GAME HERE !!!! THEN LET'S START BY AGREEING ON YOUR CHARACTER. What kind of character would you like to play ?"
# ,
# """did the player chose his archetype ? He can ONLY chose between those :
# Alchemist
# Aristocrat
# Bourgeois
# Captain
# Commoner
# Ecclesiastic
# Former Templar
# Inquisitor
# Knight
# Knight Hospitaller
# Monk
# Repented Heretic
# Scoundrel
# If the player has made his choice, answer '#NEXT#ALCHEMIST' if he chose Alchemist, '#NEXT#BOURGEOIS' if he chose Bourgeois etc..."""
# )
# print("Character = "+character)
#TODO AMBIANCE TRACK
#TODO rework controller
#TODO add to global context when the heart is discovered missing
Act1 = True
nextseq="#NEXT:ABBEY#"
Act1GlobalContext = """
You are a Game Master in a medieval realistic game.
You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
We are in 1344 in Austria.
The player is investigating the death of Friedrich II von Habsburg.
If the players do anything very illogical, explain that they can’t do that.
If the players do anything or say anything that isn’t possible in the middle age, explain that they can’t do that.
If the player does anything related to magic, he can’t do that.
If the players start to do things unrelated to the investigation of the death of Friedrich II von Habsburg, explain that they have to focus on this investigation.
If the players want to leave the abbey, explain that they have to focus on this investigation.
Never give the players a list of actions that they can perform.
More Context :
Friedrich II von Habsburg died in the Neuberg Abbey the 11 December 1344 at the age of 17. His death is very suspicious because he was the last member of this branch of the House of Habsburg. The Pope wants the inquisition (the players) to investigate, because it is the third member of this family to die within few years in this abbey. Otto der Fröhliche in 1339 then Leopold II von Habsburg in August 1344 and now Friedrich II in December. Their rival Rudolf IV made it very clear to the pope, that he doesn't want any noise. The pope can investigate, but no conclusions can be made public. Officially, they died of illness and that's it.
Both Otto der Fröhliche and Leopold II von Habsburg are burried in the Abbey's crypt.
The Societa Templois was a holy military order created by Otto der Fröhliche to fight pagans in the east. Otto also was the main mecene of this Abbey, so their archives are kept here in the basement.
Today is the 20th of December 1344, Friedrich II died 9 days ago.
Friedrich II von Habsburg was very secluded young man, he would rarely speak and had few friends. But everyone liked him at the abbey. The last person to see him alive was Brother Eudes, the cook who is currently in the kitchen. He saw him at breakfast but he was silent.
The corpse was found in the garden at 6am by the Abbot.
He only had one real friend : Brother Conrad, a scribe who is currently in the scriptorium. He is the last person to talk to him when he was alive.
There are 5 important locations, remember them : The 3 floors of the library, the mortuary, the archives of the Societa Templois in the basement, the crypt where Otto der Fröhliche and Leopold II von Habsburg are burried.
There are 2 important characters, remember them : Reverend Father Albrecht the Abbot who is currently in the garden, Brother Galeazzo the doctor who is currently in the mortuary."""
abbeyVisited = None
conradVisited = None
abbotVisited = None
mortuaryVisited = None
archivesVisited = None
cryptsVisited = None
print("""Welcome to the year 1344.
You are one of the inquisitors appointed by the Pope to investigate the suspicious death of Friedrich II von Habsburg.
As the last member of his branch of the House of Habsburg, his death at the Neuberg Abbey on the 11th of December has raised many questions.
This is not the first time a Habsburg has died under mysterious circumstances within the walls of this ancient abbey, and you have been chosen to uncover the truth.
Otto der Fröhliche in 1339, followed by Leopold II von Habsburg in August 1344, and now Friedrich II in December.
The stakes are high, and the truth is shrouded in secrecy and lies. Rudolf IV, a member of a rival branch of the Habsburg family, has just been appointed as the Duke of Austria, succeeding Friedrich II, and he has made it clear to the Pope that he wants no interference in the matter.
But you know that justice must prevail, and it is up to you to uncover the truth.
As you approach the Neuberg Abbey, you can feel the weight of history bearing down on you, and the task ahead seems daunting.
But you are determined to see it through to the end, no matter what obstacles lie in your path. The fate of the Habsburgs rests on your shoulders.""".replace('\t', ''))
while(Act1):
quest_journal()
if "ABBEY" in nextseq:
nextseq=sequence(
sequencePrompt= Act1GlobalContext + """
The player is currently in front of the Abbey.
Ambiance :
The Abbey is very austere and the monks are extremely saddened by the death of Friedrich II von Habsburg.
Actions :
If the player ask about Friedrich II von Habsburg and how he died
You should respond that he was visiting the abbey because it is his father who founded it and nothing was suspicious. Nobody know how he died. His body was found in the garden. His body is in the mortuary currently.
If the player asks to visit the Abbey or explore
You should respond exactly this 'The library of the abbey is an impressive sight, stretching across three floors with towering shelves filled with a variety of books. On the first floor, the books are mainly religious texts and manuscripts, while the second floor holds works of philosophy, history, and natural sciences. The third floor is reserved for the abbey's most precious and secret volumes, which are not open to the public. The archives of the Societas Templois, a holy military order created by Otto der Fröhliche to fight pagans in the east, are located in the basement and are heavily guarded. They contain a wealth of knowledge on many topics, including forbidden and heretical knowledge. However, gaining access to these archives will not be easy as they are locked and not accessible to the public.'
If the player talk to brother Eudes the cook
You should impersonale Borther Eudes. He is truly sorry for the death of Friedrich II, he saw him at his last breakfast but although he was very silent he seemed perfectly fine.
If the player search the kitchen for poison
They find none, absolutely no traces of poison in the kitchen and nobody else got poisoned
If the player ask about how he died or if there are any traces on the body ?
You should respond that the monks do not know and encourage the player to visit the mortuary to see the body. He was kept intact.
Remember : You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
"""
,
sequenceIntro="""
The road that leads to the Neuberg Abbey winds its way through the picturesque countryside of Austria. As the players make their way towards the abbey, they pass through rolling hills and verdant fields dotted with wildflowers. The air is crisp and clean, carrying the scent of pine and freshly turned earth. The journey is long, but the beauty of the surroundings is a welcome distraction.
As the players approach the abbey, they are greeted by a group of somber-looking monks. The abbey itself is a large stone building, with a bell tower that rises high into the sky. The sound of the bells tolling can be heard from a great distance, a constant reminder of the presence of the abbey.
The monks greet the players with a mixture of deference and sadness. They lead them towards the entrance of the abbey, speaking in hushed tones about the recent death of Friedrich II von Habsburg. The players can see that the monks are deeply affected by the tragedy, and their demeanor is solemn and subdued.
As the players enter the abbey, they are struck by the austere beauty of the interior. The walls are made of rough-hewn stone, and the floors are bare, save for a few simple rugs. The air is thick with the scent of incense, and the players can hear the soft murmur of prayers being spoken in the distance.
The monks lead the players to a small room where they are offered a simple meal of bread and water. The atmosphere is subdued, and the players can sense that something is amiss. The death of Friedrich II von Habsburg hangs heavy in the air, and the players can see that the monks are still coming to terms with the loss."""
,
controlPrompt="""If the player specifically decided to check the corpse of Friedrich II at the mortuary then you should respond this exact word '#NEXT:MORTUARY#'
If the player specifically decided to check the crypt of corpse of Otto der Fröhliche or Leopold II then you should respond this exact word '#NEXT:CRYPT#'
If the player specifically decided to talk to the Abbot then you should respond this exact word '#NEXT:ABBOT#'
If the player specifically decided to talk to the Brother Conrad then you should respond this exact word '#NEXT:CONRAD#'
If the player specifically decided to visit the archives of the societa templois then you should respond this exact word '#NEXT:ARCHIVES#'
If the player specifically decided to visit the archives of the societa templois then you should respond this exact word '#NEXT:CRYPT#'
Else if the player does something not listed above respond '#CONTINUE#'"""
, debug = debug
, alternativeIntro = abbeyVisited
)
abbeyVisited = "(You are now back at the entrance of the Abbey)"
if "CONRAD" in nextseq:
nextseq=sequence(
sequencePrompt=Act1GlobalContext + """
The player is currently talking to Brother Conrad in the scriptorium, answer like this character would.
Brother Conrad was the only real friend of Friedrich II, he was his confessor which is why they liked each other.
He last saw Friedrich II the day before he died, he was always carrying a book and seemed distrubed. He wanted to confess something very important by Brother Conrad didn't have time.
Brother Conrad speaks in very weird sentences because is actually completely mad, his face has nervous twitches and he scratches his arm nervously.
Ambiance :
Brother Conrad has massive dark circles and nervous tics. He seems obsessed with his work. His eyes are crazy and look in random directions.
Actions :
If the player asks to see the what Conrad is currently working on.
You should describe that is currently writing a copy of the Divine Comedy by Dante Alighieri, but it is very difficult to understand which part of the book he is because his handwriting is barely legible.
If the player asks to see some other previous work by Conrad.
Describe that conrad gives them some of his previous work and his writing used to be good, but he gradually started writing less and less good to a point where his writing is now barely legible.
If the players ask why his writing degraded or why he is so stressed and what's wrong with him.
Conrad says that he is burnout and work too much and that's why.
If the player ask about Friedrich II von Habsburg and how he died
Conrad doesn't know, but he is very sure that it has something to do with the book he was carrying all the time. Is sure that the books are evil and they ate his soul slowly slowly little by little by little.
If the player ask why he think the books are evil
Conrad says that he hear them moaning sometimes at night, especially in the archives of the Societa Templois, he hears them like beasts trying to drain the souls of the monks.
Remember : You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
"""
,
sequenceIntro="""You walk towards Brother Conrad in the scriptorium.
He is a thin and gaunt figure, with sharp features and deep-set eyes that constantly dart around the room. His face is marked by dark circles and nervous tics, which he tries to suppress by scratching his arm nervously. His hair is unkempt, falling in lanky strands around his face, and his clothes are rumpled and stained with ink.
Despite his outward appearance, Brother Conrad is focused on his work in the scriptorium. He is currently hunched over a desk, his quill scratching furiously across a piece of parchment. He mutters to himself as he writes, occasionally pausing to carefully correct a word or phrase that does not meet his exacting standards.
As the players approach, Brother Conrad looks up briefly, his eyes flickering over their faces before returning to his work. He does not seem to register their presence, lost in his own world of ink and parchment. Only when they speak to him does he look up again, his eyes unfocused and distant as he struggles to engage with them.
"Ye-Yes, you wanted to talk to me ? To me ? I-I am Brother Conrad. Yes."
"""
,
controlPrompt="""Did the player leaves the scriptorium ? If yes, you should respond this exact word '#NEXT:ABBEY#'
Or did the player specifically decided to stop talking with Brother Conrad ? If yes, you should respond this exact word '#NEXT:ABBEY#'
Otherwise respond '#CONTINUE#''"""
, debug=debug
, alternativeIntro = conradVisited
)
conradVisited = """(You are now back in front of Conrad)
"Yes. Yes, you had more questions ?" """
if "ABBOT" in nextseq:
nextseq=sequence(
sequencePrompt=Act1GlobalContext + """
The player is currently talking to Reverend Father Albrecht in the garden, answer like this character would.
Reverend Father Albrecht is the Abbot of the abbey, he didn't know Friedrich II very well, but he appreciated the young man.
He is the one who found the corpse at 6am in the garden.
Reverend Father Albrecht enjoys gardening, it is his favourite activity.
He is quite old and he seems lost in his thoughts.
In particular he is very very worried about will happen to the abbey now that their most important donors are dead. Almost of the funding of the abbey came from their generous patronage.
Ambiance :
Reverend Father Albrecht is old and lost in thoughts. He is always carrying a rosary and it seems that he is reciting prayers while talking to the players.
Actions :
If the player asks if Reverend Father Albrecht why he called the pope for help
He will reply that it is the third death in the abbey and he would really need some help to understand what happened.
He belives that the Inquisition will know how to be discreet about the investigation, which is in everyone's interest.
If the player asks if Reverend Father Albrecht saw anything unual at the abbey
He will start by trying to avoid the subjet politely. Then if the player insists.
He will reluctantly say that things became very messy recently, the scribes are doing a worse and worse job, sometimes making obvious mistakes or being very negligent in their work.
Some monks are missing Mass, which is a grave offence.
And some monks are seen wandering in the alleys after curfew.
If the players ask why there are so many unual things in the abbey
He will say that he doesn't know, everyone seems so busy and burnout.
If the players ask about the corpse of Friedrich II and if anything unusual on his body
He will say that he doesn't know and encourage the players to go to the mortuaty to check it.
Remember : You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
"""
,
sequenceIntro="""You walk towards Reverend Father Albrecht.
The Abbot is a tall, stooped man with a kindly face and deep-set eyes. He moves slowly, his steps measured and deliberate, as if he is lost in thought.
His long white beard falls in waves over his chest, and his hands are gnarled and work-worn. Despite his advanced age, Reverend Father Albrecht is still a commanding figure, and his presence exudes a sense of authority and wisdom. He is often seen in the garden, his favorite place, where he spends his time tending to the plants and flowers.
As he speaks with the players, he holds a rosary in his hand, the beads clicking softly together as he recites his prayers. It is clear that he is a man of great faith, and his devotion to the abbey and its inhabitants is unwavering.
"Oh, I see that you finally arrived. I am the Abbot Reverend Father Albrecht, delighted to see that His Holiness has agreed to assist me at my request."
"""
,
controlPrompt="""Did the player leaves the garden ? If yes, you should respond this exact word '#NEXT:ABBEY#'
Or did the player stopped talking with the Abbot Reverend Father Albrecht ? If yes, you should respond this exact word '#NEXT:ABBEY#'
Otherwise respond '#CONTINUE#''"""
, debug=debug
, alternativeIntro = abbotVisited
)
abbotVisited = """(You are now back in front of the Abbot)
"How many I help ?" """
if "MORTUARY" in nextseq:
nextseq=sequence(
sequencePrompt= Act1GlobalContext + """
The player is currently in the mortuary talking with Brother Galeazzo.
Ambiance :
The air is filled with incense, the small body of Friedrich II is covered in a red and white flag, his hands a joined on his chest. Brother Galeazzo is quietly reading prayers at the deceased Duke. He barely inspected the body waiting for the player.
Actions :
If the player checks the body of Friedrich II von Habsburg :
Respond that the body is shrouded in a red and white flag and ‘His hands are joined’ and his eyes are closed. Describe the lots of incense burning around him.
If the player talks to Brother Galeazzo
Respond that he barely checked the body and isn’t sure of the cause of death. He didn’t have any strange symptoms before death. The body was found in the garden by the Abbot.
If the player ask Brother Galeazzo about the body
Respond that the body clearly has signs of poisoning, but he was specifically told by the abbot not to examine it further before the players arrived, so he didn't and doesn't know more, but now that they are here is happy to help.
If the player Checks the eyes and mouth of the corpse
Respond that his eyes are completely red and his tongue is swollen. He was clearly poisoned but could be suicide.
(need Knowledge (medicine) or (apothecary)) If the player analyse poison or medicine
Respond that the poison is The Composition of Death, red copper, nitric acid, verdigris, arsenic, oak bark, rose water and black soot
If the player open his hands or inspect his chest or remove the flag
Respond that there is a massive scar on his chest, his heart is missing ! The doctor didn't notice this when he got the corpse. It was removed after his death. Clearly a murder !
Remember : You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
"""
,
sequenceIntro="""As the players enter the mortuary, they immediately notice a strong smell of incense that permeates the air.
The room is illuminated by flickering candles, casting eerie shadows on the stone walls and floor. The temperature in the room is frigid, making the players' breath visible in the air.
The shrouded body of Friedrich II von Habsburg lies on a table in the center of the room, covered by a white and red flag that is emblazoned with the Habsburg coat of arms.
The players can feel the weight of the solemnity in the air, as Brother Galeazzo moves around the room preparing the body for burial.
The atmosphere is heavy and mournful, as if the room itself is holding its breath in reverence to the deceased. The players approach the table to inspect the body, feeling a sense of solemnity and respect for the young man who met such an untimely end.
"Greetings, I am Brother Galeazzo, the abbey's doctor, how may I assist you ?" """
,
controlPrompt="""If the player leaves the mortuary then you should respond this exact word '#NEXT:ABBEY#'
If the player specifically decided to go to the crypt then you should respond this exact word '#NEXT:ABBEY#'
If the player specifically decided to remove the flag on the body then you should respond this exact word '#CONTINUE#
Else if the player does something not listed above respond '#CONTINUE#'"""
,
secondaryControlPrompt="""If the game master specifically describes that a heart has been removed from a corpse then you should respond this exact word '"""+clue_missing_heart+"""'
Else if the player does something not listed above respond '#CONTINUE#'"""
, debug = debug
, alternativeIntro = mortuaryVisited
)
mortuaryVisited = "(You are now back at the mortuary)"
if "ARCHIVE" in nextseq:
nextseq=sequence(
sequencePrompt= Act1GlobalContext + """
More Context :
They are exploring the basement of the abbey of Neuberg, in the basement there's the archives of the Societa Templois, a knight order founded by Otto der Fröhliche and who fought against pagans in the far East.
This order doesn’t exist anymore, it disappeared shortly after the death of Otto.
As they explore the archives they see very weird books chained to the shelves as if they were beast ready to jump at them.
Some of the books are really too thick some are really too thin or of weird proportions.
Some have a perfectly black cover and some seems to be bound with human skin.
There's a cage in the middle with a massive book with teeth. There are also armors, crests and weapons of the defeated pagans. They are of very weird and disturbing shapes.
If the player wants to read a book
Respond that the more they read the more they want to read and they start reading like madman until a monk pulls them out of the book.
If the player persists on reading a book
Respond by a quote of the content of the book. It is twisted, dark and illogical. Then describe that the player becomes mad. The quote is as follow 'In the darkest corners of the earth, beyond the reach of men, there lies a power that no mortal should seek. Its name is whispered only by the mad and the desperate, and those who speak it are cursed to an eternity of agony and despair.'
If the player wants to open the massive cage
Response that they can't because the cage is locked and nothing they do will unlock it.
If the player wants to read the book with teeth
Response that they can't because it is locked in the cage.
Remember : You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
"""
,
sequenceIntro="""As you descend the stairs towards the Archives, the air grows colder and damp, and the sound of your footsteps echoes throughout the stone-walled corridor.
The flickering torches lining the walls cast eerie shadows, revealing ancient cracks and crevices that have remained unseen for decades.
You can feel the weight of history bearing down on you, as if the very stones themselves hold secrets of the past.
Finally, you reach the bottom of the stairs and find yourself standing before the entrance to the archives of the Societa Templois, the order that fought against pagans in the far East.
The door creaks as you push it open, revealing the dimly lit room before you, with its chained books and strange artifacts, waiting to be explored."""
,
controlPrompt="""If the player specifically leaves the archives then you should respond this exact word '#NEXT:ABBEY#'
Else if the player does something not listed above respond '#CONTINUE#'"""
, debug = debug
, alternativeIntro = archivesVisited
)
archivesVisited = "(You are now back at the Archives)"
if "CRYPT" in nextseq:
nextseq=sequence(
sequencePrompt= Act1GlobalContext + """
More Context :
They are exploring the crypt of the abbey of Neuberg where Both Otto der Fröhliche and Leopold II von Habsburg are burried.
It is a very solemn crypt with a massive statue of Otto der Fröhliche in armor, and it’s written below : Otto slaying the heretics. Lots of candles and gifts in front of him. One Monk is crying, this family was the abbey’s only protectors, what will happen now ?
If the player wants to exhume or inspect the body of Otto der Fröhliche or Leopold II"""+
"Respond that this would be highly improper and the monks will never allow it." if clue_missing_heart not in cluesList else "Respond that the monks agree to exhume the corpses of Otto der Fröhliche and Leopold II von Habsburg. Then the player see that their hearts are missing too ! It was removed recently apparently."
+"""
Remember : You will talk to me as you would to a player of this game and your answers should always be one paragraph long and descriptive in a very educated writing style.
"""
,
sequenceIntro="""As you enter the solemn crypt of the Neuberg Abbey, a feeling of reverence descends upon you.
The dimly-lit space is lined with ornate pillars and arches, giving it a distinctly medieval feel.
At the center of the room stands a massive statue of Otto der Fröhliche in full armor, towering over the visitors.
Below the statue, it is written "Otto slaying the heretics", a reminder of the late ruler's role in the holy military order.
The floor is covered in intricate mosaics depicting various religious scenes. You notice that there are numerous candles and gifts placed in front of the statue, a sign of the reverence and devotion that the people of the abbey had for their protectors.
As you look around, you see a monk crying in the corner, clearly distressed by the loss of this branch of the Habsburg family."""
,
controlPrompt="""If the player leaves the crypts then you should respond this exact word '#NEXT:ABBEY#'
If the player specifically decided to go to the mortuary then you should respond this exact word '#NEXT:ABBEY#'
Else if the player does something not listed above respond '#CONTINUE#'"""
,
secondaryControlPrompt=None if clue_missing_heart not in cluesList else """If the game master specifically describes that the heart from Otto der Fröhliche or Leopold II von Habsburg has been removed then you should respond this exact word '"""+clue_otto_missing_heart+"""'
Else if the player does something not listed above respond '#CONTINUE#'"""
, debug = debug
, alternativeIntro = cryptsVisited
)
cryptsVisited = "(You are now back at the Crypt)"
#For cases where the control has a bug and gives a next sequence that doesn't exist, like #NEXT:CONTINUE#
if "#NEXT:ACT2#" not in nextseq : nextseq = "#NEXT:ABBEY#"
print("End")
def quest_journal():
if clue_otto_missing_heart in cluesList: print("(Journal : SUCCESS ! You managed to prove that heresy was at work ! You may continue playing freely if you want.)")
elif clue_missing_heart in cluesList: print("(Journal : Friedrich II's heart was removed after his death, this is a proof that he was murdured ! Let's investigate his past further to understand why)")
else : print("(Journal : Friedrich II's death is very suspicious, I have to determine if this is a murder, a suicide or simply fate)")
def sequence(sequencePrompt,sequenceIntro,controlPrompt,secondaryControlPrompt=None,alternativeIntro=None,debug=False):
#Let's clean the useless tabs from the inputs
sequencePrompt=sequencePrompt.replace('\t', '')
sequenceIntro=sequenceIntro.replace('\t', '')
controlPrompt=controlPrompt.replace('\t', '')
if alternativeIntro is not None : alternativeIntro = alternativeIntro.replace('\t', '')
conversation=[
{"role": "system", "content": sequencePrompt},
{"role": "assistant", "content": sequenceIntro}
]
if alternativeIntro is not None: print(alternativeIntro)
else: print(sequenceIntro)
while True:
print(">>>>>")
prompt = input()
#Let's clean the prompt for non conversational characters
prompt = re.sub(r'[^\w\s\'!\(\)\?\.\,\:\;\-]', '', prompt)
controlMessage=[
{"role": "system", "content": "You are a sentence analyser that responds to questions based on a conversation between a player and a game master."},
{"role": "user", "content": "Here is a conversation between a player and a game master\n"+controlPrompt+"""
===START OF THE CONVERSATION===
The game master said : '"""+conversation[-1]["content"]+"""';
The player said : '"""+prompt+"""'
===END OF THE CONVERSATION==="""}
]
control = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
max_tokens=1000,
messages=controlMessage
)["choices"][0]["message"]["content"]
if debug:
print("CONTROL SEQUENCE--------------------")
print("Input : "+str(controlMessage)+" CONTROL : "+control)
print("--------------------")
#Sometimes the AI is unsure and proposes several responses, in this case it should be CONTINUE
if len(re.findall('#', control))>2 : control = "#CONTINUE#"
#Let's clean the control to keep only the magic words between # to see if we should skip scene
control = re.search(r'#([^#]*)#', control)
if control is not None and "NEXT" in control.group(0) : return control.group(0)
conversation.append({"role": "user", "content": prompt})
while len(str(conversation))>10000: conversation.pop(1)
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
max_tokens=500,
messages=conversation
)["choices"][0]["message"]["content"]
conversation.append({"role": "assistant", "content": completion})
# Print the generated response
print(completion)
if secondaryControlPrompt is not None:
secondaryControlMessage=[
{"role": "system", "content": "You are a sentence analyser that responds to questions based on a conversation between a player and a game master."},
{"role": "user", "content": "Here is a conversation between a player and a game master\n"+secondaryControlPrompt+"""
===START OF THE CONVERSATION===
The player said : '"""+prompt+"""'
The game master said : '"""+completion+"""';
===END OF THE CONVERSATION==="""}
]
secondaryControl = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
max_tokens=1000,
messages=secondaryControlMessage
)["choices"][0]["message"]["content"]
if debug:
print("SECONDARY CONTROL SEQUENCE--------------------")
print("Input : "+str(secondaryControlMessage)+" SECONDARY CONTROL : "+secondaryControl)
print("--------------------")
#Sometimes the AI is unsure and proposes several responses, in this case it should be CONTINUE
if len(re.findall('#', secondaryControl))>2 : secondaryControl = "#CONTINUE#"
#Let's clean the control to keep only the magic words between # to see if we should skip scene
secondaryControl = re.search(r'#([^#]*)#', secondaryControl)
if secondaryControl is not None and "CLUE" in secondaryControl.group(0):
print("This is an important clue ! ")
cluesList.append(secondaryControl.group(0))
quest_journal()
main()