diff --git a/.idea/DM-Server.iml b/.idea/DM-Server.iml
new file mode 100644
index 0000000..6711606
--- /dev/null
+++ b/.idea/DM-Server.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..2606b4c
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..6ef8750
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..68ae3d4
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..0d8077c
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,301 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1554591743543
+
+
+ 1554591743543
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/__pycache__/generator.cpython-36.pyc b/__pycache__/generator.cpython-36.pyc
index 3339740..471f3cd 100644
Binary files a/__pycache__/generator.cpython-36.pyc and b/__pycache__/generator.cpython-36.pyc differ
diff --git a/__pycache__/utils.cpython-36.pyc b/__pycache__/utils.cpython-36.pyc
index ef1fd49..f78249e 100644
Binary files a/__pycache__/utils.cpython-36.pyc and b/__pycache__/utils.cpython-36.pyc differ
diff --git a/generator.py b/generator.py
index 41e3c45..4a97be2 100644
--- a/generator.py
+++ b/generator.py
@@ -13,7 +13,7 @@ pos_action_starts = ["You attack", "You tell", "You use", "You go"]
class StoryGenerator():
- def __init__(self, sess, length=80, temperature=0.9, top_k=40):
+ def __init__(self, sess, length=100, temperature=0.9, top_k=40):
seed = None
batch_size=1
@@ -65,3 +65,14 @@ class StoryGenerator():
return possible_actions
+ def generate_action_result(self, prompt, phrase):
+ action = phrase + self.generate(prompt + phrase)
+ action_result = cut_trailing_sentence(action)
+ action_result = story_replace(action_result)
+
+ action = first_sentence(action)
+
+
+ return action, action_result
+
+
diff --git a/main.py b/main.py
index 2ac430a..74e6ea0 100644
--- a/main.py
+++ b/main.py
@@ -46,6 +46,7 @@ def server_error(e):
def story_request():
print("****Generating Story****")
prompt = request.form["prompt"] # given prompt
+ phrase = request.form["phrase"]
gen_actions = request.form["actions"] # given prompt
print("\n Given prompt is: \n",prompt,"\n")
@@ -53,8 +54,8 @@ def story_request():
generator = get_generator()
if gen_actions == "true":
- response = generator.generate_action_options(prompt)
- response = json.dumps(response)
+ action, result = generator.generate_action_result(prompt, phrase)
+ response = json.dumps([action, result])
else:
response = generator.generate_story_block(prompt)
diff --git a/static/script.js b/static/script.js
index 9b78e34..26b7ac6 100644
--- a/static/script.js
+++ b/static/script.js
@@ -6,18 +6,21 @@ start_text = "Adventurer@AIDungeon:~ 3){
+ Typer.appendToText("\nWhich action do you choose? ")
+ StoryTracker.action_int = 0
+ acceptInput = true
+ }
+ },
+
+ makeActionRequests:function(prompt){
+
+ StoryTracker.actions = []
+ StoryTracker.results = []
+
+ for (i = 0; i < 4; i++){
+ StoryTracker.requestAction(prompt, action_list[i])
+ }
+
+ },
+
+ requestStory:function(prompt, phrase){
+ $.post("/generate", {actions: false, prompt, phrase},
StoryTracker.addNextStory)
},
- requestActions:function(prompt){
- $.post("/generate", {actions: true, prompt},
- StoryTracker.addNextActions)
+ requestAction:function(prompt, phrase){
+ $.post("/generate", {actions: true, prompt, phrase},
+ StoryTracker.addNextAction)
},
processInput:function(){
@@ -61,8 +82,10 @@ var StoryTracker = {
console.log("choice_int is %d", choice_int)
StoryTracker.lastAction = StoryTracker.actions[choice_int]
- StoryTracker.requestStory(StoryTracker.firstStory + StoryTracker.lastStory + StoryTracker.lastAction)
-
+ StoryTracker.lastStory = StoryTracker.results[choice_int]
+ StoryTracker.makeActionRequests(StoryTracker.firstStory + StoryTracker.lastStory)
+ Typer.appendToText(StoryTracker.lastStory)
+ Typer.appendToText("\n\nOptions:")
}
else{
@@ -90,7 +113,7 @@ var Typer={
},
appendToText:function(str){
- str = str.replace(".", "." + "")
+ str = str.replace(".", "." + "")
Typer.text = Typer.text + str;
},
@@ -141,7 +164,7 @@ function writeAppend(str){
function startTyping(){
- addTextTimer = setInterval("typeWords()", 35)
+ addTextTimer = setInterval("typeWords()", 40)
}
diff --git a/utils.py b/utils.py
index aeb731c..bb07a51 100644
--- a/utils.py
+++ b/utils.py
@@ -65,6 +65,19 @@ def first_sentence(text):
return text
+def all_but_first(text):
+ first_period = text.find('.')
+ first_exclamation = text.find('!')
+
+ if first_exclamation < first_period and first_exclamation > 0:
+ text = text[first_exclamation+1:]
+ elif first_period > 0:
+ text = text[first_period+1:]
+ else:
+ return text[20:]
+
+ return text
+
def cut_trailing_sentence(text):
last_period = text.rfind('.')