Git Product home page Git Product logo

elaborato_asd's Introduction

NOTES

Data

Size of the map relative to the bot is (n - 3) * (m - 3) To find cell the bot can move to by comparing every 3x3 to a 3x3 of '.' create a graph while comparing the 3x3 cells, must keep track of directions Every step has the same cost so bfs gives shortest path to destination Start is always top-left Destination is always bottom-right The graph is non-directional and every node has a maximum of 4 edges, one for every cardinal direction

Algorithm

Read input file and generate graph (every 3x3 is a node, every node has a type EMPTY or WALL, two EMPTY nodes next to each other have an edge that connects them). Bfs from source (always [0][0]), if [n-3][m-3] has distance < 0 the destination can't be reached. Populate a char array with the opposite of the direction of travel during path traversal from dest to source (recursive like print_path from bfs.c) Print distance of destination and path from source to dest.

Better Algorithm

Expand wall by moving one block and checking 3x3 with with current block as center, if there's a wall put wall in current block Do Bfs on map with expanded walls. Check distance of destination if >= 0, it can be reached. Go back by finding previous node (the one that has distance == current distance - 1).

Input files

[https://virtuale.unibo.it/mod/assign/view.php?id=800757]

elaborato_asd's People

Contributors

toriocrema avatar

Stargazers

Matteo avatar

Watchers

 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.