Code Monkey home page Code Monkey logo

awk-maze-generator's Introduction

The AWK scripts to generate maze

The repository contains AWK scripts to generate a random maze and find a path in the maze.

Generate a random maze

To generate a maze, you can use one of two scripts: maze-gen-one.awk or maze-gen-two.awk. These two scripts work the same but use completely different algorithms to generate the maze. Both scripts have two mandatory parameters - the number of rows (Rows) and columns (Cols) in the maze. You can also specify an optional Seed parameter.

Every time you run the script, you will receive a random maze.

gawk -f maze-gen-two.awk -v Rows=8 -v Cols=36 

However, if you specify optional Seed variables, you will get the same maze every time you run the script with a specific Seed value.

gawk -f maze-gen-two.awk -v Rows=8 -v Cols=36 -v Seed=42 

Sample output

Maze Sample

Make scripts executable

You can set the execution flag for scripts.

chmod +x maze-gen-two.awk

This will allow you to run scripts directly without specifying an interpreter.

./maze-gen-two.awk -v Rows=8 -v Cols=36

Save the maze

./maze-gen-two.awk -v Rows=8 -v Cols=36 Seed=42 > docs/sample.maze

Test generated maze

You can run the test script to check the correctness of the maze generator.

gawk -f maze-test.awk -v Rows=18 -v Cols=76 docs/sample.maze

Find the path

gawk -f maze-runner.awk sample.maze

Sample output of path

Maze Path

ASCII version of maze generator

In case pseudographic characters are not supported on your computer, there is a version for generating a maze using only asc characters.

gawk -f maze-gen-asc.awk -v Rows=9 -v Cols=21

Sample output

➜  awk-maze-generator git:(release/5) ✗ gawk -f maze-gen-asc.awk -v Rows=9 -v Cols=21
######################################################################################
##          ##              ##          ##                          ##              ##
##  ######  ##  ##########  ######  ##  ##  ##############  ######  ##  ##  ######  ##
##  ##          ##      ##      ##  ##  ##      ##      ##      ##  ##  ##      ##  ##
##  ##  ##########  ##  ######  ######  ######  ##  ##########  ######  ######  ##  ##
##  ##  ##          ##  ##  ##      ##      ##  ##          ##          ##      ##  ##
##  ######  ##########  ##  ######  ##  ##  ##  ######  ##  ##############  ######  ##
##      ##  ##  ##      ##      ##  ##  ##  ##      ##  ##              ##      ##  ##
##  ##  ##  ##  ##  ######  ##  ##  ##  ##  ######  ##  ##############  ######  ##  ##
##  ##          ##  ##  ##  ##  ##  ##  ##      ##  ##          ##      ##      ##  ##
##  ##############  ##  ##  ##  ##  ##  ##########  ##############  ##  ##  ######  ##
##  ##              ##      ##          ##      ##      ##          ##  ##  ##  ##  ##
##  ##  ##  ##########  ##################  ##  ######  ##  ######  ######  ##  ##  ##
##  ##  ##  ##      ##  ##                  ##  ##      ##  ##      ##      ##        
##  ##  ######  ##  ######  ##################  ##  ######  ######  ##  ##############
    ##      ##  ##          ##      ##          ##      ##      ##  ##  ##          ##
##  ######  ##  ##############  ##  ##  ##############  ######  ##  ##  ##  ######  ##
##      ##                      ##  ##                          ##  ##          ##  ##
######################################################################################
➜  awk-maze-generator git:(release/5) ✗  

awk-maze-generator's People

Contributors

rabestro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

awk-maze-generator's Issues

Tests for maze generator

To contribute an exercise for the site Exercism.io, an acceptance test for the labyrinth generation script must be written.

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.