Observed since 21 Oct, 10:45 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
AI Game Framework is a unified infrastructure designed to support the development and optimization of AI agents across various games.
An elegant, high-performance, asynchronous Python library designed to streamline the development, testing, and optimization of AI agents in both real-time and discrete-time games. Detailed documentation is hosted on GitHub Pages.
Inspired by modern web micro-frameworks like FastAPI and Flask, aigf allows developers to build games using clean functional decorators or object-oriented classes. It bundles a fully integrated lightweight HTTP/WebSocket server that automatically serves custom visualizers along with packaged styling (nord.css) and client-side logic (framework.js).
websockets and async/await event loops to easily handle large volumes of concurrent agents (perfect for neuroevolution or RL optimization).AIGameServer): FastAPI/Flask style callbacks for connection, action, tick, and state-retrieval events.GameInterface): Rigid Object-Oriented structure for strict architectural isolation.nord.css) and event handlers (framework.js) are packaged inside the wheel distribution and served natively.Add it directly to your game project's requirements.txt:
ai-game-framework >= 1.1.0
Or install it directly from source/PyPI:
pip install .
The framework handles HTTP requests through a specialized static file server routing mechanism.
When a web browser connects to the server (e.g. http://localhost:8765/):
viewer/ or frontend/ directory for an index.html file and serves it as the root webpage./aigf/framework.js or /aigf/nord.css.find_static_file) catches requests starting with /aigf/ or /framework/ and automatically serves the embedded assets bundled inside the pip package wheel. No Nginx, complex volume binds, or system-wide assets are required!// Inside your viewer/index.html
import { GameClient } from "/aigf/framework.js";
// Instantiates a client connecting automatically to ws://localhost:8765/ws
const client = new GameClient(8765);
client.onUpdate((state) => {
// Renders the real-time game state coordinates on canvas
console.log("Visualizer Update:", state);
});
Creating a game server is exceptionally quick. Register game loops and player interactions with function annotations:
from aigf.interface import AIGameServer, GameState
# 1. Initialize a real-time server operating at 30 FPS
app = AIGameServer(is_real_time=True, fps=30)
players = {}
# 2. Player handshake connector
@app.on_connect
async def connect(player_id: int):
players[player_id] = {"x": 400.0, "y": 300.0, "score": 0}
if len(players) >= 2:
app.state = GameState.RUNNING
# 3. Real-time game tick
@app.on_tick
async def tick(dt: float):
for p in players.values():
p["x"] += 10.0 * dt # Move players slightly right
# 4. Action receiver hook
@app.on_action
async def action(player_id: int, act: dict):
if act.get("cmd") == "jump":
players[player_id]["y"] -= 50.0
# 5. Visualizer state builder
@app.on_get_state
def get_state() -> dict:
return {"players": list(players.values())}
# 6. Launch the server
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8765)
The package includes two fully functioning, high-quality sample games demonstrating the API:
Located in examples/dino_jump/. Mimics Chrome's offline dinosaur game.
python3 examples/dino_jump/main.pyhttp://localhost:8765/ (press Space to jump).python3 examples/dino_jump/manual_agent.py.Located in examples/hangman/. A turn-based word-discovery game with zero ticks.
python3 examples/hangman/main.pyhttp://localhost:8765/ (click or type letters).python3 examples/hangman/manual_agent.py.Validate code changes using unittest:
python3 -m unittest discover -s tests
The codebase utilizes Google-style docstrings. Build documentation into standard HTML using pdoc:
pip install pdoc
PYTHONPATH=src pdoc --math -d google -o docs_out aigf
This project is licensed under the MIT License - see the LICENSE file for details.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.2.0 | 22 Jun 2026 | 1 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 10:45 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:c41cb3e98f0bbb1803be5f557c1a422c94b2e740d0df4efc1c453392ad8235f8