Giter Site home page Giter Site logo

cankobanz / vacuum-cleaner-robot Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 105 KB

Robot that cleans room from dirts. Finds the optimum path eventually. Same algorithms are applied as in finding path to escape a maze.

Python 100.00%
a-star a-star-algorithm a-star-path-finding a-star-search ai artificial-intelligence bfs bfs-algorithm bfs-search breadth-first-search

vacuum-cleaner-robot's Introduction

vacuum-cleaner-robot

Robot that cleans room from dirts. Finds the optimum path eventually. Same algorithms are applied as in finding path to escape a maze. This project was the first homework of Artificial Intelligence course I have taken.

TO RUN THE CODE

python cleaner_robot.py <search-type> <input_file>  

where can be DFS, BFS, UCS, GS, A1 or A2

Example Running Code:

python cleaner_robot.py BFS init1.txt

In this project, the cleaner robot cleans the room by finding its path using various algorithms:

  • DFS: Depth First Search
  • BFS: Breadth First Search
  • UCS: Uniform-Cost Search
  • GS: Greedy Search that uses the Manhattan Distance to the closest dirt as the heuristics function.
  • A1: A Search with Manhattan Distance to the closest dirt as the heuristics function.
  • A2: A Search with heuristic that is explained in project report file.

Input files look like this:
image

where:
c is the agent(cleaner),
x represents walls,
represents dirts,
j is the jumper which moves the agent that moves an incoming agent to the next grid. If the corresponding grid is occupied with an obstacle, the location of the agent will not change at all. There are no jumpers placed next to each other.

The vacuum cleaner has five actions:

  • left, right, up, down moves the cleaner one grid, unless that grid is an obstacle.
  • suck action that sucks one dirt. (in order to clean n dirts in a grid, suck action should be executed n times)

Costs of the actions:

  • Left and right: 1
  • Up and down: 2
  • Suck: 5
  • Cost of actions are as above, even though those actions do not change the state of the agent.

Tie-breaker:

  • Tie situations might occur during inserting into the fringe. The precedence used for fringe insertion tie-breaker is as follows: suck, left, right, down, up
  • For DFS and BFS, how to remove the nodes from the fringe is well-defined.
  • For others, if costs/g-values/f-values are same, respect the insertion order (first-in first-out).

In the output, map is cleaned from dirts as:
image

Reporting:

  • the number of expanded nodes
  • the action sequence to achieve the goal
  • the cost of the solution
  • the heuristic function value of the initial state if the is A*2.

Example Output:
python robot_cleaner.py BFS init1.txt
number of expanded nodes: 28
path: right down right right suck suck right suck
cost of the solution: 21

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.