Welcome to the git repository for the Python 3 version of Adventure!
This fork adds two new API methods to the adventure
module to make the game more accessible for programmatic use:
Creates a new Adventure game instance ready for API use. Automatically starts the game and answers "no" to the instructions question.
import adventure
game = adventure.create_game(seed=42) # Optional seed for reproducible gameplay
Sends a command to the game and returns the response. Handles command parsing and conversion to the format expected by the game engine.
response = adventure.send_command(game, "get lamp")
print(response) # "OK"
response = adventure.send_command(game, "east")
print(response) # Room description
import adventure
# Create a new game
game = adventure.create_game()
# Play programmatically
adventure.send_command(game, "get lamp")
adventure.send_command(game, "east")
adventure.send_command(game, "get keys")
adventure.send_command(game, "west")
These API methods enable:
- Automated testing of game scenarios
- AI/bot integration
- Game state analysis
- Integration with larger applications
The project README is one level deeper, inside of the package itself: