Skip to content

Latest commit

 

History

History
96 lines (76 loc) · 2.05 KB

README.md

File metadata and controls

96 lines (76 loc) · 2.05 KB

DoYouWantToCmyAlgorithms?

Collection of some algorithms implemented in C.
Goal is high performance.

Implemented Algorithms:

  • Maze Generator (Recursive Backtracking)
  • Maze Solver

Maze generator:

Build

git clone https://github.com/itssme/DoYouWantToCmyAlgorithms_
cd DoYouWantToCmyAlgorithms_/mazeGeneration
mkdir build
cd build
cmake ..
make

Example

Go to the build directory and run:

>> ./generator 10 10

Will 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 seconds

Maze solver:

This algorithm will solve a maze generated by the maze generator.

Build

git clone https://github.com/itssme/DoYouWantToCmyAlgorithms_
cd DoYouWantToCmyAlgorithms_/mazeSolver
mkdir build
cd build
cmake ..
make

Example

After generating a maze like ./generator 20 20 > maze.txt with the generator, go to the build directory and run:

>> ./solver 20 20 < maze.txt

to 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