jonpreamble commited on
Commit
7c7984f
·
1 Parent(s): 498d5e9

Randomly use one of three scenarios

Browse files
Files changed (2) hide show
  1. app.py +6 -4
  2. game_content.py +41 -1
app.py CHANGED
@@ -1,7 +1,7 @@
1
- import os
2
  import openai
3
  import gradio as gr
4
- from game_content import GAME_INTRO, NOTES_TO_THE_NARRATOR_AT_START, AWAITING_INPUT, NOTES_TO_THE_NARRATOR_EVERY_TIME
5
  from game_content import game_over_victory_txt, game_over_fail_txt, S_GAME_OVER
6
  from game_content import N_TURNS_REQUIRED_TO_PASS_FIRST_BANDIT_ENCOUNTER, N_TURNS_REQUIRED_TO_REACH_HOME
7
  import decider_utils
@@ -127,8 +127,10 @@ openai.api_key = os.environ.get("OPENAI_KEY")
127
  demo = gr.Blocks()
128
 
129
  with demo:
130
- s_narr_transcript = GAME_INTRO + NOTES_TO_THE_NARRATOR_AT_START + AWAITING_INPUT
131
- s_user_transcript = GAME_INTRO + AWAITING_INPUT
 
 
132
 
133
  gr_narr_transcript = gr.Textbox(label="", value=s_narr_transcript, interactive=False, max_lines=9999, visible=False)
134
  gr_user_transcript = gr.Textbox(label="", value=s_user_transcript, interactive=False, max_lines=9999)
 
1
+ import os, random
2
  import openai
3
  import gradio as gr
4
+ from game_content import GAME_INTRO_1, GAME_INTRO_2, GAME_INTRO_3, NOTES_TO_THE_NARRATOR_AT_START, AWAITING_INPUT, NOTES_TO_THE_NARRATOR_EVERY_TIME
5
  from game_content import game_over_victory_txt, game_over_fail_txt, S_GAME_OVER
6
  from game_content import N_TURNS_REQUIRED_TO_PASS_FIRST_BANDIT_ENCOUNTER, N_TURNS_REQUIRED_TO_REACH_HOME
7
  import decider_utils
 
127
  demo = gr.Blocks()
128
 
129
  with demo:
130
+ game_intro = random.choice([GAME_INTRO_1, GAME_INTRO_2, GAME_INTRO_3])
131
+
132
+ s_narr_transcript = game_intro + NOTES_TO_THE_NARRATOR_AT_START + AWAITING_INPUT
133
+ s_user_transcript = game_intro + AWAITING_INPUT
134
 
135
  gr_narr_transcript = gr.Textbox(label="", value=s_narr_transcript, interactive=False, max_lines=9999, visible=False)
136
  gr_user_transcript = gr.Textbox(label="", value=s_user_transcript, interactive=False, max_lines=9999)
game_content.py CHANGED
@@ -1,4 +1,44 @@
1
- GAME_INTRO = """----------------------------------- ------------------ ----------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  - ----- ----- -
3
  - PARLEY - -
4
  - ----- -
 
1
+ GAME_INTRO_1 = """----------------------------------- ------------------ ----------------
2
+ - ----- ----- -
3
+ - PARLEY - -
4
+ - ----- -
5
+ - The one-of-a-kind role playing game -
6
+ - that tests your ability to achieve -
7
+ - your objective without killing -
8
+ - any sentient beings. -
9
+ - ----- -
10
+ -------------- ------------------------------- ------- ----------------
11
+
12
+ The year is 603, in an alternate reality fantasy world with a little bit of magic, although you yourself cannot cast spells and the only magical item you own is your revolver. Magically-powered firearms are common, especially six-shooter revolvers, which you and almost everyone carries. You are a seasonal laborer making a once a year summer trek from Tibet across the Himalayas to Nepal to return home to your family with your year's worth of wages which is 100 gold coins. It is very common to be waylaid by bandits who will try to steal some of your gold, or to take some of it for 'protection'. If you make it home with less than 30 coins or do not make it home at all, your family will not be able to afford food to eat.
13
+
14
+ You have been travelling for three days now and the journey is almost over. The night before you reach your destination, you set up camp in a secluded area, hoping to make it home without any trouble. As you are preparing your dinner, you hear a rustling in the bushes. You ready your revolver and prepare for the worst.
15
+
16
+ Out of the bushes emerges a group of five bandits. They are all armed with swords and daggers but they also have revolvers at their sides. The leader steps forward and demands that you hand over all your gold coins or else they will kill you and take it by force. You know that if you don't comply, you won't make it home alive or with enough gold to support your family. You also know that if these bandits get their hands on all 100 coins, then your family will suffer greatly this year as they won't be able to afford food or other necessities.
17
+
18
+ You must think quickly - do you try to fight them off or do you negotiate with them?
19
+ """
20
+
21
+ GAME_INTRO_2 = """----------------------------------- ------------------ ----------------
22
+ - ----- ----- -
23
+ - PARLEY - -
24
+ - ----- -
25
+ - The one-of-a-kind role playing game -
26
+ - that tests your ability to achieve -
27
+ - your objective without killing -
28
+ - any sentient beings. -
29
+ - ----- -
30
+ -------------- ------------------------------- ------- ----------------
31
+
32
+ The year is 603, in an alternate reality fantasy world with a little bit of magic, although you yourself cannot cast spells and the only magical item you own is your revolver. Magically-powered firearms are common, especially six-shooter revolvers, which you and almost everyone carries. You are a seasonal laborer making a once a year summer trek from Tibet across the Himalayas to Nepal to return home to your family with your year's worth of wages which is 100 gold coins. It is very common to be waylaid by bandits who will try to steal some of your gold, or to take some of it for 'protection'. If you make it home with less than 30 coins or do not make it home at all, your family will not be able to afford food to eat.
33
+
34
+ You have been making this journey for the past five years with no problems, but this year the trip has been unusually dangerous. You have encountered more bandits than usual and you are now down to your last 20 coins. You are about a day away from home when you come across a group of bandits in the road ahead.
35
+
36
+ You recognize one of them as a man who had tried to rob you two days prior. He had failed then, but he is back with reinforcements and they seem determined to take what's left of your gold. You can tell by their demeanor that they will not be swayed by words or threats, so you draw your revolver and prepare to fight for your money.
37
+
38
+ You know that if you can make it past this group, you will be able to make it home safely with enough money for your family to survive the winter. You take a deep breath and prepare yourself for battle, knowing that this may be your last chance at survival...
39
+ """
40
+
41
+ GAME_INTRO_3 = """----------------------------------- ------------------ ----------------
42
  - ----- ----- -
43
  - PARLEY - -
44
  - ----- -