john-science / mazelib

A Python library for creating and solving mazes.
MIT License
239 stars 55 forks source link

Fix MazeArray #11

Closed john-science closed 10 years ago

john-science commented 10 years ago

I used my old Array2D class to store the maze data. This was cute, but not useful here.

The bulk of the work done by these maze algorithms is in getting/setting an element in the maze based on position. This means what I really want is a fast way to get/set elements by index.

A simple 2D list would be MUCH faster here.

And after working with these mazes for a while I believe speed is more important than size in memory.

john-science commented 10 years ago

Perhaps I could have two different MazeArrays... one that tries to conserve space in memory and one that tries to conserve run time.

john-science commented 10 years ago

I need to re-run my speed/memory tests with the a list-based maze array, vs the old array-based. Might as well throw in a NumPy array-based approach as well.

john-science commented 10 years ago

Ha! Success!

My array.array-based MazeArray class is actually much faster than any other standard implementation I can find using list or NumPy.array.

And my solution takes up far less memory than a list solution and somewhat less memory than a NumPy.array solution.