Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl for hobbyists

by redgreen (Priest)
on Oct 10, 2009 at 03:45 UTC ( #800407=note: print w/ replies, xml ) Need Help??


in reply to Perl for hobbyists

Mazes. Mazes for my wife and I. Instead of trying to port some of my old MS-DOS C code to linux, I found Games::Maze.

I was excited, until I found how simple and predictable the mazes were. It seems that once it is boxed in, it backtracks the way it came. Making a simple change fixes that:

# Right here is where things get predictable! Mix it up. # ($c, $r, $l) = splice @queue, 0, 3; ($c, $r, $l) = splice @queue, (rand(@queue / 3) *3), 3;

Yes, my code uses more memory, but the mazes are more challenging. I guess 'more memory' is all relative, I remember how many hoops I had to jump through to use more then 64k of data in MS-DOS.

I have code that takes the Games::Maze square data and creates a png file.

Now if I could only find a good way to represent the maze, and have the output span a few dozen pages.


Comment on Re: Perl for hobbyists
Download Code
Replies are listed 'Best First'.
Re^2: Perl for hobbyists
by ambrus (Abbot) on Oct 10, 2009 at 11:27 UTC
Re^2: Perl for hobbyists
by moritz (Cardinal) on Oct 11, 2009 at 20:23 UTC

      Wow, nice article. I didn't care about the speed problem because when I wrote my program, computers were fast enough. I only wrote the fast algorithm eight years later in the perl rewrite. Otoh, I think my program generates better (more interesting) mazes.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://800407]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (17)
As of 2015-07-29 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls