Giter VIP home page Giter VIP logo

solitaire_final's Introduction

solitaire

Overview

This is a console-based, unix-compatible Python implementation of the popular card game Solitaire (also known as "Patience"). To play, simply run the solitaire.py file using Python 3.

Rules

This implementation of Solitaire was modeled after the official rules described here by Bicycle Cards.

Edge Cases To Account For (non-exhaustive)

  • Only Kings can fill up vacancies in the Tableau
  • The four stacks in the Foundations must begin with the lowest value card, an Ace.
  • The Stock/Waste piles loop continuously through the cards
  • The game concludes when the Foundation piles are filled.
  • You can move a stack of cards between columns of the Tableau, rather than just one.
  • On the Tableau, if a column's revealed cards are all removed, the bottom card of the unrevealed pile is flipped.

Design Choices

Python

Python was used because it's flexibility in creating multiple classes in one file allowed me to implement this small game in a single file.

Classes

The Card and Deck class were used to initialize our starting deck and distribute cards between the different spaces of the game: the Tableau, the Foundation, and the Stock/Waste pile. The Tableau class manages the 7 starting piles of cards and their interactions with the Stock/Waste and the Foundation. The Foundation class handles the placement of cards into the Foundation piles. The StockWaste class moves cards in between the Stock pile and Waste pile, and provides getters/setters for Stock and Waste piles.

Data Structures

Piles of cards were mostly implemented using lists, which were the optimal choice because they retain the order of elements and retrieve elements quickly. A dictionary of integer keys and list values was used to organize the 7 piles on the Tableau.

solitaire_final's People

Contributors

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