Giter VIP home page Giter VIP logo

ai-planning-strips's Introduction

STRIPS - Monkey PROBLEM

Description

https://en.wikipedia.org/wiki/Monkey_and_banana_problem

"""
Definition
===============================

 items = [monkey, banana, box]

 positions = [0, 1, 2]

OPERATORS
===============================

Move(subject, x1, x2)
PC: monkeyAt(x1), monkeyLevelDown
A: monkeyAt(x2)
D: monkeyAt(x1)

PushBox(x1,x2)
PC: monkeyAt(x1), boxAt(x1), monkeyLevelDown
A: monkeyAt(x2), boxAt(x2)
D: monkeyAt(x1), boxAt(x1)

ClimbBox(x, direction={Up, Down})
PC: monkeyAt(x), boxAt(x), monkeyLevelDown
A: monkeyLevelUp
E: monkeyLevelDown

HaveBanana(x)
PC: monkeyAt(x), bananaAt(x), boxAt(x), monkeyLevelUp
A: GetBananaAt(x)


INITIAL STATE - Properties
===========================

monkeyAt0, monkeyLevelDown, bananaAt1, boxAt2


GOAL STATE - Properties
===========================

GetBanana(at 1)

"""

Usage

The following code will execute the default example:

python3 strips.py

Having the following (possible) output:

Initial state:
---------
{'monkeyAt0', 'bananaAt1', 'monkeyLevelDown', 'boxAt2'}

Goal state:
---------
{'haveBanana'}

STRIPS START
==============
Apply Movemonkey(0,2) to state
Apply PushBox(2,1) to state
Apply ClimbBoxUp(at 1) to state
Apply GetBanana(at 1) to state

Done! Final plan:
[Movemonkey(0,2), PushBox(2,1), ClimbBoxUp(at 1), GetBanana(at 1)]

This is an iterative version of STRIPS with heuristic based on the usage of a stack in which either Properties or Operations are pushed defining this way the sub-goals needed to reach, in a regressive approach of the search.

User is able to change the configuration of the states directly on the src/strips.py file:

initial = State()
#Simple state
initial.setProperties({"monkeyAt0", "bananaAt1", "boxAt1", "monkeyLevelDown"})

#Lab state
initial.setProperties({"monkeyAt0", "bananaAt1", "boxAt2", "monkeyLevelDown"})

goal = State()
goal.setProperties({'haveBanana'})

Code is commented for a better comprenhension.

ai-planning-strips's People

Contributors

raulrc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.