GithubHelp home page GithubHelp logo

tanthanadon / handchallenge Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.01 MB

Hand Challenge is the game developed by Python that simulates guessing the total number of opening hands of users against AI

Shell 0.27% Python 99.73%
game python

handchallenge's Introduction

HandChallenge

Rules of the game:

This game is played between two players.

One player will be the predictor.

To play the game, after a count of three, the players will need to simultaneously show their hands with each hand either open or closed, and the predictor need to shout out how many hands they think will be open on total.

If the predictor is correct, they win, otherwise the other player becomes the predictor and they go again. This continues until the game is won.

The challenge:

You need to create a program to play this game against the computer. This can just be a simple console application.

You will always be the predictor first.

The “AI” player will just do things randomly.

For each round, the computer will expect player input in the following format if you are the predictor:

OC2

Or if you are not:

CO

That is, the first two characters will show how you will play your hands, O for open or C for closed. If you are the predictor, you also need to enter a third character which is your prediction for how many open hands in total.

The program should then reveal the “AI” players input and indicate if the game was won, or move to the next round.

Example of what game play could look like:

Welcome to the game!

You are the predictor, what is your input?

OO4

AI: CO

No winner.

AI is the predictor, what is your input?

CC

AI: OO0

No winner.

You are the predictor, what is your input?

CO3

AI: OO

You WIN!!

Do you want to play again?

N

Ok, bye!

Tips:

Remember to validate the input and give the user useful messages if their input is not valid.

Valid input should be either a C or O for the first two character and a number between 0 and 4 for the prediction.

For example, if the user enters “chicken” on their turn, you could display a message such as:

Bad input: correct input should be of the form CC3, where the first two letters indicate [O]pen or [C]losed state for each hand, followed by the prediction (0-4).

If the user enters “CC8” the error could be:

Bad input: prediction should be in the range of 0-4.

Or, if they are not the predictor:

Bad input: no prediction expected, you are not the predictor.

Try and write unit tests for your code, if you can, use TDD (test driven development) when writing the solution.

Think about the design of your objects and cleanliness of your code. Will it be easy for you to make changes to your code to implement some of the extensions? How about for someone else?

handchallenge's People

Contributors

tanthanadon avatar

Watchers

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