Git Product home page Git Product logo

herbert-python's Introduction

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 [email protected]: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

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.