Skip to main content

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 problem
  • tsp_genetic: Genetic algorithm for Traveling Salesman Problem
  • logic_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bosskamagic-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bosskamagic-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file bosskamagic-0.1.0.tar.gz.

File metadata

  • Download URL: bosskamagic-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for bosskamagic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 638e62b2614a09a5861230a3981ed60046b57dd8b7ae7823cbfe957a44c96b69
MD5 3967fb4754d258d3ab780ba643ec7e36
BLAKE2b-256 7a07ea3067a60afd89d4e9ef6da89325d5b62c607ba81355a5abe57145099185

See more details on using hashes here.

File details

Details for the file bosskamagic-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bosskamagic-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

Hashes for bosskamagic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 832a6e083777c6b679c5627c353e58d814a92130e46b3b020149c7a9102f7708
MD5 dea260ecbda59eab6cc526b61a1f29e1
BLAKE2b-256 5aa5850d3fa2c55f652257d8737ab89fed3ee626a5d3c3ddc32e1865ea026a8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page