I need to create a cricket manger game (much like football manger).
Long story short i need to decide the outcome of a game based on each users team and tactics. My idea was to decide the outcome ball by ball.
So depending on a Bowlers attributes (strength, stamina, skill etc) a ball (with some properties : speed etc) is send towards the batsmen, the batsmen would hit (or not) the ball depending on a score too, if the ball is hit i would then send the ball towards one of the fielders (assume there are 9, generate a random number between 1 and 9 and pass the that fielder). Again based on fielder skill it would catch the ball or not.
What I'm missing is the number of runs the the batsmen would do before the ball is catched. I want to fine tune the direction of the ball. I'm also not sure how order of player entrance would affect the game outcome.
Can you help me define a good match workflow ? ( I'm not very familiar with a cricket, read tutorials, watched games, never played though).
Thank you.
Update:
I'm also thinking to that a ball would store most of the decision data need, e.g:
ball.Bowler = player (the bowler who threw the ball)
ball.Batsmen = player (the batsmen who might hit it)
ball.OverId = in which over this ball was played
ball.Hittable = 4 (the number would be probably generated from the bowler strengt + others, also it might be dependent on Bowler and Batsmen
ball.Runs = 2 the number the runs made by the batsmen who hit the ball
ball.IsUsed whenever the ball is worn out or new ball.IsOutside = true if the ball was send outside the field
===== Would be used to calculate if the batsmen can bat this ball or not
ball.ThrowHeight
ball.ThrowSpeed
ball.ThrowEffect
ball.ThrowNumberOfBounces
ball.BattedHeight
ball.BattedSpeed
ball.FieldlerDirection = 3 (towards the third fieldler), random
ball.FieldlerDirectionOffset = 2 (in the 2 meter range of the 3rd fieldler. 0 would be that the fielder might catch it directly from mid air, ), random
And i also need to consider if the bowler shoots for the stumps, this would be another workflow..
Update2:
The competition is 20/20 cricket.
This is an interesting problem, but I don't see the utility of this. Are you making a simulation?
In any case, if I were in your position, I would have done the following for each ball, assuming you have all the relevant data corresponding to the players.
I would break this into 4 stages and each outcome is defined by
a. Strategy
b. Strength
c. Randomness
d. State of previous stages.
Define the fielding positions. According to the bowling team strategies, I would place my strong fielders in the critical positions. This could be done by a mix of strategy and some randomness.
Define the ball. This would depend upon the bowler's skill (spinner/fast bowler/swing bowler), match situations(yorkers at the end of the innings etc), some random factors, and some rules(one bouncer per over etc)(See here). The result of this stage is a perfectly defined ball position/speed/orientation near the batsman (basically the trajectory).
Define the stroke. This would depend upon the batsman's strength, match situations, some randomness and most importantly the definition of the ball from stage 2 (See [here])3. This would define the next trajectory/ speed.
Define the fielding. This is the most crucial for you w.r.t your question. Now this depends upon the field placements as per stage 1, fielder strength, and most crucially the definition of the ball trajectory from stage 3. Depending upon these factors, it could be a catch, or 0,1,2,4,6 runs. Some obvious implementations could be that if the position of the ball is almost bisecting two fielders and no other fieleders are nearby and if the speed of the ball is good enough to reach the boundary, it is 4 runs. Here you will have to implement the physics of the ball trajectory properly in stage 4. Not only this, if the trajectory is without touching the ground and if there is a player nearby this could be defined as a catch, if the ball has already touched the ground before reaching near the player, you could modify the trajectory to guide the ball back to the wicket keeper etc. Maybe you could implement simple rules here before getting into difficult situations such as run outs.
Finally the ball is supposed to reach back to the bowler.
All the best.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With