samedi 25 juillet 2015

Creating A Text Based Maze Generator In Python

I am a beginner in coding in general, but I know my way around the basics. as a challenge, and possibly a tool for map generation, I wanted to see if I could use python to create a small text based 5x5 maze generator that is isolated (no exits or entrances) that allows both loops and dead ends. I hand drew one as an example:

┌ → ↑ ┌ ┐

├ ─ ┴ ┼ ┤

│ ┌ ┬ ┘ │

├ ┘ │ ← ┤

↓ ← ┴ ─ ┘

(arrows represent dead ends coming from the opposite direction of the arrow)

I was unable to make much progress, and gave up rather quickly, deciding that my coding knowledge was not at the level to create something this complex. now I want to know if there is a simple way to do such a thing. after going down a rabbit hole of spanning trees, visual codes, and the such, 95% of which I barely understood, I couldn't find much to help me. I'm looking for a (hopefully) easy to understand way of creating a piece of code that could achieve this. Ideally I want the answer to be in python, and be something relatively easy to understand for a beginner-medium programmer given enough time. Also, please excuse any horribly vague/overly-complicated parts of this question I have written, they would most likely be due to the fact that I don't know much about this area of coding.

if there is a simpler way to phrase this question, or significantly easier methods of creating a 5x5 maze other than making it text based, these are also very welcome :)




Aucun commentaire:

Enregistrer un commentaire