Blueprint
Magical blueprints for procedural generation of content. Based roughly on http://www.squidi.net/mapmaker/musings/m100402.php
The essential idea is that you write subclasses of blueprint.Blueprint with fields that define the general parameters of their values (e.g. an integer between 0 and 10). When you instantiate a blueprint, you get a “mastered” blueprint with well-defined values for each field. Mastered blueprints may define special “generator” instance methods that build final objects from the master.
Think of it as prototypal inheritance for Python!
An example:
import blueprint
class Item(blueprint.Blueprint):
value = 1
tags = 'foo bar'
class Weapon(Item):
name = 'Some Weapon'
tags = 'dangerous equippable'
damage = blueprint.RandomInt(1, 5)
class Spear(Weapon):
tags = 'primitive piercing'
name = 'Worn Spear'
damage = blueprint.RandomInt(10, 15)
value = blueprint.RandomInt(4, 6)
class PointedStick(Weapon):
tags = 'primitive piercing'
name = 'Pointed Stick'
damage = 6
value = 2
class Club(Weapon):
tags = 'primitive crushing'
name = 'Big Club'
damage = blueprint.RandomInt(10, 15)
value = 2
class Actor(blueprint.Blueprint):
tags = 'active'
class CaveMan(Actor):
name = 'Cave Man'
weapon = blueprint.PickOne(
Club, Spear, PointedStick
)
And then:
>>> actor = CaveMan()
>>> actor
<CaveMan:
name -- 'Cave Man'
weapon -- <PointedStick:
damage -- 6
name -- 'Pointed Stick'
value -- 2
>
>
TODO
Better documentation. :)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file python-blueprint-0.1.tar.gz.
File metadata
- Download URL: python-blueprint-0.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31e8f42811deb6c1c4bce376f9e3d01f89200d7135ba78c018a395d77b42dc2a
|
|
| MD5 |
d8618a71ed0be30ae134c36bf9fb116f
|
|
| BLAKE2b-256 |
c4d7269d1b045fdebff183b664b47aa932021ab4e48cf06709df7facc82df561
|