Skip to main content

A combined interpreter and compiler for the Half-Broken Car in Heavy Traffic programming language

Project description

Half-Broken Car in Heavy Traffic is a difficult programming language with only 5 combined operators and direction “signs” for 2D grids.

hbcht is a Python 3.1+ combined compiler/interpreter for the language.

License

mege is free software under the terms of the Do What The Fuck You Want To Public License (WTFPL); see the file COPYING.txt. The author of mege is Niels G. W. Serup, contactable at ngws@metanohi.name.

Contact

The author of hbcht is Niels G. W. Serup. Bug reports and suggestions should be sent to ngws@metanohi.name for the time being.

Installation

Way #1

Get the newest version of hbcht at http://metanohi.name/projects/hbcht/ or at http://pypi.python.org/pypi/hbcht

Extract hbcht from the downloaded file, cd into it and run this in a terminal:

# python3 setup.py install

Examples are available in the examples directory.

Way #2

Just run something like this:

# pip-3 install hbcht

Note that this will not make any examples available.

Language documentation

This is the official documentation of HBCHT.

HBCHT is a 2D grid-based programming language. You are a car fighting to get to the exit of a very chaotic highway. You have to follow the signs, but whenever you do that, you also change your memory. The value of your current memory cell can be incremented or decremented and your memory cell index can change. You can also find signs that tell you to turn either right or not turn at all, depending on your memory.

The car can drive in four directions: up, right, down, and left. Because of the chaos, you never know which direction the car is headed when the program starts. This makes it easy to randomize the output.

To make things worse (actually, it’s to make programming in HBCHT possible), you cannot turn left because your car is half-broken. You can drive straight ahead, you can turn right, and you can reverse.

Markers

o car
# exit, return/print

Operations

> go right, next memory cell
< go left, previous memory cell
^ go up, increment
v go down, decrement
/ go right if the current memory cell has the same value as the previous
  memory cell, else continue (if the previous memory cell does not exist,
  its value is zero)

Rules

  • There can be only one car and only one exit

  • The car cannot turn left; any relative left turns will be ignored along with their memory effects

  • The program always starts at memory cell #0

  • All memory cells have the value 0 by default

  • Input values cannot be negative, but values returned by a program can

  • The car cannot go out of bound; if it exits to the right, it reenters to the left, etc.

  • Values cannot be input to memory cells below memory cell #0, but the program can set values in these

  • Values can be arbitrarily large. An interpreter or compiler without this feature is valid, but not perfect (note that hbcht’s C translator uses 32-bit ints and is thereby not perfect).

A semicolon denotes a comment. Anything from the semicolon to the end of the line is ignored.

If a program file contains a line that starts with @intext, it will see input as text and convert the text to ordinals before running the core function.

If a program file contains a line that starts with @outtext, it will show output as a text string instead of a list of numbers.

Use

As a command-line tool

Run hbcht to use it. Run hbcht --help to see how to use it.

As a module

To find out how to use it, run:

$ pydoc3 hbcht

Examples

There are a few examples in the examples directory.

Development

hbcht uses Git for code management. The newest (and sometimes unstable) code is available at:

$ git clone git://gitorious.org/hbcht/hbcht.git

Project details


Download files

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

Source Distribution

hbcht-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

File details

Details for the file hbcht-0.1.1.tar.gz.

File metadata

  • Download URL: hbcht-0.1.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hbcht-0.1.1.tar.gz
Algorithm Hash digest
SHA256 17a257d5f8b73697e61da73e3b6dc6c925a6a1379df9dc59f084111f1e03e9f6
MD5 14447e7d11dcc2f8da8be543b1de9ffe
BLAKE2b-256 9d6e34a72c4b23c7903b678fa4f8bb6f1fde63bc6b68f2c92f5d47b5d5be1ac2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page