This is a Streamlit-based implementation of the classic Battleship game, featuring a player versus an AI opponent powered by AWS Bedrock's Claude model.
- Interactive game board using Streamlit components
- AI opponent using AWS Bedrock's Claude model
- Game state persistence using MongoDB Atlas
- Randomized ship placement
- Turn-based gameplay
- Python 3.7+
- Streamlit
- pymongo
- boto3
- AWS account with Bedrock Claude 3.5 access on
US-EAST-1
. - MongoDB Atlas account with your IP in the accesslist permission.
- Clone the repository:
cd atlas-ai-battleship-game
- Install the required packages:
pip install -r requirements.txt
- Set up environment variables:
MONGODB_ATLAS_URI
: Your MongoDB Atlas connection stringAWS_ACCESS_KEY
: Your AWS access keyAWS_SECRET_KEY
: Your AWS secret key
To start the game, run:
streamlit run battleship-game.py
- The game starts with ships randomly placed on both the player's and opponent's boards.
- Click on the ocean emoji (🌊) on the attack board to make your move.
- The AI opponent (Claude) will make its move automatically.
- The game continues until all ships of one player are sunk.
- You can mark the ships you have sank.
main()
: The main function that sets up the Streamlit UI and game flow.initialize_game()
: Initializes the game state and database entries.render_board()
: Renders the game boards using Streamlit components.attack()
: Processes a player's attack.opponent_turn()
: Handles the AI opponent's turn using Claude.get_bedrock_claude_move()
: Interacts with AWS Bedrock to get Claude's next move.update_database()
: Updates the game state in the MongoDB database.
- Implement a more sophisticated AI strategy
- Add sound effects and animations
- Create a multiplayer mode
- Improve the UI/UX with more detailed ship information and game statistics
Contributions are welcome! Please feel free to submit a Pull Request.