AI algorithms collection: Genetic algorithms for 8-Queens and TSP, plus propositional logic and Bayes theorem implementations
Project description
BossKaMagic
A comprehensive Python package containing AI algorithm implementations including genetic algorithms, propositional logic solvers, and Bayes theorem applications.
Features
🧬 Genetic Algorithms
- 8-Queens Problem Solver: Genetic algorithm implementation to solve the classic 8-Queens puzzle
- Traveling Salesman Problem (TSP): Genetic algorithm for finding optimal routes
🧠 Logic & Probability
- Propositional Logic: Complete logical operators (AND, OR, NOT, IMPLIES, BICONDITIONAL) with truth tables
- Logic Solver: Truth table generation, resolution theorem proving, and DPLL satisfiability checking
- Bayes Theorem: Conditional probability calculations and medical diagnosis examples
- Naive Bayes Classifier: Simple implementation for classification tasks
Installation
pip install bosskamagic
Quick Start
Genetic Algorithm - 8 Queens
from bosskamagic.eight_queens_genetic import SimpleQueensGA
# Solve 8-Queens problem
solver = SimpleQueensGA()
solution = solver.solve()
print(f"Solution found: {solution}")
Genetic Algorithm - TSP
from bosskamagic.tsp_genetic import City, SimpleTSPGA
# Create cities
cities = [
City("A", 0, 0),
City("B", 1, 2),
City("C", 3, 1),
City("D", 2, 3)
]
# Solve TSP
tsp_solver = SimpleTSPGA(cities)
best_tour, best_distance = tsp_solver.solve()
print(f"Best distance: {best_distance}")
Logical Operators
from bosskamagic.logic_and_bayes import LogicalOperators
# Use logical operators
result = LogicalOperators.AND(True, False)
print(f"True AND False = {result}")
# Print truth tables
LogicalOperators.print_truth_table_basic()
Bayes Theorem
from bosskamagic.logic_and_bayes import BayesTheorem
# Calculate conditional probability
prob = BayesTheorem.conditional_probability(0.8, 0.1, 0.05)
print(f"Posterior probability: {prob}")
# Run medical diagnosis example
BayesTheorem.medical_diagnosis_example()
Modules
eight_queens_genetic: Genetic algorithm for 8-Queens problemtsp_genetic: Genetic algorithm for Traveling Salesman Problemlogic_and_bayes: Propositional logic and Bayes theorem implementations
Requirements
- Python >= 3.7
- random2 >= 1.0.1
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Your Name - your.email@example.com
Keywords
genetic-algorithm, artificial-intelligence, 8-queens, tsp, traveling-salesman, propositional-logic, bayes-theorem, machine-learning
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sagemagic-0.1.0.tar.gz.
File metadata
- Download URL: sagemagic-0.1.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b963437e1a71a25e9604e8f64fd7ebd99dc9ea621c6eedef1038639375bdf18
|
|
| MD5 |
f33248978b9a8c78ef940892c00309bb
|
|
| BLAKE2b-256 |
217a5d4e7543fc0aa2254eb20031230d47b9ad3bf3e522d909ffb5fcca15fc7a
|
File details
Details for the file sagemagic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sagemagic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ef6ce62b5fc7e74f2f41e77c3474e6025fbdc803e2585f9e254d92bba9b4415
|
|
| MD5 |
dd3fa70168871d8d14894d3ed5dcb64e
|
|
| BLAKE2b-256 |
96cadab1270808eab91107f8d18e476c273de168c98c960aa80779443596277e
|