A web-based werewolf game where you can play against AI opponents powered by OpenAI's language models. Built with Vue 3, Pinia for state management, Vue Router for navigation, and Vitest for testing.
- AI-Powered Gameplay: Play werewolf with intelligent AI opponents using OpenAI's API
- Modern Vue 3 Stack: Built with Composition API, TypeScript, and Vite
- State Management: Pinia for reactive and type-safe state management
- Routing: Vue Router for seamless navigation between game screens
- Testing: Comprehensive test suite with Vitest
- Production Ready: Optimized build system with TypeScript and Vite
- Node.js (v16 or higher)
- npm or yarn
- OpenAI API key
- Clone the repository:
git clone https://github.com/yourusername/llm-werewolf.git
cd llm-werewolf- Install dependencies:
npm install- Start the development server:
npm run dev- Open your browser and navigate to
http://localhost:5173
Note: You'll need to enter your OpenAI API key when you first access the app. The API key is stored locally in your browser and is never sent to any external servers except OpenAI for AI functionality.
- Enter API Key: Input your OpenAI API key to enable AI opponents
- Game Setup: The game initializes with 6 players (1 human + 5 AI players)
- Role Assignment: Roles are secretly assigned (Villagers, Werewolves, Seer, Knight, Medium)
- Day Phase: Discuss and vote to eliminate suspected werewolves
- Night Phase: Werewolves attack, special roles use their abilities
- Win Conditions:
- Village Team: Eliminate all werewolves
- Werewolf Team: Eliminate all villagers or equal their numbers
- Strategic Gameplay: AI players make intelligent decisions based on game context
- Natural Communication: AI players engage in realistic discussions
- Role Playing: AI werewolves can lie and deceive, while village team members can reveal roles strategically
- Consistent Behavior: AI maintains character consistency throughout the game
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run test- Run tests with Vitestnpm run test:ui- Run tests with UInpm run lint- Run ESLint
src/
├── components/ # Vue components
├── stores/ # Pinia stores
├── router/ # Vue Router configuration
├── views/ # Page components
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
└── tests/ # Test files
The project uses Vitest for unit testing. Run tests with:
npm run test- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the AI capabilities
- Vue.js team for the amazing framework
- The werewolf game community for inspiration
If you encounter any issues or have questions, please open an issue on GitHub.
This application requires an OpenAI API key to function:
- User Input: Enter your API key directly in the app interface
- Local Storage: API key is stored securely in your browser's local storage
- Privacy: The key is never sent to external servers except OpenAI for AI functionality
- Security: API key never appears in repository code or server logs
To get an OpenAI API key:
- Visit OpenAI Platform
- Sign up or log in to your account
- Create a new API key
- Copy and paste it into the app when prompted
Important: Keep your API key secure and never share it publicly. Monitor your OpenAI usage to manage costs.