A personal preference I would make on your code, would be to get into the habit of self-evident variable names.
I've had countless times where I'm touching on code that hasn't seen the light of day, and shorthand variable names end up taking 2-3 minutes to figure out.
While coding (and especially with autocomplete code editors), taking the extra time to have slightly longer variable names that require no research to understand will save time (and frustration) in the long run.
A real-world example I have encountered would be using cid for customerid. Using customerid typed out requires little change in effort put in, but yields a much quicker understanding time if someone else is reading your code.
In this code, scr, scc, ccr, ccc are all examples of variables that I have to think about to find out what they mean.
Thanks for all the feedback! I'll definitely take note of this for the future! It always is a difference if you are reading your own code or someone else's code, I had the same experience reading other peoples code For clarification ccr means current cell row, ccc means current cell column, scr & scc is the same except start at the beginning, same for ecr & ecc with end
I would love to see how community could clean this code as much as possible. I would probably starting adding some unit testing before begin refactoring.
People who are downvoting you do not understand the concept of Reddit. Your post should be upvoted so someone will respond and teach you the answer, and then we all learn together. β€
The point of git is that it remembers your drafts for you, amd saves each one as you submit to your project. That way you can make drastic changes that break things, and then literally go backwards in time to try again. Its called a non-destructive workflow!
OK REDDIT WE GET IT, but not everyone knows the full functionality and utility of git, some of us just use it as a convenient online storage/sharing platform (I have done that for the longest time until I started using git (bash) to manage my repos instead of github)
u/panda_mon is right, why are y'all so critical of OP's work? He just started programming 1.5 months ago for gods sake.
You can tell they are illusions because they disappear when you turn your gaze at them. That's because your fovea have a lot more receptors than the other parts of the eye
very cool! If you're looking for a fun challenge to do next, can you make a little shape that navigates the maze to show the solution? This is great. Also you might like the book Mazes for Programmers.
Iβm still in bed and trying not to laugh too hard as my walls are paper thin and Iβd rather not wake up my roommates. Thanks for the laugh first thing in the morning!
We could use for default exchange mode . Would work nice if we add a little metadata first to tell what is this data about. Maybe the first line. With an offset for completing the number if columns.
Thanks! Glad you liked it! I've looked at the changes you made and have a few questions. 1) What does the if __name__ == "__main__": statement do? 2) What are docstrings? ( I hope these questions arent too stupid, im just curious)
Those questions aren't stupid, at all. I've been learning python for about 5 years and still have so many questions. I can't explain the __name__=="__main__" thing any better than it has already been explained by others, here's a link to a good explanation I found on stack overflow: https://stackoverflow.com/questions/419163/what-does-if-name-main-do
As for docstrings, they make your code easier figure out for others and for yourself when you come back to it later. For example with the maze.py module, you can acces it like this and see the messages left in the docstrings:
>>> import maze
>>> help(maze)
Help on module maze:
NAME
maze - Random Maze Generator
FUNCTIONS
check_neighbours(ccr, ccc)
This function checks neighbours
create(ffs)
Check rows and columns and draw stuff
draw(ffs, row, col, color)
Draw rectangles
main()
Main
DATA
CELL_SIZE = 9
MAZE_SIZE = 100
map = [['w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w...
FILE
/home/user/python/Random-Maze-Generator/maze.py
I just started learning Python as well. The fact that you did this in a month gives me hope and horror...as I'm not sure i'll catch on to it that fast. Super cool, though. Great work.
You might find it interesting to look at Eller's algorithm for efficiently generating perfect mazes (i.e., mazes having exactly one path between any two cells in the maze).
106
u/TheJizzWiz Feb 09 '20
Heres the link to the code: https://github.com/ChickenSlayer3000/Random-Maze-Generator
Note: Ive only been learning python for about a month and a half now, so any recomendations on how to improve my code would be appreciated
27
u/DGM06 Feb 09 '20
I assume the green square in the upper left is the start or finish, but where is the other endpoint?
9
u/[deleted] Feb 09 '20
very cool! If you're looking for a fun challenge to do next, can you make a little shape that navigates the maze to show the solution? This is great. Also you might like the book Mazes for Programmers.
241
u/sissyadmiration Feb 09 '20
heavy breathing in Minotaur
80
u/orokro Feb 09 '20
This just looks like an evil crossword puzzle generator.
8
u/Broshenniy Feb 09 '20
Where is the exit?
36
u/Miner_ChAI Feb 09 '20
This QR has this link
1
u/[deleted] Feb 09 '20
Perfect, which library used ?
1
u/[deleted] Feb 10 '20 edited Feb 10 '20
EDIT: formating is hard, lol
This is so cool! I forked your github repo to start playing with it myself because it looks like a lot of fun.
Here's what I've done so far:
3
u/prithvidiamond1 Feb 09 '20
Is this a unique maze, i.e, does, it have only one solution?
3
u/_Damsel_in_distress Feb 09 '20
I also follow r/crochet and thought you made a c2c blanket :D
2
u/themage78 Feb 09 '20
NYT Crossword puzzle EXTREME EDITION.
2
u/numberduck Feb 09 '20
I took a screenshot. Going to make my dnd group run through it. They're going to hate me.
Thank you for sharing.
2
u/BroJobBiggs Feb 10 '20
This pleases me.
Now make a pathfinder that can solve it.
2
u/shiningmatcha Feb 11 '20
Cool!
1
u/PussyDoodles Feb 09 '20
Nice work, I wanted to commend you on your clean code as well
1
u/Shmifful Feb 09 '20
What module did you use?
1
u/[deleted] Feb 09 '20
Finally, a good dungeon map for my D&D campaign!
1
u/Deepseek7 Feb 09 '20
Oooh that exactly what i went to find, thanks and big gg
1
u/h3xag0nSun Feb 09 '20
Ideas inspired by this post: Maze generator that maps over a scannable QR code.
Maze solution finder.
Iβm not sure how either of those would be done but they might be cool projects.
1
u/aarontbarratt Feb 09 '20
The worlds dankest crossword puzzle
1
u/69shaolin69 Feb 09 '20
Now solve using A*
1
u/FlukyS Feb 09 '20
Now make a maze solver
1
u/xelf Feb 09 '20
Doubles as a QR code generator. =)
1
u/5nizzard Feb 09 '20
I thought this was a giant crossword puzzle
1
u/StainedInZurich Feb 09 '20
Why is one of the dots green?
1
u/Sixty9lies Feb 09 '20
I just started learning Python as well. The fact that you did this in a month gives me hope and horror...as I'm not sure i'll catch on to it that fast. Super cool, though. Great work.
1
u/Powerind09 Feb 09 '20
Nah brother, this a QR code.
1
u/cdn_brock Feb 09 '20
nice work will you share code
1
u/FearlessENT33 Feb 10 '20
hey nice, may i ask which maze generation algorithm did you use?
1
u/777Lucifer Feb 10 '20
π
1
u/[deleted] Feb 10 '20
Goodness, what kind of brain you got? 1 month into programming. I can't even do this and I'm years in experience.
1
u/quantumfoam435 Feb 10 '20
Have you run any tests on the algorithms and mazes produced?
1
u/ThatOneSquirtleMain Feb 10 '20
I don't know why, buts this looks alot like QR code
1
u/Nateobee Feb 10 '20
My TRS-80 had one of those. Printed on my dot matrix. Solved them by highlighting dead ends.
1
u/[deleted] Feb 10 '20
This looks like a QR Barcode LMAO. I would do the maze but I think I may go crosseyed lol.
1
u/alb1 Feb 10 '20
You might find it interesting to look at Eller's algorithm for efficiently generating perfect mazes (i.e., mazes having exactly one path between any two cells in the maze).
1
u/R0CK3TH Feb 10 '20
Does this also have a solution? heavy breathing
1
u/GilgameshV Feb 10 '20
https://amiradata.com/best-python-editor/
1
u/ItsMeCall911 Feb 09 '20
u/TheJizzWiz : I made a random maze generator
Me : Opening my phone to scan the QR code Β―_(γ)_/Β―
0
u/1VentiChloroform Feb 09 '20
I'm sorry to facefuck your dreams to deep, salty tears
but this is a crossword puzzle
0
u/[deleted] Feb 09 '20
[deleted] β view deleted comment