Git Product home page Git Product logo

mouse-in-maze's Introduction

Mouse in a Maze 老鼠走迷宮

Time:2017 年 11 月
Language:C++

Algorithm

This algorithm is aiming finding the path to the exit. Moreover, the road which was passed before will not be passed again. Therefore, this algorithm can find the exit in the end.

此演算法的規則是會記錄走過的路,並且不會再次走死胡同的路,如果遇到死路則會回頭找還沒走過的路當路徑

Program

parameters

route_x / route_y (type:stack) : store route the mouse had passed

current_x / current_y : store the current position

step_found : every round whether the current position find the possible exit

found : whether the mouse find the exit

process

Firstly, we read the input data and find the started position and ended position. Next,we try every posibble direction then push it into the stack(route). Every time we find the posibble direction, allowing the current position '*'. If there is no posibble direction can pass :

  • step==2 : return the started position
    there is no route for the maze, break out the for loop

  • step!=2 : just go back the previous step
    current position='1'(block) ,pop the top data and then continue search the possible direction

In the end, if found==true ,then print out the result.

mouse-in-maze's People

Contributors

hsiaoping-zhang avatar

Stargazers

 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.