This is the starter code for Lab 10. Complete the three functions marked with # TODO
to make the game work.
adventure_game.py
- Main game file with data structures and partial implementationrequirements.txt
- Python dependenciesREADME.md
- This file
pip install -r requirements.txt
Once you've implemented the required functions, you can play:
python adventure_game.py
You need to complete these three functions in adventure_game.py
:
-
message_to_story_chunk(message: List[str]) -> StoryChunk
- Parse server messages into StoryChunk objects
- Handle edge cases like empty messages
-
integrate_message(world: GameWorld, message: List[str]) -> GameWorld
- Add new story chunks to the front of the story list
- Set waiting to False
-
request_next_chunk(world: GameWorld, choice_num: int) -> Tuple[GameWorld, str]
- Process user choices and prepare server messages
- Add choice confirmation to story and set waiting to True
- Enter a number (0, 1, 2, etc.) to make a choice
- Type 'quit' to exit
By default, the game uses mock responses for testing. To connect to the real AI server:
- Get the server URL and API key from your TA
- Edit the constants at the top of
adventure_game.py
:
# Server Configuration
SERVER_URL = "https://your-lab-server.com" # Base URL (from TA)
API_KEY = "some-secret-key" # From TA
Answer the interpretive question about AI-generated content risks at the bottom of adventure_game.py
.