Giter Site home page Giter Site logo

arthodas / mastermind Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chulme/mastermind

0.0 0.0 0.0 47 KB

A paired university project, concerning an embedded Raspberry Pi system written in C and inline assembly, to recreate the board game Mastermind.

Makefile 4.63% C 95.37%

mastermind's Introduction

Mastermind

To purpose of this project is to create the game Mastermind, using the C programming language and inline ARM assembly, executing on the Raspberry Pi with external input/output devices.

This project has been completed by Adam Malek and Christopher Hulme as a university project.

Game Rules

MasterMind is a two player game between a codemaker and a codebreaker. Before the game, a sequence length of N and a number of C colours for an arbitrary number of pegs are fixed. Then the codemaker selects N pegs and places them into a sequence of N slots. This (hidden) sequence comprises the code that should be broken. In turns, the codebreaker tries to guess the hidden sequence, by composing a sequence of N coloured pegs, choosing from the C colours.

In each turn the codemaker answers by stating how many pegs in the guess sequence are both of the right colour and at the right position, and how many pegs are of the right colour but not in the right position. The codebreaker uses this information in order to refine his guess in the next round. The game is over when the codebreaker successfully guesses the code, or if a fixed number of turns has been played.

Below is a sample sequence of moves (R red, G green, B blue) for the board-game:

Secret: R G G
=============
Guess1: B R G
Answ1:  1 1
Guess2: R B G
Answ2:  2 0
Guess3: R G G
Answ3:  3 0
Game finished in 3 moves.

For details see the MasterMind Wikipedia page: https://en.wikipedia.org/wiki/Mastermind_%28board_game%29

Download and Installation

The program has to be executed with sudo privileges: sudo build/mastermind

Objects and the executable can be removed with the command: make clean

Compilation can also be done with make: make all

Implementation

Hardware

A Raspberry Pi 2 was used in conjunction with an external breadboard circuit featuring 2 LEDs, a button, a potentiometer and a 16x2 LCD screen.

The breadboard circuit follows the wiring diagram provided. Following the wiring diagram, the RPi GPIO pin 13 was used for the green LED, pin 5 was used for the red LED and pin 19 for the button.

Code

The code is split into 3 modules

  • GPIO –for controlling the GPIO pins using inline assembly.
  • LCD – for controlling the LCD display.
  • Mastermind – implements the gameplay logic and brings GPIO and LCD modules together

mastermind's People

Contributors

chulme 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.