GithubHelp home page GithubHelp logo

peg_solitaire's Introduction

Univeristy of Exeter Logo

HPDM139 Assignment 1 - Peg Solitaire

Elliott Coyne

MSc Health Data Science 2021/2 Cohort

Content

Assignment Description

The purpose of this assignment was to create a functioning game of Peg Solitaire. The game needed to meet the following requirements:

  • allows a user to play the game of peg solitaire via a basic interface;
  • allows only the legal moves from peg solitaire;
  • allows a user to input moves step by step by loading a solution file that contains a chain of moves; and
  • logs the users moves and outputs the log to file.

Instructions for Use

Please note the library dependencies as listed below in Additional Libraries Used

  • To run the TEXT based version of the game, run the "main.py" in the Python terminal. This will load the menu to faciliate game play.
  • To run the Windows GUI (advanced) version of the game, run the "GUI_main.py" in the Python terminal. This will launch a new window with buttons for different operations.

Testing

  • To ensure that both the Text and GUI versions can handle solution import files, please refer to the garbage_moves.txt and garbage_moves2.txt files respectively. These can each be imported and handled correctly.

Game Operation

Text Version

Once loaded, the game will ask the player to determine what they would like to do. The options are to Load a (S)oltion File, (P)lay the Game, Read the (R)ules or (E)xit. After loading a solution file (which is assumed to be in the current working directory), the player can enter the next move of their own choice (provided there are pegs remaining). Legal moves will be in the format 'ox' or 'ex'.

GUI Advanced Version

The game will load and display the board; red buttons indicate pegs and white are holes. Simply click first on the origin then the destination buttons; the computer will assess the move and reduce the peg count (displayed at the bottom of the screen) if successful.

Solution files may be loaded by clicking on the Load button, which will open the File Browser. Descriptive feedback will be provided after the file has been loaded and moves considered.

Both Versions

The aim of the game is to be left with just 1 peg in the board.

If loading a partial solution file, the computer will make all the loaded moves before handing over to the player. Any subsequent moves will be appended to loaded moves and appear as a single file in the export.

The number of pegs remaining will appear on bottom of the window after the first successful move is made.

Upon exiting the game (after game play), a text file containing all legal moves will by generated and autosaved using the date time to create a unique file name.

If playing the game, the following criteria must be satisfied for a move to be considered legal:

  • ORIGIN and MIDDLE peg must be filled;
  • DESTINATION hole must be empty; and
  • ORIGIN and DESTINATION must be 2 holes (horizotally or vertically) away from eachother; and

Game Rules

  • Peg solitaire is a game for one player. There are 33 holes arranged in a 'plus' symbol configuration. The peg in the centre is removed. This leaves 32 pegs.

  • The objective of the game is to end up with one peg in the middle hole. This is achieved by removing one peg at a time by jumping an adjacent peg over it into an adjacent empty hole in the other side."

  • For example, the peg marked with a cross would be removed by jumping the peg marked with a triangle into the hole in the centre (shaded). No diagonal jumps are permitted.

Additional Libraries Used

  • The Rich (v 10.12.0) library was used for enhanced display of the board and character map positions. More details can be found within the documentation.
  • Tkinter (tk v 8.6.10) was used for the GUI version of the application. More details can be found within the documentation.

Links

Please find all relevant links for this project below:

peg_solitaire's People

Contributors

tristar82 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  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.