Code Monkey home page Code Monkey logo

pydaedalus's Introduction

pydaedalus

image

image

Latest Version

Daedalus source code is copyright (c) 1998-2016 Walter D. Pullen.

Wrapper is copyright (c) 2017 Will Roberts <[email protected]>.

Licensed under the GNU General Public License version 2.

A Python wrapper of the Daedalus maze generator. This project is currently built against version 3.2 of the Daedalus software.

Quickstart

Install:

pip install pydaedalus

Getting started:

>>> from daedalus import Maze
>>> maze = Maze(63, 63)
>>> maze.create_perfect()
>>> maze.resize(31, 61)
>>> maze.create_perfect()
>>> maze.save_bitmap('test.bmp')
>>> maze.save_text('test.txt')

A Maze can be treated as a 2D array of Bools (walls are True and passages are False), or as a container of lists of ints (walls are 1 and passages are 0):

>>> maze.width, maze.height
(31, 61)
>>> maze[0,0]
True
>>> maze[1,1]
False
>>> maze[1,2]
False
>>> maze[1,3]
False
>>> maze[1]
[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1]
>>> len(maze)
61

Take a look at demo.ipynb to see visualisations of some of the kinds of Mazes Daedalus can create.

Requirements

  • Python 2.7, or 3.3+,
  • A C++ compiler with C++11 support (GCC 4.7+, clang 3.3+).

Development Notes

To compile the Cython extension:

python setup.py build_ext --inplace

pydaedalus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pydaedalus's Issues

"Getting Started" code gives error

Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license()" for more information.
>>> from daedalus import Maze
>>> maze = Maze(63, 63)
>>> maze.create_perfect()
>>> maze.resize(31, 61)
>>> maze.create_perfect()
>>> maze.save_bitmap('test.bmp')
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
maze.save_bitmap('test.bmp')
File "daedalus/_maze.pyx", line 1626, in daedalus._maze.Maze.save_bitmap (daedalus/_maze.cpp:9643)
TypeError: expected bytes, str found
>>> maze.save_text('test.txt')
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
maze.save_text('test.txt')
File "daedalus/_maze.pyx", line 1646, in daedalus._maze.Maze.save_text (daedalus/_maze.cpp:9843)
TypeError: expected bytes, str found
>>>

Installation is broken via pip

It was recommended by pip that I install using this command: python -m pip install --use-pep517 pydaedalus
This did not correct major errors I am having on install.
Currently the wheel is not building.

This is the command and output:

PS D:\Commerce\A&XB_Designs\PROJECTS\IMPOSSIBLE_MAZE_BOOK_1> python -m pip install --use-pep517 pydaedalus
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
Collecting pydaedalus
  Using cached pydaedalus-0.1.5.tar.gz (400 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pydaedalus
  Building wheel for pydaedalus (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pydaedalus (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-310
      creating build\lib.win-amd64-cpython-310\daedalus
      copying daedalus\compat.py -> build\lib.win-amd64-cpython-310\daedalus
      copying daedalus\__init__.py -> build\lib.win-amd64-cpython-310\daedalus
      creating build\lib.win-amd64-cpython-310\daedalus\test
      copying daedalus\test\test_maze.py -> build\lib.win-amd64-cpython-310\daedalus\test
      copying daedalus\test\__init__.py -> build\lib.win-amd64-cpython-310\daedalus\test
      running build_ext
      building 'daedalus._maze' extension
      creating build\temp.win-amd64-cpython-310
      creating build\temp.win-amd64-cpython-310\Release
      creating build\temp.win-amd64-cpython-310\Release\daedalus
      creating build\temp.win-amd64-cpython-310\Release\daedalus\src
      "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Idaedalus/src -IC:\Python310\include -IC:\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019
\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Fil
es (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /EHsc /Tpdaedalus/_maze.cpp /Fobuild\temp.win-amd64-cpython-310\Release\daedalus/_maze.obj -std=c++11 -Wno-error=format-security
      cl : Command line error D8021 : invalid numeric argument '/Wno-error=format-security'
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pydaedalus
Failed to build pydaedalus
ERROR: Could not build wheels for pydaedalus, which is required to install pyproject.toml-based projects
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)

Windows necessary?

(apologies if this isn't the appropriate place to ask questions, but I don't know another place)

After "pip install pydaedalus" under Anaconda Python 2.7.13 on Mac, I get

ImportError                               Traceback (most recent call last)
<ipython-input-1-526a22e210bd> in <module>()
      2 import matplotlib.pyplot as plt
      3 import numpy as np
----> 4 from daedalus import Maze

/Users/bbeckman/Documents/pydaedalus/daedalus/__init__.py in <module>()
     25     __version__ = "unknown (%s)" % ex
     26 
---> 27 from ._maze import (Maze,
     28                     COLOR_WHITE, COLOR_BLACK,
     29                     ENTRANCE_CORNER, ENTRANCE_MIDDLE, ENTRANCE_BALANCED, ENTRANCE_RANDOM)

ImportError: No module named _maze

I deduce that I must build the cpp sources and figure out how to get an interop module "_maze" going. No problem, but a few questions

  1. Does this compile only on Windows, or is there any hope of building it on Mac or Linux? I notice the src directory has a version of Daedalus with a bunch of cpp files, some of which seems algorithmic and some of which seem to be interfacing to Windows. At least conceptually, it should be possible to separate the algorithmic bits from the Windows bits (but doing so requires some intentionality on the part of the original programmer, lest Windows dependencies leak all over the rest of the code). Because you're using matplotlib and Python for display, there should be no theoretical reason for dependency on Windows.

  2. If you've built it off Windows, would you happen to have a CMakeLists.txt or makefile?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.