Giter VIP home page Giter VIP logo

py-sweep's Introduction

PySweep

There are pythons snakes in the grass!

This project is a console implementation of the classic game Minesweeper as recommended by Triplebyte's interview guide.

Running

Just clone the repo and execute the pysweep module

$ python -m pysweep

The prompts will guide you from there.

Tests

Tests are written with pytest. Install if not installed already and just run pytest

$ pip install -U pytest
$ pytest

Programming Concepts/Patterns Used

Anonymous Functions : Principally for customizing how user input is captured.

Depth-First Search : For revealing contiguous sections of blank squares.

Encapsulation : For state management of the gameboard and squares.

Null Object Pattern : For gracefully dealing with out of bounds squares.

Generators : For various iterations, to keep memory use nice and tidy

Recursion : For the application of scalar-based algorithms against non-scalar data

Thoughts

I know there are best in class packages available in the community to handle some of the things done here better, but as a practice exercise I wanted to keep this pure python, save testing.

I'm not great at making console applications and am even less experienced at dealing with game loops. I don't feel great about the use of Exceptions to manage game termination but it works for now.

Overall I'm pleased with the implementation for a few hours work.

TODO

  • Admin: Unit tests
  • Admin: Doc strings
  • Feature: Add victory condition
  • Feature: Add snake flagging
  • Feature: Add snake count
  • Feature: Add timer
  • Feature: Add UI colors
  • Feature: Richer input options (Multiple row/column selection per command)
  • Feature: Command-Line arguments to drive feature toggles
  • Refactor: Uncouple rendering from state
  • Refactor: Get fancy! Maybe some context managers or decorators
  • Refactor: Unit tests to make better use of built-in mocking
  • Major Version: Write as a curses app

Changelog

0.6.0

  • Added richer input options
  • Board difficulties now mirror the original Minesweeper

0.5.0

  • Added UI colors
  • Added game timer

0.4.0

  • Updated rendering so playing larger boards is a bit easier

0.3.0

  • Added snake flagging
  • Added snake counter

0.2.0

  • Rebranded game as PySweep

0.1.0

  • Version playable version of game that is winnable
  • No flagging
  • No bomb counter

py-sweep's People

Contributors

baileyp avatar

Stargazers

 avatar

Watchers

 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.