Skip to content

ayush1298/AI-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI Simulator

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!

Python Streamlit PyGame

๐ŸŒŸ Features

๐ŸŽฎ Multi-Framework Support

  • PyGame Simulations: 2D physics simulations with interactive controls
  • Ursina Engine: 3D simulations and visualizations
  • Extensible Architecture: Easy to add new frameworks

๐Ÿค– AI-Powered Generation

  • 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

๐Ÿ”ง Multiple AI Providers

  • 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

๐ŸŽ“ Educational Features

  • 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

๐Ÿ’ป Development Tools

  • 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

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/ai-simulator.git
    cd ai-simulator
  2. Install dependencies

    pip install -r requirements.txt
  3. 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"
  4. Run the application

    streamlit run app.py
  5. Open your browser to http://localhost:8501

๐ŸŽฏ Usage Examples

Creating a Bouncing Ball Simulation

  1. Select your AI provider and model
  2. Enter: "Create a bouncing ball simulation with gravity and adjustable elasticity"
  3. Click "Generate PyGame Code"
  4. Use the playground to run and modify the simulation

Loading Example Simulations

  • 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

Using Audio Input

  1. Click the microphone icon
  2. Record your simulation description
  3. The AI will transcribe and generate code automatically

๐Ÿ—๏ธ Project Structure

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

๐Ÿง  AI Agent Architecture

Configurator Agent

  • Analyzes user requirements
  • Suggests interactive features and parameters
  • Focuses on educational value and engagement

Planner Agent

  • Creates detailed implementation plans
  • Structures the development approach
  • Ensures comprehensive feature coverage

Code Generation Agent

  • Generates complete, runnable simulations
  • Implements physics-accurate calculations
  • Creates interactive user interfaces

Learning Agent

  • Generates educational explanations
  • Provides physics concepts and formulas
  • Creates learning objectives and extensions

๐Ÿ”ง Configuration

Adding New AI Providers

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"
        }
    }
}

Customizing Prompts

Modify prompts.py to adjust AI behavior:

  • get_configurator_prompt(): Configuration suggestions
  • get_planner_prompt(): Implementation planning
  • get_code_gen_prompt(): Code generation
  • get_learning_prompt(): Educational content

๐Ÿ“š Example Simulations

๐Ÿ€ Bouncing Balls

  • Interactive elasticity controls
  • Gravity adjustment
  • Ball-to-ball collisions
  • Ground angle modification

๐ŸŽฑ Billiard Physics

  • Realistic ball dynamics
  • Momentum conservation
  • Force application
  • Collision highlighting

๐Ÿ“ฆ Newton's Laws Demo

  • Force vector visualization
  • Interactive mass and velocity
  • Friction effects
  • Energy calculations

๐Ÿš€ Projectile Motion

  • Adjustable launch parameters
  • Wind resistance effects
  • Trajectory prediction
  • Target practice mode

๐ŸŽ“ Educational Features

Physics Learning

  • Real-time formula display
  • Mathematical derivations
  • Physics principle explanations
  • Units and dimensional analysis

Code Learning

  • Step-by-step code explanations
  • Programming concept tutorials
  • Best practices demonstrations
  • Algorithm explanations

Interactive Experiments

  • Parameter exploration
  • Hypothesis testing
  • Comparative analysis
  • Scientific method application

Adding New Examples

  1. Create your simulation file in examples/
  2. Add metadata to ui/examples_metadata.json
  3. Test the example in the Examples Library

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages