SChem
https://pypi.org/project/schem/. Install with pip install schem
Clean Room implementation of the backend of SpaceChem (https://www.zachtronics.com/spacechem).
Usage (CLI)
python -m schem [-h] [--version] [-l LEVEL_FILE] [--max-cycles MAX_CYCLES]
[--check-precog] [--max-precog-check-cycles MAX_PRECOG_CHECK_CYCLES]
[--seed SEED] [--hash-states HASH_STATES]
[--export] [--no-run] [--strict]
[--json | --verbose] [--debug [DEBUG]]
[solution_files ...]
E.g. python -m schem will validate the cycles-reactors-symbols score of any solution export(s) in the user's clipboard. See python -m schem --help for details.
Usage (python)
Supposing level_export, solution_export are strings as exported by SpaceChem CE:
from schem import Level, Solution
# Load a solution
solution = Solution(solution_export) # Auto-use appropriate official level
solution = Solution(solution_export, level=level_export) # Custom level
solution = Solution(solution_export, level=Level(level_export)) # Alternative
# Run a solution
solution.run()
# => Score(cycles=45, reactors=1, symbols=14)
# Check the expected score that was in the export's metadata
solution.expected_score
# => Score(cycles=44, reactors=1, symbols=14)
# Reset the run state of a solution
solution.reset()
# Validate that a solution matched its expected score
solution.validate()
# =/> ScoreError("[Of Pancakes and Spaceships] 44-1-14 "Cycles" by Zig: Expected 44 cycles but got 45.")
# Check if a solution uses precognition
solution.is_precognitive() # slow
# => False
# Bundle method for calling validate() if expected score is present, else run(), optionally checking precog,
# and returning a dict of all this info and any error
solution.evaluate()
# => {"level_name": "Tunnels III",
# "resnet_id": (1, 1, 3), # Volume, Issue, Puzzle
# "author": "Zig",
# "cycles": 244,
# "reactors": 1,
# "symbols": 14,
# "solution_name": "symbols",
# "error": ScoreError("[Tunnels III] 243-1-14 \"symbols\" by Zig: Expected 243 cycles but got 244.")
#}
solution.evaluate(check_precog=True)
# => {"level_name": "Challenge: Going Green",
# "author": "Zig",
# "cycles: 3578,
# "reactors": 1,
# "symbols": 103,
# "solution_name": "assumes 2nd input",
# "precog": true,
# "precog_explanation": "Solution is precognitive; failed whenever molecule 2 was Hydrogen Sulfide, for 9 such
# appearances (whereas solution success rate was otherwise 100%)."
#}
# Re-export the solution. Sorts export lines to ensure uniqueness
solution.export_str()
# => "SOLUTION:..."
Metadata
Release files for schem 0.35.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| schem-0.35.0.tar.gz | 251.1 kB | Without provenance | Details for schem-0.35.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| schem-0.35.0-py3-none-any.whl | Python 3 | none | any | Details for schem-0.35.0-py3-none-any.whl |
Total release size: 459.0 kB
Release files / schem-0.35.0.tar.gz
| Download URL | schem-0.35.0.tar.gz |
|---|---|
| Size | 251.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d328e9c20eaa24f5d7d62df86de06737d29756a8e7a77771e1915be8c424ee7
|
|
BLAKE2b-256 checksum How to use checksums |
2a07081458240da82dd24e6929f23b5d9725c1bd64ac080ee68ad5d7fd4175c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.3
|
Release files / schem-0.35.0-py3-none-any.whl
| Download URL | schem-0.35.0-py3-none-any.whl |
|---|---|
| Size | 207.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
828ce2b9811233544d9f5dee3a6cf4392348c2e4d80d86da07fce793a9b474fe
|
|
BLAKE2b-256 checksum How to use checksums |
f6f72c459b72442c157eeb242c6e60623c0d6e509c3f41c2efe28bb6dfc96347
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.3
|
Security for schem 0.35.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.