Coder Social home page Coder Social logo

mazes-c's Introduction

A collection of tools for making and messing with mazes

Briefly

./grid --width=10 --height=10 | ./maze --algorithm=backtracker | ./print

Mazes-c are a collections of tools that you can use to make and render mazes. They're inspired by Jamis Buck's great book "Mazes for Programmers" but are tailored to making stuff that I like to look at.

The tools

  • grid - produces a "maze" where all paths are open. You can use grid as the first step in a pipeline that makes mazes. The resulting maze is printed to stdout in a format that is similar to, and vaguely compatible with, the graphviz dot format. You shouldn't have to interact with this format directly - to see the grid, use the print tool.
$ ./grid --width=20 --height=5 | ./print

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|                                                           |
+  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +
|                                                           |
+  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +
|                                                           |
+  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +
|                                                           |
+  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +
|                                                           |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  • maze - takes the format produced by grid and produces a maze by removing edges. Reads from stdin and writes to stdout.
$ ./grid --width=20 --height=5 | ./maze | ./print

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|     |           |        |        |        |              |
+  +  +  +  +--+--+  +  +--+  +  +  +  +  +--+  +--+--+--+  +
|  |  |  |           |        |  |  |  |     |     |        |
+  +--+  +--+--+  +--+--+--+--+  +  +  +--+  +--+  +  +--+  +
|        |     |           |  |  |  |     |  |     |     |  |
+  +--+--+--+  +--+--+--+  +  +  +--+--+  +  +  +--+--+  +  +
|  |        |  |              |           |     |     |  |  |
+  +  +--+  +  +--+--+--+--+--+--+--+--+--+--+--+  +  +  +  +
|     |     |                                      |     |  |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  • print - takes a maze on stdin and renders it as ascii art to stdout.

  • png - takes a maze on stdin and writes a png to stdout.

  • scad - takes a maze on stdin and writes an openscad script to stdout.

There are some other little maze toys included with the software as well. Refer to the usage messages of the programs for more detailed help.

  • assemble translates a list of three dimensional coordinates into a format that ./maze and friends can use, allowing you to create shaped mazes.

  • color - takes a maze on stdin and produces an annotated maze on stdout with added "color" attributes, that png or scad can use during rendering.

  • gravity takes a maze as input and attempts to add edges so it will print more easily on a 3D printer.

  • paths reads a maze in the common, dot-ish format, and produces JSON that can be used to reconstruct the maze.

You can also run a (toy, insecure) server using server.sh, and run that server in a Docker image using the included Dockerfile.

Building the tools

Building mazes-c requires graphviz's cgraph headers and library, and cairo. The tests require glib-2.0. I build on Ubuntu, with libcairo2-dev and libgraphviz-dev, using gcc.

To build, I just run

make

To run the (not really actual) tests, run

make run-tests

A more detailed description of the requirements to build the system can be inferred from the Dockerfile included with this project. You can build the dockerfile (which includes the very silly, certainly insecure maze service) you can run.

make container

mazes-c's People

Contributors

joeatwork avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mazes-c's Issues

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.