Skip to content

✨ My collection of AI code from college nights! Search algorithms, genetic stuff, and other weird computer-thinky code that actually works - all written in Python! Grab it if you're stuck on assignments! πŸ’»β˜•

Notifications You must be signed in to change notification settings

Jia2005/AI-codes-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Algorithms in Python

Sup fellow coders! 🀘 Dumping my AI algorithm collection from those loooong college nights when coffee was my best friend and sleep was just a concept.

AI Brain

πŸ“š Table of Contents

πŸ› οΈ What's Inside

Here's the AI stuff I survived implementing:

πŸ” Search Algorithms - Finding paths through problems
Algorithm Description File
DFS Depth-First Search - Goes as deep as possible before backtracking DFS_DLS_DFID.py
DLS Depth-Limited Search - Like DFS but with a "that's deep enough, I'm out" limit DFS_DLS_DFID.py
DFID Depth-First Iterative Deepening - Combines BFS's completeness with DFS's memory efficiency DFS_DLS_DFID.py
BFS Breadth-First Search - Explores all neighbors before going deeper BFS_UCS.py
UCS Uniform Cost Search - Like BFS but considers path costs BFS_UCS.py
GBFS Greedy Best-First Search - The impatient algorithm that always chases what looks good GBFS_Astar.py
A* A-Star - Uses heuristics to find optimal paths efficiently GBFS_Astar.py
⛰️ Hill Climbing - Just keeps going up until it can't anymore

Simple optimization algorithm that:

  • Starts at a random solution
  • Iteratively makes small improvements
  • Stops when no better neighbor exists
  • Often gets stuck in local maxima
def hill_climbing(problem):
    current = problem.initial()
    while True:
        neighbor = problem.best_neighbor(current)
        if problem.value(neighbor) <= problem.value(current):
            return current
        current = neighbor
🧬 Genetic Algorithms - Digital Darwin stuff where code evolves and the fittest survives

Evolution-inspired approach that:

  • Creates a population of potential solutions
  • Evaluates their fitness
  • Selects the best individuals
  • Creates new solutions through crossover and mutation
  • Repeats until convergence
🧠 Prolog - Logic programming that'll make you question your life choices πŸ€”

Python implementations of logic programming concepts:

  • Knowledge representation
  • Rule-based systems
  • Logical inference

βš™οΈ Installation

# Clone this repository
git clone https://github.com/Jia2005/AI-codes-in-Python.git

# Navigate into the directory
cd AI-codes-in-Python

# No external dependencies required - just Python 3.6+

πŸš€ How to Run

# Run any algorithm (example with BFS/UCS)
python3 BFS_UCS.py

# Run other algorithms
python3 DFS.py
python3 DFID.py
python3 A_star.py

πŸ‘Ύ Algorithm Breakdown

Search Algorithms Visualized

BFS                          DFS
────────────                 ────────────
   [1]                          [1]
  ↙   β†˜                        ↙   β†˜
[2]     [3]                  [2]     [3]
↙ β†˜     ↙ β†˜                 ↙        ↙ β†˜
4   5   6   7               4        6   7
                            ↙
                           5
  • BFS/DFS: Think of these as different ways to explore a maze - BFS goes wide, DFS goes deep
  • A*: The overachiever that finds optimal paths while being smart about it
  • Genetic Algorithms: Digital survival of the fittest - letting solutions evolve through generations
  • Hill Climbing: Like hiking with no map - just keep going up and hope for the best

β˜• Java Version

More of a Java person? No judgment (ok maybe a little πŸ˜‰)

Java Version

🀝 Contributing

Found a bug? Have a better way to implement something? Open a pull request!

1. Fork the repository
2. Create your feature branch: git checkout -b amazing-feature
3. Commit your changes: git commit -m 'Add some amazing feature'
4. Push to the branch: git push origin amazing-feature
5. Open a pull request

If this helped you with your assignments or understanding AI concepts, a star ⭐ would be awesome.
No pressure... (but seriously, it takes like 2 seconds)

⚠️ Disclaimer

Fair warning: This is college-assignment-level code. It works, it's readable, but it's not winning any optimization awards.


Made with β˜• and 😴 deprivation

About

✨ My collection of AI code from college nights! Search algorithms, genetic stuff, and other weird computer-thinky code that actually works - all written in Python! Grab it if you're stuck on assignments! πŸ’»β˜•

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages