Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Herbert

Herbert is a game I first saw in the Imagine Cup 2008 Algorithm Invitational.

The game requires you to solve a series of levels by writing small programs to control a robot named Herbert. The simpler and more elegant your solution, the more points you get.

It challenges your ability to see patterns and create algorithms to produce those patterns.

Here’s my clone of Herbert.

https://raw.githubusercontent.com/dwayne/herbert-python/master/data/images/herbert.png

Enjoy!

Installation

To install, simply use pip (or pipenv):

$ pip install herbert

Usage

To run herbert you need a level to solve and a program, that you write, that attempts to solve the level.

Suppose the level is stored in level.txt and that you wrote and saved your solution in sol.h. Then, you’d run herbert as follows:

$ herbert level.txt sol.h

It will open a curses based text user interface that allows you to run your program against the level to determine if it solves the level and how many points your solution is worth.

N.B. The data/example directory contains an example level along with 3 attempted solutions to the level. You can use it to help you understand how the game works.

An overview of the game

A level consists of empty spaces (.), walls (*), white (w) and gray (g) buttons, and a robot (u means the robot is facing upwards, r means the robot is facing towards the right, d means the robot is facing downwards, or l means the robot is facing towards the left).

N.B. You can find an example level here.

On each level there are some white buttons. To solve a level you must press all the white buttons. Your goal then is to program Herbert, in a language called “h”, to press all the white buttons while avoiding obstacles such as walls and gray buttons (walls block Herbert’s path and gray buttons reset any previously pressed white buttons to their unpressed state).

You are only allotted a certain number of “bytes” (a unit of program size) per level. Your program must use no more than this number of bytes.

Points are awarded for each white button pressed, a bonus is awarded for solving the level, and extra points are awarded for solutions that use less than the allotted maximum number of bytes.

The “h” language

It is a simple language that contains statements, procedures with zero or more parameters and recursion. Check out the tutorial here to get a better understanding of the language.

You can find examples of the language in use here, here and here.

Challenge

Try to solve the following levels (see data/levels):

Development

Recommended tools:

Clone the repository and install the dependencies:

$ git clone git@github.com:dwayne/herbert-python.git
$ cd herbert-python
$ pipenv shell
$ pipenv install --dev

You’re now all set to begin development.

Testing

Tests are written using the built-in unit testing framework, unittest.

Run all tests.

$ python -m unittest

Run a specific test module.

$ python -m unittest tests.test_interpreter

Run a specific test case.

$ python -m unittest tests.test_interpreter.ExamplesTestCase.test_example10

Resources

Metadata

Release files for herbert-python 0.0.1a3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for herbert-python 0.0.1a3
File Size Uploaded Provenance Actions
herbert-python-0.0.1a3.tar.gz 14.0 kB Without provenance Details for herbert-python-0.0.1a3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for herbert-python 0.0.1a3
File Interpreter ABI Platform Actions
herbert_python-0.0.1a3-py3-none-any.whl Python 3 none any Details for herbert_python-0.0.1a3-py3-none-any.whl

Total release size: 27.9 kB

Release files / herbert-python-0.0.1a3.tar.gz

Download URL herbert-python-0.0.1a3.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ea72d55c29995c6bd484da7054f41aa095dc24e6324f53b9481a92e7cee1a08c
BLAKE2b-256 checksum
How to use checksums
a8ddf7909cf102186bd798bd06bda1512d2c80da5bfe5a06f4cf2dab3e1119b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Release files / herbert_python-0.0.1a3-py3-none-any.whl

Download URL herbert_python-0.0.1a3-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11a8611eb68fe243b5c668fe43ef6b7ae7d919b99a5fee2625fc33f4382302c0
BLAKE2b-256 checksum
How to use checksums
fc6d72e1267572fb3a0a867b696fbc12155af79b67dedb0b4c839731db5e7be5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Security for herbert-python 0.0.1a3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page