Coder Social home page Coder Social logo

cricket's Introduction

Introduction

A cricket simulator on the command-line.


Description

In its current version, this is a program that simulates a 50-over
cricket match between two teams (no players yet), whose names are
provided by the user.  The aim is to offer a realistic simulation.
During a match, every over is played out and the score is kept for each
team's innings.  Additional features include statistics such as the
projected score and the number of boundaries; a brief description of the
condition of the pitch before the start of play; the ability to control
the degree of attack or defense while batting: a more aggressive style
increases the likelihood of scoring runs, but also the chance of losing
wickets.  Vice versa for a more defensive style.

The simulator is written to conform to ISO/IEC 9899:1999 ("C99").  It only uses
these facilities of the C99 Standard:

* stdbool.h for the boolean type  bool


Limitations

* No players
* Ignores free-hit rules, powerplay rules, ball change rules


Enhancements possible

* Implementing players [In progress]
  This is by far the primary feature on the roadmap of enhancements.
* Other minor improvements
  These are mentioned in the items marked `TODO' in the file todo.org


External functionality

A piece of code required case insensitive string comparisons.  There is

        int strcasecmp(const char *s1, const char *s2);

for systems conforming to POSIX.1-2001, but it is not in a Standard C
library.  The wish to stay within the bounds of the C99 standard
motivated the search for a portable solution.

For case insensitive string comparison, `lexcmp' from the Standard
Function Library (c) 1991-2000 by iMatix Corporation has been modified
and used as per the SFL License Agreement found here:

<http://legacy.imatix.com/html/sfl/sfl4.htm#license>

The original library is at

<http://legacy.imatix.com/html/sfl/>


Origin

Many of the mechanics were adapted from the rules for a postal cricket
game, /Cosmic Celebrity Cricket/, originally at

<http://www.sholing.force9.co.uk/cosmic.htm>

but which is now unavailable.  However, it has been archived at the Web
Archive at, for example,

<https://web.archive.org/web/20030930100637/http://www.sholing.force9.co.uk/cosmic.htm>

Changes have been made to the rules described in the above.

The idea for permuting the list of {1, 2, 3, 4, 5, 6}, i.e., the faces
of a die, and thereby determining the chance of a wicket was partly
inspired by how a friend of the author handled a similar situation in
his implementation of the dice game /Ship, Captain, Crew/.


Credits

Advice and commentary by Richard Heathfield on comp.lang.c has helped
the author and this program greatly.  In particular, the code for the
team initialization was simplified by him.  He recommended using better
techniques to reduce the range of the RNG, and also using the
Fisher-Yates shuffle for permuting the list of faces of a six-sided die.

cricket's People

Contributors

udyant-79 avatar udyantw 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.