GithubHelp home page GithubHelp logo

youngmyn / solitaire Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 218 KB

This program automatically generates a shuffled deck of cards and plays Solitaire N times. Then it outputs the percentage of successful solitaire games.

Java 100.00%
solitare statistics

solitaire's Introduction

Solitaire

This code is one of the first I wrote.
I was about 14 years old and just starting to discover programming.
Mom taught me how to play card solitaire, and when I was bored I would sit with a deck of cards and try to fold it.
However, over and over again the combination of cards turned out to be unsuccessful,
and it began to seem to me that it was impossible to fold it. Then I wrote a small program that automatically
played a huge number of solitaire games and counted the winning percentage.
As a result, I got a probability of winning of approximately 0.0075. This explained my such a low winning percentage :)
The rules of that solitaire game are given below:

Rules

The game is played using a deck of 36 cards.
Cards are laid out on the table alternately from left to right, and after laying out a card, we look at the last three cards laid out.
If in a three of cards the outer ones belong to the same suit or have the same value, then the central card in the three is placed on top of the left one.
Further, since one card disappeared, we could have new combinations, and we look for them in the laid out cards and add them up according to the same principle.
Sometimes 1 needed card starts a giant chain of combinations.
If we are sure that there is no combination in any of the three adjacent cards in front of us, we lay out a card from the deck.
The game ends when the cards in the main deck run out. If there are only 2 cards on the table in front of us, then we win, if more, we lose.
Example:

drawing

solitaire's People

Contributors

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