Coder Social home page Coder Social logo

burraabhishek / python-hand-cricket Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 3.0 14.01 MB

A fully functional implementation of cricket, based on the traditional hand cricket game and implemented over the Python Command Line Interface

License: MIT License

Python 100.00%
python hand-cricket game score test-cricket cricket python-command python3 single-player-game multiplayer-game

python-hand-cricket's Introduction

Python-Hand-Cricket

Play hand cricket as an individual or as a team of 11 against a team of 11 bots for free on the Python Command Line Interface! More information about the gameplay is available in the documentation.

NOTE: The gameplay charts in the documentation are still relevant, but the instructions no longer work. Instead, directly run main.py for the full gameplay.

About this game

This is a hybrid of cricket and the legacy hand cricket game โ€“ implemented in Python and played using the command line interface.

This game is compatible with all releases of Python 3.6 and later.

The game can be played even without an internet connection.

Tournament mode is not yet included in this game. Customized tournaments can be created using individual team files. For such tournaments, at least 20 MB of disk space is recommended.

Test cricket is fully supported.

This game supports almost all of the laws of cricket which can be implemented in a computer program.

Pure hand cricket settings

NOTE: To play only the traditional hand cricket game, play a limited overs game, and set a large number of overs (For example, 1000 overs) and 1 wicket as the game settings when prompted.

Modules:

The source code is located in the src directory. The main source code with all the functions uses a class-based approach. The classes can be viewed here

The source code comprises of the following modules:

  • Team setup: Setup your team and it's members. Team members need not be unique, since only one person may actually be an entire team, i.e., the person wants to play as an individual. In that case, the person's name can be the name of each team member.
  • Match registration: Register a match between your team and another team. To play against the computer, simply skip the play human option.
  • The game: This module can handle both limited-overs and test cricket.
  • src/modules/batterchoice.py: From a given list of players, select the player who will bat now.
  • src/modules/batting.py: Module which contains the code for batting.
  • src/modules/bowlerchoice.py: From a given list of players, select the bowler.
  • src/modules/bowling.py: Module which contains the code for bowling.
  • src/modules/scoreinput.py: This module contains the code to play each ball by using the batting and bowling modules.
  • src/modules/commentary.py: Generate the commentary for each ball bowled, based on the result of that ball.
  • src/modules/scorecard.py: Generate the innings scorecard at the end of each innings.
  • src/modules/superover.py: The super over tiebreaker.
  • src/modules/hashfunc.py: Contains the hashing and verification algorithms used, by importing the required modules. Therefore, if a stronger algorithm is found, it is easier to simply update the algorithm from this file than to update the algorithms everywhere.
  • src/modules/toss.py: Toss to decide which team bats / fields first. This code is not compatible with super over games, since this decision is the reverse of their decision in the latest tied game
  • src/modules/followon.py: Only works for test cricket. Determine whether the team which batted first can enforce the follow-on or not. This code runs only if the team batting first leads by a certain threshold.
  • src/modules/savegamedata.py: Saves the completed game into a JSON file.

Some folders (directories) have a README.md file. Please read them carefully as they describe the contents of that directory.

Getting Started:

Rules of the game:

This game is a hybrid of cricket and hand cricket and runs on the Python Command-line interface.

NOTE: The scoring and dismissal mechanisms are determined by the rules of Hand Cricket. The rest of the game follows the Laws of Cricket

The ultimate goal is simple: Score more than your opponent to win.

Pre-requisites:

To play this game, you need to have Python software installed. Go to https://www.python.org/downloads to install the latest version.

Supported platforms:

Either download this entire repository to play this game, or clone this repository using:

$ git clone https://github.com/BurraAbhishek/Python-Hand-Cricket.git

Disk space: 32 MB (minimum), 256 MB or more (recommended).

Features of cricket which are not implemented in this game

  • Run out: The batter fails to reach the crease before the wickets fall.
  • Extras: Wides, no balls, byes, leg-byes.
  • This game implements a 6-run penalty for wrong bowling input. In actual cricket, various infractions by the fielding side can lead to 5 penalty runs.
  • Rain delay and DLS par score

Known bugs

Rain delay and abandoned matches are not yet implemented in this game. However, deliberately closing the application in order to avoid losing a match is considered as an abandoned match. This issue can't be fixed, since there are other ways to get around it, for example, by manually editing the JSON team files.

License

The source code is licensed under the terms of the MIT License, unless specified otherwise.

The sample games and documentation are licensed under the Creative Commons CC0 license.

python-hand-cricket's People

Contributors

burraabhishek avatar

Watchers

 avatar

python-hand-cricket's Issues

Password hashing is required

All passwords in this game are currently stored in clear text. Password hashing is required to securely store the passwords in the text files used to save game data.

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.