-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadventures.py
55 lines (43 loc) · 1.47 KB
/
adventures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from model import Model
from view import View
from controller import Controller
class Adventure:
"""
An implementation of an AI generated choose your own adventure story.
Attributes:
_model: An instance of the model class which keeps track of game state.
_view: An instance of the view class which displays the game to the
user.
_controller: An instance of the controller class which gathers user
input.
"""
def __init__(self):
"""
Instanitate necessary variables for the game.
"""
self._model = Model("TEST", "test.csv")
self._view = View()
self._controller = Controller()
def run(self, prompt):
"""
Runs the main loop of the game.
Args:
prompt: String used as a prompt for the AI to start the game.
"""
game_over = False
while not game_over:
# Display prompt
self._view.display(prompt, new_line=True)
# Generate text
output = self._model.generate_text(prompt)
# Display text
self._view.display(output)
# Get user input
prompt = self._controller.prompt()
# Check if game is over
# TODO: Implement game over detection
if prompt == "EXIT": # User exit
game_over = True
if __name__ == "__main__":
game = Adventure()
game.run("Once upon a time...")