-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame Overview
25 lines (24 loc) · 2.5 KB
/
Game Overview
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
The project is to create a simulator for a cricket match using arrays and random functions. The simulation follows a specific order of execution:
Read the value of N (number of overs) from the configuration.txt file.
Toss is done randomly, and a team is chosen to bat first.
Create two teams with 11 players each, storing their names, runs scored, balls faced, balls bowled, runs given, and wickets taken using 1D/2D arrays.
Player 1 and Player 2 of the batting team appear on the scorecard. Player 1 faces the first ball.
The batsman facing the ball is determined based on the score:
Score 1, 3, or 5: The other end batsman will face the next ball.
Over completed: The other end batsman will face the next ball.
Bowlers are selected from Team B, with the last five players designated as bowlers. Each bowler can bowl a maximum of total_overs/5 overs.
Each ball is bowled by pressing ENTER, and a random score between -1 and 6 is generated. If -1 comes up, the batsman is declared OUT.
The scoreboard is updated by clearing the screen and redrawing it with new values.
The probability of a batsman getting out or scoring runs varies:
Bowlers (player 6 to 11) have a 50% chance of getting out and a 50% chance of scoring 0-6.
Batsmen (player 1 to 5) have a 10% chance of getting out and a 90% chance of scoring 0-6.
The total score and the number of dismissed players are calculated and displayed on the scoreboard.
If a batsman is dismissed, their scorecard is displayed until ENTER is pressed again, and then the main scorecard is shown.
The innings of the team batting first ends when all overs are bowled or all players are dismissed. The full scorecard is displayed, summarizing the innings.
A special key allows the user to enter the over number and skip pressing ENTER for each ball, or go directly to the end of the innings. A short delay can be added after each ball for better visualization.
The second innings is played in the same manner, including the target, remaining score, remaining overs, and required run rate on the scorecard. The first innings scoreboard is not displayed during the second innings.
After the match finishes, the user is given the option to show a short summary of the match, show the first innings, show the second innings, save match data to a file, or load previous match data.
The result is determined as follows:
The bowler with the highest number of wickets is declared the bowler of the match.
The batsman with the highest runs scored is declared the batsman of the match.
The team that wins is displayed as the winner.