Git Product home page Git Product logo

ofelia's Introduction

Ofelia

Ofelia, title

A python script to generate not mazes, but look-alikes. The idea came from my daughter, the code from me. It's a very early code, with 1-hour work total. It still needs to be optimized, improved, enhanced. And we got ideas.

The name comes from the movie The Pan's Labyrinth. The main character is named Ofelia. Also, I like recursive acronyms, so it stands for Ofelia Fabrique d'Étonnants Labyrinthes et d'Incroyables Architectures, which is french (cause I'm french). It could translates to Ofelia makes stunning labyrinths and incredible architectures (which is not a recursive acronym anymore).

An image generated by ofelia

This is what Ofelia can generate. And I'll explain soon what are the rules/behaviour.

How to use

Right now, the code is kinda as is, and I plan to work on making it more user friendly (so my daughter can more easily play with it). You can look at the two generators.

You can also get to see some examples.

Console generation

Open the testConsole.py script. There, you can change the size of the maze you generate, and state the starting points. Then, you display it. The colored argument is there as a test to colorize the output (but it's kind of meh).

displayCharPath(maze, colored=True)

It generates something like this :

a a g e e e a a a c
e e e e e e k m n c
b b h j e e k k c c
b b h j h h h h c c
b b h h h i i i c c
b b i i i i l l c c
b b f f d d d d d o
b f f f d d d d d p
b f f f d d d d d d

Image generation

Open the test_generation.py script. As noted in the file, it uses the PIL image generation library. You need it to run it.

You'll find three fillings of the colors table. Only the last one is used (previous were tests with my daughter). This is one the stuff I need to improve. But, for your own tests, fill that table with the colors you want for your image.

colors = colMg.colorManager(colors=colMg._PASTELS_PALETTE)

xMax = 100
yMax = 100
maze = plane.mazePlane(xMax, yMax)
maze.add_path((0, 0))
maze.add_path((0, yMax - 1))
maze.add_path((xMax - 1, 0))
maze.generate()

print("maze parameters OK")
print("starting to draw it")
vis.draw_maze(maze, image_filename='./generated/simple.png', colors=colors)
print("png done")

This is the generation code : setting the size, the starting points, then building the maze (cost sensitive with those parameters), and drawing it. A jpg file is generated. Voilà!

20x20, with neon colors

Want to see how the maze is constructed?

ofelia's People

Contributors

gulix avatar

Stargazers

 avatar  avatar Bruno Bord avatar

Watchers

 avatar

ofelia's Issues

Add textures

Generation of the image applying textures on post process

More "organic" path

Why not use something like the python logo ? Round angle, head for the path.

Keep some areas "not passable"

In order to decorate drawings, logo or else, we have to be able to set some "positions" as not available from the start.

Set path behaviour

Set how the path is generated (full random, likeness to change direction...)

Loops and branches

The paths are "one-way" only.
What about branches? A path separating in two branches at some point ?
What about loops, with path getting back on itself ?

SVG generation

Adding a visualizer/generator that makes a SVG file of the paths

Stats and logs

Having some logs in generation (time to generate, loops...)
Also, getting some stats about a plane : number of paths, length, ...

Other structures of path

Bring about new structures : hexagons, square but with 8 exit points (diagonals).
Obviously, any visualizer would need to decide if it can (or not) run a type of structures or not.

Code organization

Working on a better project organization, by following guidelines.

Add tag to the paths

In order to make future operations, tags will be added to path : group by tag (from the same origin ? with the same rules ?), by "age"

Make the mask feature a permanent one

Currently, the mask feature is a "applied-once" feature. It cannot be replayed, it cannot be played with (like, for example, inverted).
It could be good to have a dedicated class.

Seeding the random

Right now, the random part of the maze generation is totally random.

It could be good to add a "seed function", optional, that could be used to (re)generate multiple times the same pattern.

Gif Generation - Add steps displayed

Right now, the gif generation replays the construction "step by step".

It could be useful to speed up (and limit the number frames, which can break the process) by skipping some steps (2by2, 4by4...) on large images.

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.