Collection of some algorithms implemented in C.
Goal is high performance.
Implemented Algorithms:
- Maze Generator (Recursive Backtracking)
- Maze Solver
git clone https://github.com/itssme/DoYouWantToCmyAlgorithms_
cd DoYouWantToCmyAlgorithms_/mazeGeneration
mkdir build
cd build
cmake ..
makeGo to the build directory and run:
>> ./generator 10 10Will create a 10 by 10 field Maze and print:
###########
#...#.....#
###.# ###.#
#.#...#...#
#.#####.###
#.#...#...#
#.#.#.###.#
#...#.#...#
#.###.#.###
#...#.....#
###########For bigger mazes pipe output into a file:
>> ./generator 10000000 50 > maze.txt If the definition BENCH is set at compile time, additional output with the time will be printed.
Look at the output like:
>> tail maze.txt
#.#.#.#.###.#.#.#.#.#.#.#.#.###.#.#.#############.#
#.#.#.#.#...#.#.#.#...#.#.#.#.....#.............#.#
###.#.#.#.#.#.#.#.#####.#.#.#####.#############.#.#
#...#.#.#.#.#.#.#.....#.#.#.#...#.#.....#...#...#.#
#.#.###.#.###.#.#####.#.#.#.#.#.###.###.#.#.#.###.#
#.#.#...#...#...#...#.#.#.#.#.#.#...#.#...#.#.#...#
#.###.#####.#####.#.###.#.#.#.#.#.###.#####.#.#.#.#
#.................#.....#.#...#...........#.....#.#
###################################################
generated (10000000x50) maze in 6.848794 secondsThis algorithm will solve a maze generated by the maze generator.
git clone https://github.com/itssme/DoYouWantToCmyAlgorithms_
cd DoYouWantToCmyAlgorithms_/mazeSolver
mkdir build
cd build
cmake ..
makeAfter generating a maze like ./generator 20 20 > maze.txt with the generator, go to the build directory and run:
>> ./solver 20 20 < maze.txtto solve the maze. This will use ansi colors to print the maze, so make sure to use a terminal which supports those.
It is also possible to pipe the output to a text file and look at the result late:
>> ./solver 20 20 < maze.txt > solved.txt
>> cat solved.txt