Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

Some utilities for playing the Leaving Earth boardgame.

Project Description

A Python (2.7) tool for planning missions for the Leaving Earth boardgame.

Currently support is only provided for a basic API. There is (as yet) no command line support and no documentation.

Functionality: package API

To get started simply import the whole package (importing the usual components from __future__ for good measure):

>>> from __future__ import (absolute_import, print_function, division, unicode_literals)
>>> from leaving_earth_game import *

Note that this imports matplotlib, which will, as usual, subsequently behave according to your backend settings (e.g., some operations my open a figure window if you use an interactive backend).

Optimal (least cost) missions are computed by simply creating a mission from a mission specification, consisting of a list of location names, or, where components are added or removed, a tuple consisting of the name and a list of added and (optionally) removed components, each of which is in turn a tuple consisting of the component name and the number added or removed.

Note that currently, these specifications are not validated (see limitations). In particular, it is necessary to add at least one payload on Earth for a valid mission to be generated.

For example, to create a mission to the Moon via Suborbital Flight with a single Probe as payload simply

>>> mission = Mission([('Earth', [('Probe', 1)]), 'Suborbital Flight', 'Earth Orbit', 'Lunar Orbit', 'Moon'])

Missions can then be printed as a text schematic, showing the mission profile from bottom to top, with locations along with components any added or removed there, alternating with the rockets used between each location, along with the total cost of that stage (in parentheses):

>>> print(mission)
Moon
^ 1xJuno (1)
Lunar Orbit
^ 1xAtlas (5)
Earth Orbit
^ 1xSoyuz (8)
Suborbital Flight
^ 1xSoyuz (8)
Earth + 1xProbe

More interestingly, missions can be displayed graphically by creating a figure using the mission’s plot method and then displaying that figure with any of the usual matplotlib Figure methods. For example to create and save a high-resolution PNG of the mission above, simply

>>> mission_fig = mission.plot()
>>> mission_fig.savefig('moon_probe.png', bbox_inches='tight', dpi=500)

which produces a graphical representation of the same structure as the text schematic, with costs indicated in brackets, and added or removed components indicated with right and left pointing triangles, respectively.

Similarly, a PDF version can be created with

>>> mission_fig.savefig('moon_probe.pdf', bbox_inches='tight')

So, for example, a mission to the Moon and back with a single Probe (no sampling or leaving any probes behind) would be:

>>> mission = Mission([('Earth', [('Probe', 1)]),'Suborbital Flight', 'Earth Orbit',
                      'Lunar Orbit', 'Moon',
                      'Lunar Orbit', 'Earth Orbit', 'Earth'])
>>> print(mission)
Earth
^
Earth Orbit
^ 3xJuno (3)
Lunar Orbit
^ 4xJuno (4)
Moon
^ 1xAtlas (5)
Lunar Orbit
^ 1xSoyuz (8)
Earth Orbit
^ 1xAtlas 1xSaturn (20)
Suborbital Flight
^ 1xSaturn (15)
Earth + 1xProbe

or graphically

In addition to the default Tube-style theme used in the figures above, a “Retro” theme, is also supported, so that, applied to the lunar sample return mission above,

>>> mission.plot(theme='Retro').savefig('moon_probe_return_retro.png', bbox_inches='tight', dpi=500)

produces

It is also possible to select a color for use in the Tube-style figures:

>>> mission.plot(path_color=PATH_COLORS['circleyellow']).savefig('moon_probe_return_yellow.png', bbox_inches='tight', dpi=500)

produces

More complex missions are defined by simply using the same scheme for specifying additions and subtractions of components. For example a mission with an unmanned Vostok that makes a round trip to Venus Orbit accompanied by 2 Probes, one that’s left in Earth Orbit, and one that’s left in Venus Fly-By, and an Eagle that’s picked up in Earth Orbit and left in Venus Orbit, is defined with

>>> miss = Mission([('Earth', [('Probe', 2), ('Vostok', 1)]), 'Suborbital Flight',
                     ('Earth Orbit', [('Eagle', 1)], [('Probe', 1)]),
                     'Inner Planets Transfer',
                     ('Venus Fly-By', [], [('Probe', 1)]), ('Venus Orbit', [], [('Eagle', 1)]),
                     'Inner Planets Transfer', 'Earth Orbit', 'Earth'])
>>> print(mission)
Earth
^
Earth Orbit
^ 1xAtlas (5)
Inner Planets Transfer
^ 1xSoyuz (8)
Venus Orbit - 1xEagle
^ 1xAtlas (5)
Venus Fly-By - 1xProbe
^ 1xSoyuz (8)
Inner Planets Transfer
^ 1xSaturn (15)
Earth Orbit + 1xEagle - 1xProbe
^ 3xSaturn (45)
Suborbital Flight
^ 1xSoyuz 2xSaturn (38)
Earth + 2xProbe 1xVostok
>>> miss.plot(path_color=PATH_COLORS['districtgreen'])
>>> miss.plot(theme='Retro')

By default, all basic game rockets are available for use in mission planning. Rockets can be excluded from the specification of a mission with the excluderockets optional argument, or constrained with the userockets argument.

Functionality: command line

TBD

Documentation

For now, just this file.

Limitations

There is as yet no support for crew or for samples, though specifying a Sample as part of the payload will still work:

>>> mission = Mission([('Earth', [('Probe', 1)]), 'Suborbital Flight', 'Earth Orbit',
                        'Lunar Orbit', ('Moon', [('Sample', 1)]),
                        'Lunar Orbit', 'Earth Orbit', 'Earth'])
>>> print(mission)
Earth
^
Earth Orbit
^ 1xAtlas (5)
Lunar Orbit
^ 1xAtlas (5)
Moon + 1xSample
^ 1xAtlas (5)
Lunar Orbit
^ 1xSoyuz (8)
Earth Orbit
^ 1xSoyuz 1xSaturn (23)
Suborbital Flight
^ 1xAtlas 1xSaturn (20)
Earth + 1xProbe

or graphically

There’s no validation of the specification provided for a mission. For example it is possible to specify a mission with no payload, which just ends up as no mission at all

>>> print(Mission(['Earth','Suborbital Flight', 'Earth Orbit', 'Lunar Orbit', 'Moon']))
Moon
^
Lunar Orbit
^
Earth Orbit
^
Suborbital Flight
^
Earth

or to specify removal of payload components than are not present, which just results in garbage

>>> print(Mission([('Earth', [('Probe', 1)]), 'Suborbital Flight', ('Earth Orbit',[], [('Vostok', 5)]), 'Lunar Orbit', 'Moon']))
Moon
^
Lunar Orbit
^
Earth Orbit - 5xVostok
^ 1xAtlas (5)
Suborbital Flight
^ 1xAtlas (5)
Earth + 1xProbe

In addition to there being (as yet) no documentation (other than this file) or command line support, this package is much more complex than it needs to be for the limited functionality it currently supports. This is mostly to provide the necessary scaffolding to evolve it into a full Python package (which may never happen).

Feedback and suggestions

For all suggestions and discussion, connect on Gitter

Development status

This package is in the early stages of development, and I and can’t promise the current development version will work. More detail about planned releases and activities can be found the list of scheduled milestones and in the list of open issues. Various test versions may be available for installation or issues review, but these also may not work as expected.

Release History

Release History

This version
History Node

0.0.1a5.dev2

History Node

0.0.1a4.dev1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
leaving-earth-game-0.0.1a5.dev2.tar.gz (10.7 kB) Copy SHA256 Checksum SHA256 Source Feb 1, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting