https://github.com/samthinkgit/aia-battleground-backend
https://github.com/samthinkgit/aia-battleground-backend
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/samthinkgit/aia-battleground-backend
- Owner: SamthinkGit
- Created: 2024-11-14T17:14:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-12T13:09:37.000Z (over 1 year ago)
- Last Synced: 2025-03-30T02:11:31.857Z (over 1 year ago)
- Language: Python
- Homepage: https://colab.research.google.com/drive/1RH6nEtPFokiP6Yf4ums0xIFa1W-UYdyB#scrollTo=H1xwd5xJseti
- Size: 16.7 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AIA-Battleground-Backend

### Main Components
- **Backend**: Contains the game logic and AI analyzer.
- `app.py`: Main backend server.
- `analyser.py`: File to modify the guided prompt of the analyzer.
- `game.py`: Initial game configuration and mechanics.
- `wrappers/character_wrapper.py`: Defines fighters and their attributes.
- `wrappers/examples`: Examples of customized fighters.
- **Frontend**: Graphical interface accessible via a web browser.
- `index.html`: Main game page.
- `media/`: Contains images and videos used in the design.
- `scripts/`: Contains `script.js` for frontend functionality.
- `styles/`: Contains `styles.css` for visual styling.
- **scripts/setup.sh**: Script to set up project dependencies.
## Installation
### Prerequisites
- Python 3.10 or higher.
- Web browser (Firefox, Chrome, Edge, etc.).
- Some python libraries such as langchain, colorama, etc. (requirements.txt not defined yet)
### Initial Setup
1. Clone this repository:
```bash
git clone https://github.com/SamthinkGit/AIA-Battleground-Backend/edit/main/README.md
cd AIA-Battleground-Backend
```
2. Run the `setup.sh` script to link the PYTHONPATH:
```bash
source scripts/setup.sh
```
This script must be run in every new terminal session or added to the `~/.bashrc` file for automation.
To add it to bashrc:
```bash
echo "source $(pwd)/scripts/setup.sh" >> ~/.bashrc
```
## Usage
### Starting the Server
1. Launch the backend on port 8000:
```bash
uvicorn backend.app:app --port 8000
```
2. Launch the frontend server on port 5500:
```bash
cd frontend
python -m http.server 5500
```
### Accessing the Game
Open a web browser and visit:
- `http://localhost:5500` to access the frontend.
### Game Customization
1. **AI Analyzer**: Modify the `backend/analyser.py` file to adjust the guided prompt as needed for the event.
2. **Game Parameters**: Edit the `backend/game.py` file to change initialization values and game mechanics.
3. **Fighters**: Modify or add fighters in `backend/wrappers/character_wrapper.py`. Each fighter must define a `response` variable with `attack`, `defend`, and `parry` attributes.
4. **Visual Appearance**: Edit the `frontend/index.html` file and resources in the `media/` folder to customize names, images, and backgrounds.
### Examples
Preconfigured fighter examples (`example_1.py`, `example_2.py`, etc.) are included in the `wrappers/examples/` folder and can be used directly in battles.
## Contributing
We welcome contributions to the project! Please open an issue or pull request in the repository if you have suggestions or improvements.