jmerc77 / remix-of-Russian-Doll-Maze-Puzzle-Box

generator for thingiverse thing 2980535
Other
2 stars 3 forks source link

improvements and cleanups #2

Closed dek3rr closed 5 years ago

dek3rr commented 5 years ago

Thank you so much for making this all work! I just wanted to offer some cleanups and make it easier for others to use.

-improved version checking for OpenSCAD -use numpy definition of pi -consolidate code used in maze file generation -use "with" statement to handle file open/close -better parsing of opt.txt so it can be modified and run directly with comments

ex-nerd commented 5 years ago

I should have checked for an existing PR before doing a bunch of similar work on my own. I think I'll incorporate your ideas before submitting my larger set of changes (if nothing else, my choice to run everything throughblack to clean up the code means the diffs have diverged a bunch): https://github.com/ex-nerd/remix-of-Russian-Doll-Maze-Puzzle-Box

jmerc77 commented 5 years ago

White spacing in make_shells.scad could also use some work. Is there a good tool for that?

ex-nerd commented 5 years ago

@jmerc77 There's already a rd.seed() on line 253. Honestly, there should only need to be one call into rd.seed() in the whole file -- resetting it risks ending up with less random. The only reason I can think of to reset the seed is in a multithreaded environment where you want to make sure that the different threads each have their own random seed (looks like you had some earlier code that tried this?). The alternative would be to use os.urandom() but that's probably overkill for this case. You also don't need to provide any additional parameters to rd.seed() because it defaults to using the system time.

jmerc77 commented 5 years ago

OK. in that case just have the seed once at the start and not in the loop.

ex-nerd commented 5 years ago

@jmerc77 yeah. Give me a couple hours and I'll submit a PR that has my own fixes along with the ones from @dekerr.