Giter Site home page Giter Site logo

brainspacehangman's Introduction

Brainspace Hangman

The goal of this repository is to provide one file containing an implementation of the popular game Hangman.

However, the implementation will be done in Brainfuck and Whitespace, both contained within the same file (effectively creating a polyglot). Instructions how to run the code in this repository with existing interpreters or compilers can be found in the github repository of the respective language. The following language sections also reference the interpreters used while developing.

Branches

Apart from the main branch, this repository features the two branches brainfuck and whitespace. Since the main branch contains only the source code in a way that is as obfuscated as possible (that's the beauty of this repository after all) interested viewers can find better documented code in those branches.

Please be aware that the content of these branches is split into multiple files for different algorithms and contains only rough comments I made while implementing them. They may be incomprehensible to anyone other than me, but I still leave them in there to give at least any form of explanation how this code works. Even though I try to keep them synchronized, I cannot guarantee that the main file and the broken-down explanation files are completely equal in content.

Language-specific game instructions

Since the two implementations are separate from each other, the final program also differs slightly depending on the language. Here is what you need to know in order to play a proper game of hangman:

Brainfuck

The game starts by instructing you to input a secret phrase. Player 1 may input any character, but only ASCII letters [a-zA-Z] become hidden, with any other symbols staying visible to keep the game fair. You conclude the input by entering newline. Player 1 should then clear the console. The secret phrase may even consist of multiple words separated by spaces.

Player 2 can then make attempts to guess letters contained in the secret phrase. Each wrong guess deducts one of the seven lifes and adds a new part to the stick figure. Capitalization of the input is ignored, as the input as well as the secret phrase are stored in uppercase. Correctly guessed letters will not be hidden in subsequent attempts.

The game ends once either the secret phrase was fully revealed or the stick figure was completed. The message on the screen will inform Player 2 whether they won or lost.

The Implementation has been tested with this brainfuck interpreter. Please be aware that other interpreters may show implementation-specific behavior that can render the program unusable.

Whitespace

The game flow is very similar to the Brainfuck version. Initially, Player 1 specifies a secret phrase, with any characters which are non-ASCII letters staying revealed. The difference with this version is that the secret phrase must end with a trailing space character, otherwise the program will not stop reading your input. This also means that in this implementation, you cannot separate multiple words using spaces.

After the secret phrase was specified, Player 2 may try to guess individual letters. On a correct guess, this letter will be revealed, otherwise a new part of the stick figure will be added. This input does not have to be space-terminated, and inputting multiple characters at once is possible.

Again, the game ends once either the secret was fully guessed or after seven wrong guesses. The interpreter used for testing the implementation is this one. Have fun!

brainspacehangman's People

Contributors

codingdepot avatar

Stargazers

 avatar

Watchers

 avatar

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.