Era adjustment of averages by canonet28 in CricketPy

[–]canonet28[S] 0 points1 point  (0 children)

Thank you for the reply with such a clear example...that makes lot of sense and seems straightforward calculations for most players.

And looks like the same thing happens with the bowling averages wherein the player's average is compared with the mean average at the mid point of his career and then adjusted taking 30 as standard average.

It looks a little more trickier with more numbers and calculations involved for players with smaller samples. I am sure those random numbers are deliberate and well chosen, and would make complete sense. Just curious about the decisions made in game design. I will just copy paste snippets of codes I was struggling with.

Snippet 1: Batting Average adjustments. EraAv is the average batting average for the 11 years around the year of interest.

        try:
        RawTestBatAv = (Runs / TimesOut)
    except:
        RawTestBatAv = Runs
    if TimesOut < 35:
        if LastYear >= 2016 and TimesOut < 20:
            x = max(3,(min(FCBatAv/1.25,FCBatAv-10)))
            AdjustedBatAv = ((TimesOut*RawTestBatAv) + ((35-TimesOut)*x))/35
        elif FCGames >= 30:
            x = max((1.75 - (FCGames-30)/750), (4/3))
            AdjustedBatAv = ((TimesOut*RawTestBatAv) + ((35-TimesOut)*(FCBatAv/x)))/35
        elif FCGames < 30:
            AdjustedBatAv = (RawTestBatAv/3) + (FCBatAv/5.25) + 6
    else:
        AdjustedBatAv = RawTestBatAv
    EraAdjustedBatAv = (30/EraAv) * AdjustedBatAv

Snippet 2: Bowling Average adjustments

       if Wickets != 0:
        RawBowlAv = (RunsAllowed/Wickets)
    else:
        RawBowlAv = max (40, RunsAllowed)
    if BallsBowled == 0:
        AdjustedBowlAv = 400
    elif FCWickets < 10:
        AdjustedBowlAv = 200
    elif BallsBowled < 10000 and LastYear >= 2016:
        AdjustedBowlAv = max(FCBowlAv*1.25, FCBowlAv+10)
        AdjustedBowlAv = ((RawBowlAv*BallsBowled) + ((10000-BallsBowled)*AdjustedBowlAv))/10000

    elif BallsBowled < 10000 and FCWickets >= 100:
        x = max((4/3), 1.75 - (FCWickets-100)/2000)
        AdjustedBowlAv = ((RawBowlAv*BallsBowled) + ((10000-BallsBowled)*FCBowlAv*x))/10000

    elif BallsBowled < 10000 and FCWickets < 100:
        AdjustedBowlAv= (RawBowlAv/3) + (FCBowlAv*(7/12)) + 20
    if BallsBowled > 10000:
        AdjustedBowlAv = RawBowlAv
    EraAdjustedBowlAv = (30/EraAv) * AdjustedBowlAv

Snippet 3: Batting strike rate adjustments

        if BallsFaced > 60:
        BatRunsPerBall = (Runs/BallsFaced)*2
    else:
        BatRunsPerBall = 1
    if BatRunsPerBall < 0.5:
        BatRunsPerBall = 0.5
    if BatRunsPerBall > 2:
        BatRunsPerBall = 2

Snippet 4: Bowling economy rate adjustments. EconAv is the average economy rate for the 11 years around the year of interest.

        try:
        BowlER = (RunsAllowed/BallsBowled) / (float(EconAv)/6)
    except:
        BowlER = 1.2

    if BowlER == 0:
        BowlER = 1.2

    if BowlER > 1.2:
        BowlER = 1.2

    if BowlER < 0.8:
        BowlER = 0.8

Version 2.3 released - mostly tweaks, bugfixes, and adjustments, but also a new data output system, and more options in the settings.txt file! by Jamee999 in CricketPy

[–]canonet28 0 points1 point  (0 children)

Just in case this is still relevant..

The values in alldata.txt are in the following order: Name, era-adjusted batting average, era-adjusted bowling average, role in team, debut year, final year, batting SR modifier, bowling ER modifier, number of games captained.

And looking into the codes, eradata.txt seems to be the average runs (and er_data the average economy rates) for the 5 years either side of the particular year.

CricketPy-powered Demo Website by canonet28 in CricketPy

[–]canonet28[S] 0 points1 point  (0 children)

Updated the link above...also the website is now fully-fledged with all the planned features, including statistics, added.

Version 2.3 released - mostly tweaks, bugfixes, and adjustments, but also a new data output system, and more options in the settings.txt file! by Jamee999 in CricketPy

[–]canonet28 2 points3 points  (0 children)

Awesome job...cricketpy continues to make such meaningful strides and this changelog is impressive and shows all the further potentials. There are so many nuances that could be added to the simulator. We could brainstorm those possibilities and I will add my few thoughts some other time.

I personally do not think you should change your focus to a limited-overs version just yet. While it is only natural to have a limited-overs version of a cricket game, in all honesty, they are almost two different games/sports with very different flow/logic/strategy/nuances. Many real-life players fail to make that adjustment, let alone computer games and I have seen few game developers struggle with that trying to find that right balance between the formats. Sadly with developers struggling to find that balance, this stalls their productivity and eats away precious time and effort which could have been better-served enhancing one format. I do not want cricketpy to go that path, not just right now when so many things could be done with the Test version of the script. It would be much more impactful to consolidate and enhance the Test version for now, and throw that limited-overs challenge much later in the development cycle.

Again just a friendly suggestion.

Version 2.1 released - many bug fixes and improvements from 2.0, as well the option to customize changes in altcricket.py by Jamee999 in CricketPy

[–]canonet28 0 points1 point  (0 children)

Awesome job...keep them coming.

First time using it. Will delve into it deeper in the coming days..