A powerful AI-driven platform for creating, learning, and experimenting with physics simulations using PyGame and Ursina. Generate interactive simulations with just natural language descriptions and explore the physics behind them!
- PyGame Simulations: 2D physics simulations with interactive controls
- Ursina Engine: 3D simulations and visualizations
- Extensible Architecture: Easy to add new frameworks
- Natural Language Input: Describe simulations in plain English
- Multi-Modal Input: Text, file upload, or audio recording
- Intelligent Agents: Specialized AI agents for configuration, planning, and code generation
- Physics-Aware: Generates scientifically accurate simulations with proper formulas
- OpenAI: GPT-4o, GPT-5, GPT-4o Mini
- Anthropic: Claude 3.5 Sonnet, Claude 4, Claude Opus 4.1
- Google: Gemini 2.0 Flash, Gemini 2.5 Pro, Gemini 1.5 Pro
- DeepSeek: DeepSeek R1, DeepSeek V3, DeepSeek Coder V2
- Mistral: Mistral Large 2, Codestral, Mistral Medium 3.1
- Cerebras: GPT OSS 120B, Llama 4 Maverick, Llama 4 Scout
- Grok: DeepSeek R1 Distill, Kimi K2 Instruct
- OpenRouter: Access to 15+ models including Qwen 3 series
- Code Explanation: AI-powered code explanations
- Learning Materials: Physics concepts, formulas, and theories
- Interactive Examples: Pre-built physics demonstrations
- Real-time Experimentation: Modify parameters and see immediate results
- Live Code Editor: Syntax highlighting with Monaco/ACE editor
- Python Playground: Run and test code in real-time
- Chat Interface: Iterative improvements with conversation context
- Project Management: Save, load, and export complete projects
- Python 3.8 or higher
- pip package manager
-
Clone the repository
git clone https://github.com/yourusername/ai-simulator.git cd ai-simulator -
Install dependencies
pip install -r requirements.txt
-
Set up API keys (choose at least one provider)
# OpenAI export OPENAI_API_KEY="your_openai_api_key" # Anthropic export ANTHROPIC_API_KEY="your_anthropic_api_key" # Google Gemini export GEMINI_API_KEY="your_gemini_api_key" # DeepSeek export DEEPSEEK_API_KEY="your_deepseek_api_key" # Mistral export MISTRAL_API_KEY="your_mistral_api_key" # Other providers (optional) export CEREBRAS_API_KEY="your_cerebras_api_key" export GROK_API_KEY="your_grok_api_key" export OPENROUTER_API_KEY="your_openrouter_api_key"
-
Run the application
streamlit run app.py
-
Open your browser to
http://localhost:8501
- Select your AI provider and model
- Enter: "Create a bouncing ball simulation with gravity and adjustable elasticity"
- Click "Generate PyGame Code"
- Use the playground to run and modify the simulation
- Visit the Examples Library tab
- Choose from pre-built simulations:
- ๐ Bouncing Balls Physics
- ๐ฑ Billiard Ball Dynamics
- ๐ฆ Newton's 3rd Law Demo
- ๐ Projectile Motion
- โ๏ธ Pendulum Simulation
- Click the microphone icon
- Record your simulation description
- The AI will transcribe and generate code automatically
ai-simulator/
โโโ app.py # Main Streamlit application
โโโ prompts.py # AI prompt templates
โโโ requirements.txt # Python dependencies
โโโ agents/ # AI agent modules
โ โโโ base_agent.py # Base agent class
โ โโโ configurator_agent.py # Configuration suggestions
โ โโโ planner_agent.py # Implementation planning
โ โโโ code_gen_agent.py # Code generation
โ โโโ learning_agent.py # Educational content
โโโ config/ # Configuration files
โ โโโ models_config.py # AI model configurations
โโโ ui/ # User interface components
โ โโโ main_ui.py # Main UI logic
โ โโโ model_selector.py # Model selection interface
โ โโโ examples_library.py # Examples management
โ โโโ examples_metadata.json # Example descriptions
โโโ utils/ # Utility functions
โ โโโ transcription.py # Audio transcription
โ โโโ python_runner.py # Code execution
โโโ examples/ # Pre-built simulations
โ โโโ balls_dropping.py
โ โโโ billiard_balls.py
โ โโโ collision_box_wall.py
โ โโโ newtons3rd_law.py
โ โโโ projectile_motion.py
โโโ motion_of_pendulum.py
- Analyzes user requirements
- Suggests interactive features and parameters
- Focuses on educational value and engagement
- Creates detailed implementation plans
- Structures the development approach
- Ensures comprehensive feature coverage
- Generates complete, runnable simulations
- Implements physics-accurate calculations
- Creates interactive user interfaces
- Generates educational explanations
- Provides physics concepts and formulas
- Creates learning objectives and extensions
Edit config/models_config.py:
MODEL_PROVIDERS["NewProvider"] = {
"api_key_env": "NEW_PROVIDER_API_KEY",
"base_url": "https://api.newprovider.com/v1",
"models": {
"new-model": {
"name": "New Model",
"description": "Description of the model",
"max_tokens": 4096,
"cost": "Medium"
}
}
}Modify prompts.py to adjust AI behavior:
get_configurator_prompt(): Configuration suggestionsget_planner_prompt(): Implementation planningget_code_gen_prompt(): Code generationget_learning_prompt(): Educational content
- Interactive elasticity controls
- Gravity adjustment
- Ball-to-ball collisions
- Ground angle modification
- Realistic ball dynamics
- Momentum conservation
- Force application
- Collision highlighting
- Force vector visualization
- Interactive mass and velocity
- Friction effects
- Energy calculations
- Adjustable launch parameters
- Wind resistance effects
- Trajectory prediction
- Target practice mode
- Real-time formula display
- Mathematical derivations
- Physics principle explanations
- Units and dimensional analysis
- Step-by-step code explanations
- Programming concept tutorials
- Best practices demonstrations
- Algorithm explanations
- Parameter exploration
- Hypothesis testing
- Comparative analysis
- Scientific method application
- Create your simulation file in
examples/ - Add metadata to
ui/examples_metadata.json - Test the example in the Examples Library