Code Monkey home page Code Monkey logo

hangman's Introduction

Program Overview

  • A Multi-feature Hangman game written in Haskell, to be played in the console.
    • Some Features:
      • Visual hangman drawing,
      • Quit at anytime, Heavy error-checking,
      • Single (w/ word length) and multi-player playing option!
  • By Atif Chaudhry (Programming Languages @ Saint Louis University, Spring 2015).

Hangman Overview

  • Hangman a game of guessing a word (or a phrase), one letter at a time
  • In this version of the game, the player has 9 lives/chances to guess all the letters in the word.

Game: Start

  • Download Haskell Platform: http://goo.gl/bfyWAW (Windows for me)
  • Either Double click Hangman_2.0.hs or Right Click -> 'Open with GHCI'
    • Alternative: run ghci command in console and enter :load Hangman_2.0.hs
  • Call 'main' function to begin
  • Example:
    F:\Directory>ghci
    -- Some text shows automatically
    Prelude> :load Hangman_2.0.hs
    -- Loaded module(s) are shown
    *Main> main
    -- Game begins
  • The game starts off with showing game's how-to, along with a game menu alt tag
    Option 1: Given a length, a random word of that length is picked for you
    Option 2: Player 2 picks a word (word is not shown/printed) for Player 1 to guess

  • After the word is picked, the following set-up is shown alt tag
    ○ The total number of ' _ ' represent the length of the word, and each ' _ ' represents a letter

Game: Guessing Logic

  • Each turn the player guesses a letter. Only the first letter of input is considered (i.e. in 'abc' only 'a' is taken)
  • If the guess is correct, all occurrences of the letter are revealed.
    • For example, if the hidden word is 'paisa' and the guess was 'a' , the view becomes _ A _ _ A.
  • The number of lives do NOT decrease on correct, invalid (i.e. #, /, $, 3), or duplicate guess(es).
  • Gradually, the wrong guesses will accumulate, and the hangman drawing will continue to become complete alt tag

Game: End

  • (1) The player WINS if all letters are guessed with one or more lives to spare alt tag

  • (2) The player LOSES if the player runs out of lives (the picked word IS shown) alt tag

  • (3) The player QUITS (any time) without winning or losing (the picked word is NOT shown) alt tag

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.