Skip to main content

An implementation of AI algorithms based on aima-python

Project description

Simple AI
=========

(Project home: http://github.com/fisadev/simpleai)

This packages is based and inspired in aima-python:
https://code.google.com/p/aima-python/

We implement most of the searches in aima-python plus some extra options. Besides, we make
some improvements in terms of code readability, installation, testing, and others.

Installation
============

Just get it:

pip install simpleai


Examples
========

Simple AI allows you to define problems and look for the solution with
different strategies. Another samples are in the *samples* directory, but
here is an easy one.

This problem tries to create the string "HELLO WORLD" using the A* algorithm:


from simpleai.models import Problem
from simpleai.search import astar

GOAL = 'HELLO WORLD'

class HelloProblem(Problem):
def actions(self, state):
if len(state) < len(GOAL):
return [c for c in ' ABCDEFGHIJKLMNOPQRSTUVWXYZ']
else:
return []

def result(self, state, action):
return state + action

def is_goal(self, state):
return state == GOAL

def heuristic(self, state):
# how far are we from the goal?
wrong = sum([1 if state[i] != GOAL[i] else 0
for i in range(len(state))])
missing = len(GOAL) - len(state)
return wrong + missing


problem = HelloProblem(initial_state='')
result = astar(problem)

print result.state
print result.path()

Authors
=======

* Juan Pedro Fisanotti <fisadev@gmail.com>
* Rafael Carrascosa <rcarrascosa@machinalis.com>
* Santiago Romero <sromero@machinalis.com>

Special acknowledgements to Machinalis (http://www.machinalis.com/) for the
time provided to work on this project.

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

simpleai-0.2.1.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file simpleai-0.2.1.tar.gz.

File metadata

  • Download URL: simpleai-0.2.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for simpleai-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3af8fcb8c1856c3ae5e2fd9a0243593a20259c4bce94b6d14f21ac5013cb8a8f
MD5 7aa0f7c0fa4358fb0b9a2269b7e15e37
BLAKE2b-256 f798ac46b3a61597736b72d274cb7166d247c6f67fa6bb2b5552d796bde26302

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