Wednesday, July 19, 2023

0000 0000 1100 1101

It's so slow you can hear crickets!

Seeed Studios may be regretting sending little XIAO modules to me!

I started with the XIAO ESP32C3 which I thought would be great to run a 6502 emulator, taking this marvellous piece of 21 century technology back to 1976 - for some reason (art?).

The next victim module was the XIAO ESP32S3 which, comically (I think), ended up in the bin...

What insanity awaits the RP2040 version of this series?

Well it's Ashes time in the cricket world, so I thought I'd tweak some python code I wrote in 2013 to make a sort of high speed fantasy Ashes series.

Here's the code:

import random, time

Australia = ["Pat Cummins", "Scott Boland", "Alex Carey", "Cameron Green", "Marcus Harris", "Josh Hazlewood", "Travis Head", "Usman Khawaja", "Marnus Labuschagne", "Nathan Lyon", "Josh Inglis", "Todd Murphy", "Steve Smith", "Mitchell Starc", "David Warner", "Mitch Marsh", "Matt Renshaw"]

England = ["Ben Stokes", "James Anderson", "Jonny Bairstow", "Stuart Broad", "Harry Brook", "Zak Crawley", "Ben Duckett", "Dan Lawrence", "Moeen Ali", "Ollie Pope", "Ollie Robinson", "Joe Root", "Josh Tongue", "Chris Woakes", "Mark Wood"]

India = ["Rohit Sharma", "Virat Kohli", "Axar Patel", "Hardik Pandya", "Ishan Kishan", "KL Rahul", "Kuldeep Yadav", "Md. Shami", "Md. Siraj", "R Ashwin", "Ravindra Jadeja", "Sanju Samson", "Shardul Thakur", "Shubhman Gill", "Suryakumar Yadav", "Yashasvi Jaiswal", "Mukesh Kumar"]

NewZealand = ["Kane Williamson", "Tim Southee", "Ish Sodhi", "Mitchell Santner", "Glenn Phillips", "Jimmy Neesham", "Daryl Mitchell", "Adam Milne", "Martin Guptill", "Lockie Ferguson", "Devon Conway", "Mark Chapman", "Michael Bracewell", "Trent Boult", "Finn Allen"]

Pakistan = ["Babar Azam", "Mohammad Rizwan", "Fakhar Zaman", "Haris Sohail", "Imam-ul-Haq", "Shan Masood", "Shadab khan", "Muhammad Nawaz", "Haris Rauf", "Shaheen Afridi", "Mohammad Wasim", "Tayyab Tahir", "Abbas Afridi", "Mohammad Wasim", "Naseem Shah"]

SouthAfrica = ["Kane Williamson", "Tim Southee", "Ish Sodhi", "Mitchell Santner", "Glenn Phillips", "Jimmy Neesham", "Daryl Mitchell", "Adam Milne", "Martin Guptill", "Lockie Ferguson", "Devon Conway", "Mark Chapman", "Michael Bracewell", "Trent Boult", "Finn Allen"]

SriLanka = ["Dasun Shanaka", "Kusal Mendis", "Dimuth Karunaratne", "Pathum Nissanka", "Charith Asalanka", "Dhananjaya de Silva", "Sadeera Samarawickrama", "Wanindu Hasaranga", "Chamika Karunaratne", "Dushmantha Chameera", "Kasun Rajitha", "Lahiru Kumara", "Maheesh Theekshana", "Matheesha Pathirana", "Dushan Hemantha"]

WestIndies = ["Shai Hope", "Rovman Powell", "Shamarh Brooks", "Yannic Cariah", "Keacy Carty", "Johnson Charles", "Roston Chase", "Jason Holder", "Akeal Hosein", "Alzarri Joseph", "Brandon King", "Kyle Mayers", "Keemo Paul", "Nicholas Pooran", "Romario Shepherd"]

num_of_teams = [1,2,3,4,5,6,7,8]
Bat = 0
print("Choose batting team from: ")
while(Bat not in num_of_teams):
    print("1. Australia")
    print("2. England")
    print("3. India")
    print("4. New Zealand")
    print("5. Pakistan")
    print("6. South Africa")
    print("7. Sri Lanka")
    print("8. West Indies")
    Bat = int(input("Batting First? "))

if Bat == 1:
    T1 = Australia
    T1_name = "Australia"
elif Bat == 2:
    T1 = England
    T1_name = "England"
elif Bat == 3:
    T1 = India
    T1_name = "India"
elif Bat == 4:
    T1 = NewZealand
    T1_name = "New Zealand"
elif Bat == 5:
    T1 = Pakistan
    T1_name = "Pakistan"
elif Bat == 6:
    T1 = SouthAfrica
    T1_name = "South Africa"
elif Bat == 7:
    T1 = SriLanka
    T1_name = "Sri Lanka"
elif Bat == 8:
    T1 = WestIndies
    T1_name = "West Indies"
else:
    T1 = Australia
    T1_name = "Australia"

print("Batting Team: ",T1_name);


Bowl = 0
print("Choose bowling team from: ")
while(Bowl not in num_of_teams):
    print("1. Australia")
    print("2. England")
    print("3. India")
    print("4. New Zealand")
    print("5. Pakistan")
    print("6. South Africa")
    print("7. Sri Lanka")
    print("8. West Indies")
    Bowl = int(input("Bowling First? "))

if Bowl == 1:
    T2 = Australia
    T2_name = "Australia"
elif Bowl == 2:
    T2 = England
    T2_name = "England"
elif Bowl == 3:
    T2 = India
    T2_name = "India"
elif Bowl == 4:
    T2 = NewZealand
    T2_name = "New Zealand"
elif Bowl == 5:
    T2 = Pakistan
    T2_name = "Pakistan"
elif Bowl == 6:
    T2 = SouthAfrica
    T2_name = "South Africa"
elif Bowl == 7:
    T2 = SriLanka
    T2_name = "Sri Lanka"
elif Bowl == 8:
    T2 = WestIndies
    T2_name = "West Indies"
else:
    T2 = Australia
    T2_name = "Australia"

print("Bowling Team: ",T2_name);

how_many_games = int(input("How many games to play? "))
maxovers = int(input("How many overs per game? "))
bowler_max = int(input("Maximum overs per bowler? "))
time_delay = True # False for testing
# in seconds, but will take e.g. 0.400 as 400 milliseconds
time_sleep = float(input("How many seconds between balls? "))

class Teamclass():
    pass

def random_shuffle(seq):
    l = len(seq)
    for i in range(l):
        j = random.randrange(l)
        seq[i], seq[j] = seq[j], seq[i]

def maketeam(team, from_pool, name):
    team.name = name
    team.members = []
    team.out = 0
    team.score = 0
    team.balls_batted = 0
    team.balls_bowled = 0
    team.batextras = 0
    team.bowlextras = 0
    current_pool = list(from_pool) # make a copy so we don't exhaust the list by popping too many players over multiple games
    for players in range(1,12):
        random_shuffle(current_pool)
        team.members.append([players,current_pool.pop(),0,0,"not out",0,0,0])
        #number, name,runs,balls faced, how out, balls bowled, wickets taken, runs against

def throwdie(): # throw two dice
    return (random.randint(1,6) + random.randint(1,6))

def printscore(team):
    team.members.sort()
    print("")
    print(team.name,"Scorecard")
    print("")
    for teamnum in range(len(team.members)):
        print("{0:20}{1:22}".format(team.members[teamnum][1],team.members[teamnum][4]),team.members[teamnum][2],"("+str(team.members[teamnum][3])+")")
    print("{0:42}".format("Extras"),team.batextras)
    print("")
    if team.out == 10:
        print("All out for", team.score)
    else:
        print("Total",team.out,"for",team.score)

def bowlingfigures(team):
    team.members.sort()
    print("Bowling")
    print("")
    for teamnum in range(5,11):
        print("{0:18}".format(team.members[teamnum][1]),str(team.members[teamnum][6])+"/"+str(team.members[teamnum][7])+" ("+str(team.members[teamnum][5])+")")

def card(batting, bowling):
    print("")
    printscore(batting)
    print("")
    bowlingfigures(bowling)
    print("")
def innings(batting, bowling, score_to_beat):
    bowlers = bowling.members[5:11]
    bowler = bowlers[0]
    illegal = False
    while ((batting.out < 10) and (batting.score<=score_to_beat) and (bowling.balls_bowled+1<=maxovers*6)):
        if bowling.balls_bowled%6 == 0 and illegal == False:
            random_shuffle(bowlers)
            newbowler = bowlers[0]
            while newbowler == bowler or ((newbowler[5]/6)==bowler_max):
                random_shuffle(bowlers)
                newbowler = bowlers[0]
            bowler = newbowler
            batting.members[0], batting.members[1] = batting.members[1], batting.members[0]
            startover_score = batting.score
            print("")
            print("Over",bowling.balls_bowled/6+1,"Bowler:",bowler[1],str(bowler[6])+"/"+str(bowler[7])," ("+str(bowler[5]/6),"overs)")
        print("Ball",bowling.balls_bowled%6+1, batting.members[0][1],str(batting.members[0][2])+"("+str(batting.members[0][3])+"),",batting.members[1][1],str(batting.members[1][2])+"("+str(batting.members[1][3])+") ["+str(batting.out)+"/"+str(batting.score)+"]", end=' ')
        # is it a legal delivery?
        if time_delay:
            time.sleep(time_sleep)
        legal = throwdie()
        appeal = throwdie()
        dismissal = throwdie()
        fielded = str(bowling.members[random.randint(0,10)][1]).split()[-1]
        ball = throwdie()
        if legal == 2: # 3% chance
            typeball = throwdie()
            batting.score += 1
            batting.batextras += 1
            batting.bowlextras += 1
            bowler[7] += 1
            illegal = True
            if typeball > 51:
                print("Wide ball!")
            else:
                print("No ball!")
        else:
            bowling.balls_bowled += 1
            batting.balls_batted += 1
            batting.members[0][3] += 1
            bowler[5] += 1
            illegal = False
            if (ball == 3) or (ball == 4):
                reportappeal = "Appeal for "
                if time_delay:
                    time.sleep(time_sleep)
                if (appeal < 5):
                    catcher = random.randint(0,11)
                    howout = "caught "+fielded+" (b. "+str(bowler[1].split()[-1])+")"
                    if (dismissal < 10):
                        result = " Out!"
                        if fielded == str(bowler[1]).split()[1]:
                            report = "c&b"+" ("+str(bowler[1]).split()[-1]+")"
                        else:
                            report = "c."+fielded+" b."+str(bowler[1]).split()[-1]
                        bowler[6] += 1
                        batting.members[0][4] = report
                        batting.out += 1
                        if batting.out == 10:
                            pass
                        else:
                            batting.members[0],batting.members[batting.out+1] = batting.members[batting.out+1], batting.members[0]
                    else:
                        result = " Not out!"
                elif (appeal < 7):
                    howout = "bowled"
                    result = "! Out!"
                    bowler[6] += 1
                    batting.members[0][4] = howout+"("+str(bowler[1]).split()[-1]+")"
                    batting.out += 1
                    if batting.out == 10:
                        pass
                    else:
                        batting.members[0],batting.members[batting.out+1] = batting.members[batting.out+1], batting.members[0]
                elif (appeal < 10):
                    howout = "lbw"
                    if (dismissal < 6):
                        result =  ".  Out!"
                        bowler[6] += 1
                        batting.members[0][4] = howout+" ("+str(bowler[1]).split()[-1]+")"
                        batting.out += 1
                        if batting.out == 10:
                            pass
                        else:
                            batting.members[0],batting.members[batting.out+1] = batting.members[batting.out+1], batting.members[0]
                    else:
                        result =  ".  Not out!"
                else:
                    howout = "run out"
                    whichrun = throwdie()
                    # if whichrun < 3: #to work out how many and who goes!
                    if (dismissal < 6):
                        result =  ". Out! ("+fielded+")"
                        if (throwdie()<7): # which end?
                            batting.members[0], batting.members[1] = batting.members[1], batting.members[0]
                        batting.members[0][4] = howout+" ("+fielded+")"
                        batting.out += 1
                        if batting.out == 10:
                            pass
                        else:
                            batting.members[0],batting.members[batting.out+1] = batting.members[batting.out+1], batting.members[0]
                    else:
                        result =  ". Not out!"
                print(reportappeal+howout+result)
            elif (ball == 2):
                print("3 scored ("+fielded+")")
                batting.score += 3
                batting.members[0][2] += 3
                batting.members[0], batting.members[1] = batting.members[1], batting.members[0]
                bowler[7] += 3
            elif (ball == 6) or (11<=ball<=12):
                print("1 scored ("+fielded+")")
                batting.score += 1
                batting.members[0][2] += 1
                batting.members[0], batting.members[1] = batting.members[1], batting.members[0]
                bowler[7] += 1
            elif (ball == 5):
                print("2 scored ("+fielded+")")
                batting.score += 2
                batting.members[0][2] += 2
                bowler[7] += 2
            elif (ball == 7):
                print("0 scored")
            elif (ball == 10):
                print("6 scored ("+fielded+")")
                batting.score += 6
                batting.members[0][2] += 6
                bowler[7] += 6
            else:
                print("4 scored ("+fielded+")")
                batting.score += 4
                batting.members[0][2] += 4
                bowler[7] += 4
            overs = (int(batting.balls_batted/6)+float((batting.balls_batted%6)/6.0))
            if ((batting.out < 10) and (batting.score<=score_to_beat) and (bowling.balls_bowled+1<=maxovers*6)):
                if ((score_to_beat-batting.score)>40) and overs>1:
                    if score_to_beat == 9999:
                        
                        print("Run rate:", "{0:.2f}".format(float((batting.score)/overs)))
                    else:
                        print("Run rate:", "{0:.2f}".format(float((batting.score)/overs))," Required:","{0:.2f}".format((float(bowling.score)+1-float(batting.score))/(maxovers-overs)))
                elif overs>1:
                    print("Required:",bowling.score+1-batting.score,"from",maxovers*6-bowling.balls_bowled)
            if bowling.balls_bowled%6 == 0:
                print("Over produced:",batting.score-startover_score,"Score: ("+str(batting.out)+"/"+str(batting.score)+")")

def games():
    if time_delay:
        time.sleep(time_sleep)
    T1_wins = 0
    T2_wins = 0
    Total_T1_runs = 0
    Total_T2_runs = 0
    playgames = how_many_games
    for numgames in range(1,playgames+1):
        print("")
        print("New Game")
        Bat1 = Teamclass()
        Bowl1 = Teamclass()
        maketeam(Bat1, T1, T1_name)
        maketeam(Bowl1, T2, T2_name)
        printscore(Bat1)
        if time_delay:
            input("Press Enter to continue...")
        if time_delay:
            time.sleep(time_sleep)
        innings(Bat1, Bowl1, 9999)
        card(Bat1, Bowl1)
        if time_delay:
            input("Press Enter to continue...")
        if time_delay:
            time.sleep(time_sleep)
        printscore(Bowl1)
        if time_delay:
            input("Press Enter to continue...")
        if time_delay:
            time.sleep(time_sleep)
        innings(Bowl1, Bat1, Bat1.score)
        card(Bowl1,Bat1)
        if time_delay:
            input("Press Enter to continue...")
        if time_delay:
            time.sleep(time_sleep)
        Total_T1_runs += Bat1.score
        Total_T2_runs += Bowl1.score
        if Bat1.score>Bowl1.score:
            print(T1_name,"("+str(Bat1.out)+"/"+str(Bat1.score)+") beat",T2_name,"("+str(Bowl1.out)+"/"+str(Bowl1.score)+")")
            T1_wins += 1
        elif Bat1.score<Bowl1.score:
            print(T2_name,"("+str(Bowl1.out)+"/"+str(Bowl1.score)+") beat",T1_name,"("+str(Bat1.out)+"/"+str(Bat1.score)+")")
            T2_wins += 1
        else:
            print(T1_name," ("+str(Bat1.out)+"/"+str(Bat1.score)+") drew",T2_name,"("+str(Bowl1.out)+"/"+str(Bowl1.score)+")")
    return T1_wins, T2_wins, Total_T1_runs, Total_T2_runs, playgames

AW, OW, TAR, TOR, TG = games()

print("")
print("Overall analysis")
print("Games played:",TG)
print(T1_name,"wins:",AW)
print(T2_name,"wins:",OW)
print("Draws:",(TG-(OW+AW)))
print("Average",T1_name,"Score:","{0:.2f}".format(float(TAR)/float(TG)))
print("Average",T2_name,"Score:","{0:.2f}".format(float(TOR)/float(TG)))

Can we play a simulated game of cricket (invented circa 1611) using code conjured up by a math teacher in 2013 to engage his students, on a tasty bit of RP2040 kit by Seeed Studios in 2023?

Catch the video below, and an example game below that - you be the judge!


Choose batting team from: 
1. Australia
2. England
3. India
4. New Zealand
5. Pakistan
6. South Africa
7. Sri Lanka
8. West Indies
Batting First? 1
Batting Team:  Australia
Choose bowling team from: 
1. Australia
2. England
3. India
4. New Zealand
5. Pakistan
6. South Africa
7. Sri Lanka
8. West Indies
Bowling First? 2
Bowling Team:  England
How many games to play? 1
How many overs per game? 20
Maximum overs per bowler? 4
How many seconds between balls? 0.1

New Game

Australia Scorecard

Steve Smith         not out                0 (0)
Nathan Lyon         not out                0 (0)
David Warner        not out                0 (0)
Mitchell Starc      not out                0 (0)
Todd Murphy         not out                0 (0)
Josh Inglis         not out                0 (0)
Scott Boland        not out                0 (0)
Pat Cummins         not out                0 (0)
Cameron Green       not out                0 (0)
Usman Khawaja       not out                0 (0)
Alex Carey          not out                0 (0)
Extras                                     0

Total 0 for 0
Press Enter to continue...

Over 1.0 Bowler: Stuart Broad 0/0  (0.0 overs)
Ball 1 Nathan Lyon 0(0), Steve Smith 0(0) [0/0] 2 scored (Broad)
Ball 2 Nathan Lyon 2(1), Steve Smith 0(0) [0/2] 4 scored (Broad)
Ball 3 Nathan Lyon 6(2), Steve Smith 0(0) [0/6] 4 scored (Woakes)
Ball 4 Nathan Lyon 10(3), Steve Smith 0(0) [0/10] 0 scored
Ball 5 Nathan Lyon 10(4), Steve Smith 0(0) [0/10] Appeal for lbw.  Not out!
Ball 6 Nathan Lyon 10(5), Steve Smith 0(0) [0/10] 0 scored
Over produced: 10 Score: (0/10)

Over 2.0 Bowler: James Anderson 0/0  (0.0 overs)
Ball 1 Steve Smith 0(0), Nathan Lyon 10(6) [0/10] 0 scored
Run rate: 8.57
Ball 2 Steve Smith 0(1), Nathan Lyon 10(6) [0/10] 0 scored
Run rate: 7.50
Ball 3 Steve Smith 0(2), Nathan Lyon 10(6) [0/10] 4 scored (Bairstow)
Run rate: 9.33
Ball 4 Steve Smith 4(3), Nathan Lyon 10(6) [0/14] 3 scored (Woakes)
Run rate: 10.20
Ball 5 Nathan Lyon 10(6), Steve Smith 7(4) [0/17] 0 scored
Run rate: 9.27
Ball 6 Nathan Lyon 10(7), Steve Smith 7(4) [0/17] Appeal for bowled! Out!
Run rate: 8.50
Over produced: 7 Score: (1/17)

Over 3.0 Bowler: Ben Stokes 0/0  (0.0 overs)
Ball 1 Steve Smith 7(4), David Warner 0(0) [1/17] 0 scored
Run rate: 7.85
Ball 2 Steve Smith 7(5), David Warner 0(0) [1/17] 4 scored (Woakes)
Run rate: 9.00
Ball 3 Steve Smith 11(6), David Warner 0(0) [1/21] 4 scored (Root)
Run rate: 10.00
Ball 4 Steve Smith 15(7), David Warner 0(0) [1/25] 6 scored (Stokes)
Run rate: 11.63
Ball 5 Steve Smith 21(8), David Warner 0(0) [1/31] 2 scored (Root)
Run rate: 11.65
Ball 6 Steve Smith 23(9), David Warner 0(0) [1/33] 2 scored (Anderson)
Run rate: 11.67
Over produced: 18 Score: (1/35)

Over 4.0 Bowler: James Anderson 1/7  (1.0 overs)
Ball 1 David Warner 0(0), Steve Smith 25(10) [1/35] 6 scored (Ali)
Run rate: 12.95
Ball 2 David Warner 6(1), Steve Smith 25(10) [1/41] 4 scored (Tongue)
Run rate: 13.50
Ball 3 David Warner 10(2), Steve Smith 25(10) [1/45] 4 scored (Bairstow)
Run rate: 14.00
Ball 4 David Warner 14(3), Steve Smith 25(10) [1/49] 4 scored (Woakes)
Run rate: 14.45
Ball 5 David Warner 18(4), Steve Smith 25(10) [1/53] 1 scored (Robinson)
Run rate: 14.09
Ball 6 Steve Smith 25(10), David Warner 19(5) [1/54] 2 scored (Root)
Run rate: 14.00
Over produced: 21 Score: (1/56)

Over 5.0 Bowler: Stuart Broad 0/10  (1.0 overs)
Ball 1 David Warner 19(5), Steve Smith 27(11) [1/56] 6 scored (Tongue)
Run rate: 14.88
Ball 2 David Warner 25(6), Steve Smith 27(11) [1/62] No ball!
Ball 2 David Warner 25(6), Steve Smith 27(11) [1/63] 2 scored (Woakes)
Run rate: 15.00
Ball 3 David Warner 27(7), Steve Smith 27(11) [1/65] Appeal for run out. Out! (Anderson)
Run rate: 14.44
Ball 4 Mitchell Starc 0(0), David Warner 27(8) [2/65] 1 scored (Bairstow)
Run rate: 14.14
Ball 5 David Warner 27(8), Mitchell Starc 1(1) [2/66] 4 scored (Root)
Run rate: 14.48
Ball 6 David Warner 31(9), Mitchell Starc 1(1) [2/70] 1 scored (Anderson)
Run rate: 14.20
Over produced: 15 Score: (2/71)

Over 6.0 Bowler: Moeen Ali 0/0  (0.0 overs)
Ball 1 David Warner 32(10), Mitchell Starc 1(1) [2/71] 2 scored (Anderson)
Run rate: 14.13
Ball 2 David Warner 34(11), Mitchell Starc 1(1) [2/73] 4 scored (Broad)
Run rate: 14.44
Ball 3 David Warner 38(12), Mitchell Starc 1(1) [2/77] 1 scored (Lawrence)
Run rate: 14.18
Ball 4 Mitchell Starc 1(1), David Warner 39(13) [2/78] 0 scored
Run rate: 13.76
Ball 5 Mitchell Starc 1(2), David Warner 39(13) [2/78] 1 scored (Lawrence)
Run rate: 13.54
Ball 6 David Warner 39(13), Mitchell Starc 2(3) [2/79] Appeal for caught Robinson (b. Ali) Out!
Run rate: 13.17
Over produced: 8 Score: (3/79)

Over 7.0 Bowler: Ben Stokes 0/18  (1.0 overs)
Ball 1 Mitchell Starc 2(3), Todd Murphy 0(0) [3/79] 2 scored (Root)
Run rate: 13.14
Ball 2 Mitchell Starc 4(4), Todd Murphy 0(0) [3/81] 4 scored (Tongue)
Run rate: 13.42
Ball 3 Mitchell Starc 8(5), Todd Murphy 0(0) [3/85] 6 scored (Brook)
Run rate: 14.00
Ball 4 Mitchell Starc 14(6), Todd Murphy 0(0) [3/91] Appeal for caught Lawrence (b. Stokes) Not out!
Run rate: 13.65
Ball 5 Mitchell Starc 14(7), Todd Murphy 0(0) [3/91] 0 scored
Run rate: 13.32
Ball 6 Mitchell Starc 14(8), Todd Murphy 0(0) [3/91] 6 scored (Anderson)
Run rate: 13.86
Over produced: 18 Score: (3/97)

Over 8.0 Bowler: Stuart Broad 0/25  (2.0 overs)
Ball 1 Todd Murphy 0(0), Mitchell Starc 20(9) [3/97] 2 scored (Bairstow)
Run rate: 13.81
Ball 2 Todd Murphy 2(1), Mitchell Starc 20(9) [3/99] 6 scored (Stokes)
Run rate: 14.32
Ball 3 Todd Murphy 8(2), Mitchell Starc 20(9) [3/105] 4 scored (Anderson)
Run rate: 14.53
Ball 4 Todd Murphy 12(3), Mitchell Starc 20(9) [3/109] 4 scored (Anderson)
Run rate: 14.74
Ball 5 Todd Murphy 16(4), Mitchell Starc 20(9) [3/113] 1 scored (Brook)
Run rate: 14.55
Ball 6 Mitchell Starc 20(9), Todd Murphy 17(5) [3/114] No ball!
Ball 6 Mitchell Starc 20(9), Todd Murphy 17(5) [3/115] 6 scored (Anderson)
Run rate: 15.13
Over produced: 24 Score: (3/121)

Over 9.0 Bowler: James Anderson 1/28  (2.0 overs)
Ball 1 Todd Murphy 17(5), Mitchell Starc 26(10) [3/121] 4 scored (Lawrence)
Run rate: 15.31
Ball 2 Todd Murphy 21(6), Mitchell Starc 26(10) [3/125] 4 scored (Ali)
Run rate: 15.48
Ball 3 Todd Murphy 25(7), Mitchell Starc 26(10) [3/129] 0 scored
Run rate: 15.18
Ball 4 Todd Murphy 25(8), Mitchell Starc 26(10) [3/129] 1 scored (Root)
Run rate: 15.00
Ball 5 Mitchell Starc 26(10), Todd Murphy 26(9) [3/130] 1 scored (Brook)
Run rate: 14.83
Ball 6 Todd Murphy 26(9), Mitchell Starc 27(11) [3/131] 4 scored (Lawrence)
Run rate: 15.00
Over produced: 14 Score: (3/135)

Over 10.0 Bowler: Ben Stokes 0/36  (2.0 overs)
Ball 1 Mitchell Starc 27(11), Todd Murphy 30(10) [3/135] 4 scored (Robinson)
Run rate: 15.16
Ball 2 Mitchell Starc 31(12), Todd Murphy 30(10) [3/139] 6 scored (Root)
Run rate: 15.54
Ball 3 Mitchell Starc 37(13), Todd Murphy 30(10) [3/145] Appeal for lbw.  Not out!
Run rate: 15.26
Ball 4 Mitchell Starc 37(14), Todd Murphy 30(10) [3/145] Appeal for caught Tongue (b. Stokes) Out!
Run rate: 15.00
Ball 5 Josh Inglis 0(0), Todd Murphy 30(10) [4/145] No ball!
Ball 5 Josh Inglis 0(0), Todd Murphy 30(10) [4/146] 4 scored (Bairstow)
Run rate: 15.25
Ball 6 Josh Inglis 4(1), Todd Murphy 30(10) [4/150] 4 scored (Anderson)
Run rate: 15.40
Over produced: 19 Score: (4/154)

Over 11.0 Bowler: Josh Tongue 0/0  (0.0 overs)
Ball 1 Todd Murphy 30(10), Josh Inglis 8(2) [4/154] 1 scored (Root)
Run rate: 15.25
Ball 2 Josh Inglis 8(2), Todd Murphy 31(11) [4/155] 0 scored
Run rate: 15.00
Ball 3 Josh Inglis 8(3), Todd Murphy 31(11) [4/155] 3 scored (Broad)
Run rate: 15.05
Ball 4 Todd Murphy 31(11), Josh Inglis 11(4) [4/158] 2 scored (Robinson)
Run rate: 15.00
Ball 5 Todd Murphy 33(12), Josh Inglis 11(4) [4/160] 0 scored
Run rate: 14.77
Ball 6 Todd Murphy 33(13), Josh Inglis 11(4) [4/160] 0 scored
Run rate: 14.55
Over produced: 6 Score: (4/160)

Over 12.0 Bowler: Harry Brook 0/0  (0.0 overs)
Ball 1 Josh Inglis 11(4), Todd Murphy 33(14) [4/160] 1 scored (Broad)
Run rate: 14.42
Ball 2 Todd Murphy 33(14), Josh Inglis 12(5) [4/161] 1 scored (Tongue)
Run rate: 14.29
Ball 3 Josh Inglis 12(5), Todd Murphy 34(15) [4/162] 0 scored
Run rate: 14.09
Ball 4 Josh Inglis 12(6), Todd Murphy 34(15) [4/162] 1 scored (Stokes)
Run rate: 13.97
Ball 5 Todd Murphy 34(15), Josh Inglis 13(7) [4/163] Appeal for lbw.  Not out!
Run rate: 13.77
Ball 6 Todd Murphy 34(16), Josh Inglis 13(7) [4/163] 2 scored (Broad)
Run rate: 13.75
Over produced: 5 Score: (4/165)

Over 13.0 Bowler: James Anderson 1/42  (3.0 overs)
Ball 1 Josh Inglis 13(7), Todd Murphy 36(17) [4/165] 0 scored
Run rate: 13.56
Ball 2 Josh Inglis 13(8), Todd Murphy 36(17) [4/165] 4 scored (Lawrence)
Run rate: 13.70
Ball 3 Josh Inglis 17(9), Todd Murphy 36(17) [4/169] 1 scored (Bairstow)
Run rate: 13.60
Ball 4 Todd Murphy 36(17), Josh Inglis 18(10) [4/170] 6 scored (Woakes)
Run rate: 13.89
Ball 5 Todd Murphy 42(18), Josh Inglis 18(10) [4/176] 1 scored (Broad)
Run rate: 13.79
Ball 6 Josh Inglis 18(10), Todd Murphy 43(19) [4/177] 1 scored (Robinson)
Run rate: 13.69
Over produced: 13 Score: (4/178)

Over 14.0 Bowler: Stuart Broad 0/49  (3.0 overs)
Ball 1 Josh Inglis 19(11), Todd Murphy 43(19) [4/178] 0 scored
Run rate: 13.52
Ball 2 Josh Inglis 19(12), Todd Murphy 43(19) [4/178] 4 scored (Lawrence)
Run rate: 13.65
Ball 3 Josh Inglis 23(13), Todd Murphy 43(19) [4/182] 1 scored (Woakes)
Run rate: 13.56
Ball 4 Todd Murphy 43(19), Josh Inglis 24(14) [4/183] 0 scored
Run rate: 13.39
Ball 5 Todd Murphy 43(20), Josh Inglis 24(14) [4/183] 6 scored (Root)
Run rate: 13.66
Ball 6 Todd Murphy 49(21), Josh Inglis 24(14) [4/189] 1 scored (Stokes)
Run rate: 13.57
Over produced: 12 Score: (4/190)

Over 15.0 Bowler: Harry Brook 0/5  (1.0 overs)
Ball 1 Todd Murphy 50(22), Josh Inglis 24(14) [4/190] 1 scored (Robinson)
Run rate: 13.48
Ball 2 Josh Inglis 24(14), Todd Murphy 51(23) [4/191] 1 scored (Brook)
Run rate: 13.40
Ball 3 Todd Murphy 51(23), Josh Inglis 25(15) [4/192] 2 scored (Ali)
Run rate: 13.38
Ball 4 Todd Murphy 53(24), Josh Inglis 25(15) [4/194] Appeal for lbw.  Not out!
Run rate: 13.23
Ball 5 Todd Murphy 53(25), Josh Inglis 25(15) [4/194] 0 scored
Run rate: 13.08
Ball 6 Todd Murphy 53(26), Josh Inglis 25(15) [4/194] 1 scored (Stokes)
Run rate: 13.00
Over produced: 5 Score: (4/195)

Over 16.0 Bowler: Ben Stokes 1/55  (3.0 overs)
Ball 1 Todd Murphy 54(27), Josh Inglis 25(15) [4/195] 6 scored (Woakes)
Run rate: 13.25
Ball 2 Todd Murphy 60(28), Josh Inglis 25(15) [4/201] 4 scored (Stokes)
Run rate: 13.37
Ball 3 Todd Murphy 64(29), Josh Inglis 25(15) [4/205] 2 scored (Anderson)
Run rate: 13.35
Ball 4 Todd Murphy 66(30), Josh Inglis 25(15) [4/207] 4 scored (Woakes)
Run rate: 13.47
Ball 5 Todd Murphy 70(31), Josh Inglis 25(15) [4/211] 0 scored
Run rate: 13.33
Ball 6 Todd Murphy 70(32), Josh Inglis 25(15) [4/211] 0 scored
Run rate: 13.19
Over produced: 16 Score: (4/211)

Over 17.0 Bowler: Moeen Ali 1/8  (1.0 overs)
Ball 1 Josh Inglis 25(15), Todd Murphy 70(33) [4/211] 0 scored
Run rate: 13.05
Ball 2 Josh Inglis 25(16), Todd Murphy 70(33) [4/211] Appeal for lbw.  Not out!
Run rate: 12.92
Ball 3 Josh Inglis 25(17), Todd Murphy 70(33) [4/211] 6 scored (Robinson)
Run rate: 13.15
Ball 4 Josh Inglis 31(18), Todd Murphy 70(33) [4/217] 1 scored (Woakes)
Run rate: 13.08
Ball 5 Todd Murphy 70(33), Josh Inglis 32(19) [4/218] 1 scored (Root)
Run rate: 13.01
Ball 6 Josh Inglis 32(19), Todd Murphy 71(34) [4/219] 0 scored
Run rate: 12.88
Over produced: 8 Score: (4/219)

Over 18.0 Bowler: Josh Tongue 0/6  (1.0 overs)
Ball 1 Todd Murphy 71(34), Josh Inglis 32(20) [4/219] 0 scored
Run rate: 12.76
Ball 2 Todd Murphy 71(35), Josh Inglis 32(20) [4/219] 2 scored (Bairstow)
Run rate: 12.75
Ball 3 Todd Murphy 73(36), Josh Inglis 32(20) [4/221] Appeal for bowled! Out!
Run rate: 12.63
Ball 4 Scott Boland 0(0), Josh Inglis 32(20) [5/221] Appeal for lbw.  Not out!
Run rate: 12.51
Ball 5 Scott Boland 0(1), Josh Inglis 32(20) [5/221] 1 scored (Root)
Run rate: 12.45
Ball 6 Josh Inglis 32(20), Scott Boland 1(2) [5/222] 4 scored (Stokes)
Run rate: 12.56
Over produced: 7 Score: (5/226)

Over 19.0 Bowler: Harry Brook 0/10  (2.0 overs)
Ball 1 Scott Boland 1(2), Josh Inglis 36(21) [5/226] Appeal for bowled! Out!
Run rate: 12.44
Ball 2 Pat Cummins 0(0), Josh Inglis 36(21) [6/226] Appeal for bowled! Out!
Run rate: 12.33
Ball 3 Cameron Green 0(0), Josh Inglis 36(21) [7/226] 2 scored (Tongue)
Run rate: 12.32
Ball 4 Cameron Green 2(1), Josh Inglis 36(21) [7/228] 3 scored (Brook)
Run rate: 12.38
Ball 5 Josh Inglis 36(21), Cameron Green 5(2) [7/231] 1 scored (Root)
Run rate: 12.32
Ball 6 Cameron Green 5(2), Josh Inglis 37(22) [7/232] 4 scored (Lawrence)
Run rate: 12.42
Over produced: 10 Score: (7/236)

Over 20.0 Bowler: Moeen Ali 1/16  (2.0 overs)
Ball 1 Josh Inglis 37(22), Cameron Green 9(3) [7/236] 0 scored
Run rate: 12.31
Ball 2 Josh Inglis 37(23), Cameron Green 9(3) [7/236] 4 scored (Woakes)
Run rate: 12.41
Ball 3 Josh Inglis 41(24), Cameron Green 9(3) [7/240] No ball!
Ball 3 Josh Inglis 41(24), Cameron Green 9(3) [7/241] 2 scored (Brook)
Run rate: 12.46
Ball 4 Josh Inglis 43(25), Cameron Green 9(3) [7/243] Appeal for bowled! Out!
Run rate: 12.36
Ball 5 Usman Khawaja 0(0), Cameron Green 9(3) [8/243] 2 scored (Brook)
Run rate: 12.35
Ball 6 Usman Khawaja 2(1), Cameron Green 9(3) [8/245] No ball!
Ball 6 Usman Khawaja 2(1), Cameron Green 9(3) [8/246] 1 scored (Bairstow)
Over produced: 11 Score: (8/247)


Australia Scorecard

Steve Smith         run out (Anderson)     27 (11)
Nathan Lyon         bowled(Anderson)       10 (8)
David Warner        c.Robinson b.Ali       39 (14)
Mitchell Starc      c.Tongue b.Stokes      37 (15)
Todd Murphy         bowled(Tongue)         73 (37)
Josh Inglis         bowled(Ali)            43 (26)
Scott Boland        bowled(Brook)          1 (3)
Pat Cummins         bowled(Brook)          0 (1)
Cameron Green       not out                9 (3)
Usman Khawaja       not out                3 (2)
Alex Carey          not out                0 (0)
Extras                                     5

Total 8 for 247

Bowling

James Anderson     1/55 (24)
Moeen Ali          2/27 (18)
Stuart Broad       0/61 (24)
Josh Tongue        1/13 (12)
Harry Brook        2/20 (18)
Ben Stokes         1/71 (24)

Press Enter to continue...

England Scorecard

Jonny Bairstow      not out                0 (0)
Dan Lawrence        not out                0 (0)
Chris Woakes        not out                0 (0)
Ollie Robinson      not out                0 (0)
Joe Root            not out                0 (0)
James Anderson      not out                0 (0)
Moeen Ali           not out                0 (0)
Stuart Broad        not out                0 (0)
Josh Tongue         not out                0 (0)
Harry Brook         not out                0 (0)
Ben Stokes          not out                0 (0)
Extras                                     0

Total 0 for 0
Press Enter to continue...

Over 1.0 Bowler: Alex Carey 0/0  (0.0 overs)
Ball 1 Dan Lawrence 0(0), Jonny Bairstow 0(0) [0/0] 1 scored (Smith)
Ball 2 Jonny Bairstow 0(0), Dan Lawrence 1(1) [0/1] 0 scored
Ball 3 Jonny Bairstow 0(1), Dan Lawrence 1(1) [0/1] 2 scored (Green)
Ball 4 Jonny Bairstow 2(2), Dan Lawrence 1(1) [0/3] Appeal for lbw.  Not out!
Ball 5 Jonny Bairstow 2(3), Dan Lawrence 1(1) [0/3] Appeal for run out. Out! (Cummins)
Ball 6 Chris Woakes 0(0), Jonny Bairstow 2(4) [1/3] 2 scored (Starc)
Over produced: 5 Score: (1/5)

Over 2.0 Bowler: Usman Khawaja 0/0  (0.0 overs)
Ball 1 Jonny Bairstow 2(4), Chris Woakes 2(1) [1/5] 1 scored (Starc)
Run rate: 5.14  Required: 12.85
Ball 2 Chris Woakes 2(1), Jonny Bairstow 3(5) [1/6] No ball!
Ball 2 Chris Woakes 2(1), Jonny Bairstow 3(5) [1/7] 4 scored (Green)
Run rate: 8.25  Required: 12.70
Ball 3 Chris Woakes 6(2), Jonny Bairstow 3(5) [1/11] 0 scored
Run rate: 7.33  Required: 12.81
Ball 4 Chris Woakes 6(3), Jonny Bairstow 3(5) [1/11] 4 scored (Warner)
Run rate: 9.00  Required: 12.71
Ball 5 Chris Woakes 10(4), Jonny Bairstow 3(5) [1/15] 1 scored (Boland)
Run rate: 8.73  Required: 12.77
Ball 6 Jonny Bairstow 3(5), Chris Woakes 11(5) [1/16] 4 scored (Green)
Run rate: 10.00  Required: 12.67
Over produced: 15 Score: (1/20)

Over 3.0 Bowler: Scott Boland 0/0  (0.0 overs)
Ball 1 Chris Woakes 11(5), Jonny Bairstow 7(6) [1/20] No ball!
Ball 1 Chris Woakes 11(5), Jonny Bairstow 7(6) [1/21] 6 scored (Boland)
Run rate: 12.46  Required: 12.39
Ball 2 Chris Woakes 17(6), Jonny Bairstow 7(6) [1/27] 0 scored
Run rate: 11.57  Required: 12.51
Ball 3 Chris Woakes 17(7), Jonny Bairstow 7(6) [1/27] 2 scored (Murphy)
Run rate: 11.60  Required: 12.51
Ball 4 Chris Woakes 19(8), Jonny Bairstow 7(6) [1/29] 1 scored (Boland)
Run rate: 11.25  Required: 12.58
Ball 5 Jonny Bairstow 7(6), Chris Woakes 20(9) [1/30] 4 scored (Carey)
Run rate: 12.00  Required: 12.47
Ball 6 Jonny Bairstow 11(7), Chris Woakes 20(9) [1/34] Appeal for bowled! Out!
Run rate: 11.33  Required: 12.59
Over produced: 14 Score: (2/34)

Over 4.0 Bowler: Pat Cummins 0/0  (0.0 overs)
Ball 1 Chris Woakes 20(9), Ollie Robinson 0(0) [2/34] 0 scored
Run rate: 10.74  Required: 12.71
Ball 2 Chris Woakes 20(10), Ollie Robinson 0(0) [2/34] 1 scored (Starc)
Run rate: 10.50  Required: 12.78
Ball 3 Ollie Robinson 0(0), Chris Woakes 21(11) [2/35] Appeal for bowled! Out!
Run rate: 10.00  Required: 12.91
Ball 4 Joe Root 0(0), Chris Woakes 21(11) [3/35] Appeal for lbw.  Not out!
Run rate: 9.55  Required: 13.04
Ball 5 Joe Root 0(1), Chris Woakes 21(11) [3/35] 4 scored (Green)
Run rate: 10.17  Required: 12.93
Ball 6 Joe Root 4(2), Chris Woakes 21(11) [3/39] 0 scored
Run rate: 9.75  Required: 13.06
Over produced: 5 Score: (3/39)

Over 5.0 Bowler: Josh Inglis 0/0  (0.0 overs)
Ball 1 Chris Woakes 21(11), Joe Root 4(3) [3/39] 0 scored
Run rate: 9.36  Required: 13.20
Ball 2 Chris Woakes 21(12), Joe Root 4(3) [3/39] 3 scored (Murphy)
Run rate: 9.69  Required: 13.15
Ball 3 Joe Root 4(3), Chris Woakes 24(13) [3/42] 4 scored (Starc)
Run rate: 10.22  Required: 13.03
Ball 4 Joe Root 8(4), Chris Woakes 24(13) [3/46] Appeal for lbw.  Not out!
Run rate: 9.86  Required: 13.17
Ball 5 Joe Root 8(5), Chris Woakes 24(13) [3/46] Appeal for lbw.  Not out!
Run rate: 9.52  Required: 13.32
Ball 6 Joe Root 8(6), Chris Woakes 24(13) [3/46] 4 scored (Inglis)
Run rate: 10.00  Required: 13.20
Over produced: 11 Score: (3/50)

Over 6.0 Bowler: Alex Carey 0/5  (1.0 overs)
Ball 1 Chris Woakes 24(13), Joe Root 12(7) [3/50] Appeal for run out. Not out!
Run rate: 9.68  Required: 13.35
Ball 2 Chris Woakes 24(14), Joe Root 12(7) [3/50] 0 scored
Run rate: 9.38  Required: 13.50
Ball 3 Chris Woakes 24(15), Joe Root 12(7) [3/50] 3 scored (Inglis)
Run rate: 9.64  Required: 13.45
Ball 4 Joe Root 12(7), Chris Woakes 27(16) [3/53] 1 scored (Boland)
Run rate: 9.53  Required: 13.53
Ball 5 Chris Woakes 27(16), Joe Root 13(8) [3/54] 4 scored (Starc)
Run rate: 9.94  Required: 13.41
Ball 6 Chris Woakes 31(17), Joe Root 13(8) [3/58] 1 scored (Inglis)
Run rate: 9.83  Required: 13.50
Over produced: 9 Score: (3/59)

Over 7.0 Bowler: Josh Inglis 0/11  (1.0 overs)
Ball 1 Chris Woakes 32(18), Joe Root 13(8) [3/59] 0 scored
Run rate: 9.57  Required: 13.66
Ball 2 Chris Woakes 32(19), Joe Root 13(8) [3/59] 1 scored (Inglis)
Run rate: 9.47  Required: 13.76
Ball 3 Joe Root 13(8), Chris Woakes 33(20) [3/60] 1 scored (Inglis)
Run rate: 9.38  Required: 13.85
Ball 4 Chris Woakes 33(20), Joe Root 14(9) [3/61] 1 scored (Warner)
Run rate: 9.30  Required: 13.95
Ball 5 Joe Root 14(9), Chris Woakes 34(21) [3/62] 4 scored (Lyon)
Run rate: 9.66  Required: 13.82
Ball 6 Joe Root 18(10), Chris Woakes 34(21) [3/66] 4 scored (Lyon)
Run rate: 10.00  Required: 13.69
Over produced: 11 Score: (3/70)

Over 8.0 Bowler: Usman Khawaja 0/15  (1.0 overs)
Ball 1 Chris Woakes 34(21), Joe Root 22(11) [3/70] 4 scored (Boland)
Run rate: 10.33  Required: 13.56
Ball 2 Chris Woakes 38(22), Joe Root 22(11) [3/74] 0 scored
Run rate: 10.09  Required: 13.74
Ball 3 Chris Woakes 38(23), Joe Root 22(11) [3/74] 2 scored (Murphy)
Run rate: 10.13  Required: 13.76
Ball 4 Chris Woakes 40(24), Joe Root 22(11) [3/76] 4 scored (Starc)
Run rate: 10.43  Required: 13.62
Ball 5 Chris Woakes 44(25), Joe Root 22(11) [3/80] 0 scored
Run rate: 10.21  Required: 13.81
Ball 6 Chris Woakes 44(26), Joe Root 22(11) [3/80] Appeal for run out. Out! (Lyon)
Run rate: 10.00  Required: 14.00
Over produced: 10 Score: (4/80)

Over 9.0 Bowler: Alex Carey 0/14  (2.0 overs)
Ball 1 Joe Root 22(11), James Anderson 0(0) [4/80] Appeal for lbw.  Out!
Run rate: 9.80  Required: 14.20
Ball 2 Moeen Ali 0(0), James Anderson 0(0) [5/80] 3 scored (Green)
Run rate: 9.96  Required: 14.14
Ball 3 James Anderson 0(0), Moeen Ali 3(1) [5/83] 6 scored (Warner)
Run rate: 10.47  Required: 13.83
Ball 4 James Anderson 6(1), Moeen Ali 3(1) [5/89] 4 scored (Starc)
Run rate: 10.73  Required: 13.68
Ball 5 James Anderson 10(2), Moeen Ali 3(1) [5/93] Appeal for lbw.  Not out!
Run rate: 10.53  Required: 13.88
Ball 6 James Anderson 10(3), Moeen Ali 3(1) [5/93] No ball!
Ball 6 James Anderson 10(3), Moeen Ali 3(1) [5/94] 1 scored (Warner)
Run rate: 10.56  Required: 13.91
Over produced: 15 Score: (5/95)

Over 10.0 Bowler: Pat Cummins 1/5  (1.0 overs)
Ball 1 James Anderson 11(4), Moeen Ali 3(1) [5/95] 6 scored (Carey)
Run rate: 11.02  Required: 13.57
Ball 2 James Anderson 17(5), Moeen Ali 3(1) [5/101] 1 scored (Boland)
Run rate: 10.93  Required: 13.69
Ball 3 Moeen Ali 3(1), James Anderson 18(6) [5/102] 1 scored (Boland)
Run rate: 10.84  Required: 13.81
Ball 4 James Anderson 18(6), Moeen Ali 4(2) [5/103] 1 scored (Inglis)
Run rate: 10.76  Required: 13.94
Ball 5 Moeen Ali 4(2), James Anderson 19(7) [5/104] 1 scored (Boland)
Run rate: 10.68  Required: 14.07
Ball 6 James Anderson 19(7), Moeen Ali 5(3) [5/105] 4 scored (Murphy)
Run rate: 10.90  Required: 13.90
Over produced: 14 Score: (5/109)

Over 11.0 Bowler: Scott Boland 1/14  (1.0 overs)
Ball 1 Moeen Ali 5(3), James Anderson 23(8) [5/109] 4 scored (Carey)
Run rate: 11.11  Required: 13.73
Ball 2 Moeen Ali 9(4), James Anderson 23(8) [5/113] 1 scored (Green)
Run rate: 11.03  Required: 13.86
Ball 3 James Anderson 23(8), Moeen Ali 10(5) [5/114] 4 scored (Warner)
Run rate: 11.24  Required: 13.68
Ball 4 James Anderson 27(9), Moeen Ali 10(5) [5/118] 3 scored (Khawaja)
Run rate: 11.34  Required: 13.61
Ball 5 Moeen Ali 10(5), James Anderson 30(10) [5/121] 1 scored (Lyon)
Run rate: 11.26  Required: 13.75
Ball 6 James Anderson 30(10), Moeen Ali 11(6) [5/122] No ball!
Ball 6 James Anderson 30(10), Moeen Ali 11(6) [5/123] 1 scored (Boland)
Run rate: 11.27  Required: 13.78
Over produced: 15 Score: (5/124)

Over 12.0 Bowler: Pat Cummins 1/19  (2.0 overs)
Ball 1 James Anderson 31(11), Moeen Ali 11(6) [5/124] 6 scored (Starc)
Run rate: 11.64  Required: 13.36
Ball 2 James Anderson 37(12), Moeen Ali 11(6) [5/130] 1 scored (Inglis)
Run rate: 11.56  Required: 13.50
Ball 3 Moeen Ali 11(6), James Anderson 38(13) [5/131] 1 scored (Starc)
Run rate: 11.48  Required: 13.65
Ball 4 James Anderson 38(13), Moeen Ali 12(7) [5/132] Appeal for run out. Out! (Warner)
Run rate: 11.31  Required: 13.92
Ball 5 Stuart Broad 0(0), Moeen Ali 12(7) [6/132] No ball!
Ball 5 Stuart Broad 0(0), Moeen Ali 12(7) [6/133] 1 scored (Lyon)
Run rate: 11.32  Required: 13.96
Ball 6 Moeen Ali 12(7), Stuart Broad 1(1) [6/134] 0 scored
Run rate: 11.17  Required: 14.25
Over produced: 10 Score: (6/134)

Over 13.0 Bowler: Josh Inglis 0/22  (2.0 overs)
Ball 1 Stuart Broad 1(1), Moeen Ali 12(8) [6/134] 6 scored (Carey)
Run rate: 11.51  Required: 13.79
Ball 2 Stuart Broad 7(2), Moeen Ali 12(8) [6/140] 2 scored (Starc)
Run rate: 11.51  Required: 13.83
Ball 3 Stuart Broad 9(3), Moeen Ali 12(8) [6/142] 0 scored
Run rate: 11.36  Required: 14.13
Ball 4 Stuart Broad 9(4), Moeen Ali 12(8) [6/142] 4 scored (Starc)
Run rate: 11.53  Required: 13.91
Ball 5 Stuart Broad 13(5), Moeen Ali 12(8) [6/146] 0 scored
Run rate: 11.38  Required: 14.23
Ball 6 Stuart Broad 13(6), Moeen Ali 12(8) [6/146] 4 scored (Cummins)
Run rate: 11.54  Required: 14.00
Over produced: 16 Score: (6/150)

Over 14.0 Bowler: Pat Cummins 1/29  (3.0 overs)
Ball 1 Moeen Ali 12(8), Stuart Broad 17(7) [6/150] Appeal for lbw.  Not out!
Run rate: 11.39  Required: 14.34
Ball 2 Moeen Ali 12(9), Stuart Broad 17(7) [6/150] 1 scored (Smith)
Run rate: 11.32  Required: 14.55
Ball 3 Stuart Broad 17(7), Moeen Ali 13(10) [6/151] Appeal for lbw.  Out!
Run rate: 11.19  Required: 14.92
Ball 4 Josh Tongue 0(0), Moeen Ali 13(10) [7/151] 4 scored (Cummins)
Run rate: 11.34  Required: 14.68
Ball 5 Josh Tongue 4(1), Moeen Ali 13(10) [7/155] Appeal for lbw.  Not out!
Run rate: 11.20  Required: 15.08
Ball 6 Josh Tongue 4(2), Moeen Ali 13(10) [7/155] 2 scored (Green)
Run rate: 11.21  Required: 15.17
Over produced: 7 Score: (7/157)

Over 15.0 Bowler: Usman Khawaja 0/25  (2.0 overs)
Ball 1 Moeen Ali 13(10), Josh Tongue 6(3) [7/157] 4 scored (Carey)
Run rate: 11.36  Required: 14.91
Ball 2 Moeen Ali 17(11), Josh Tongue 6(3) [7/161] 4 scored (Starc)
Run rate: 11.51  Required: 14.65
Ball 3 Moeen Ali 21(12), Josh Tongue 6(3) [7/165] Appeal for bowled! Out!
Run rate: 11.38  Required: 15.09
Ball 4 Harry Brook 0(0), Josh Tongue 6(3) [8/165] 4 scored (Green)
Run rate: 11.52  Required: 14.81
Ball 5 Harry Brook 4(1), Josh Tongue 6(3) [8/169] 0 scored
Run rate: 11.39  Required: 15.29
Ball 6 Harry Brook 4(2), Josh Tongue 6(3) [8/169] 4 scored (Inglis)
Run rate: 11.53  Required: 15.00
Over produced: 16 Score: (8/173)

Over 16.0 Bowler: Josh Inglis 0/38  (3.0 overs)
Ball 1 Josh Tongue 6(3), Harry Brook 8(3) [8/173] 3 scored (Boland)
Run rate: 11.60  Required: 14.90
Ball 2 Harry Brook 8(3), Josh Tongue 9(4) [8/176] 1 scored (Smith)
Run rate: 11.54  Required: 15.21
Ball 3 Josh Tongue 9(4), Harry Brook 9(4) [8/177] 4 scored (Khawaja)
Run rate: 11.68  Required: 14.89
Ball 4 Josh Tongue 13(5), Harry Brook 9(4) [8/181] 0 scored
Run rate: 11.55  Required: 15.46
Ball 5 Josh Tongue 13(6), Harry Brook 9(4) [8/181] 6 scored (Carey)
Run rate: 11.81  Required: 14.64
Ball 6 Josh Tongue 19(7), Harry Brook 9(4) [8/187] 6 scored (Murphy)
Run rate: 12.06  Required: 13.75
Over produced: 20 Score: (8/193)

Over 17.0 Bowler: Scott Boland 1/29  (2.0 overs)
Ball 1 Harry Brook 9(4), Josh Tongue 25(8) [8/193] Appeal for run out. Not out!
Run rate: 11.94  Required: 14.35
Ball 2 Harry Brook 9(5), Josh Tongue 25(8) [8/193] 1 scored (Warner)
Run rate: 11.88  Required: 14.73
Ball 3 Josh Tongue 25(8), Harry Brook 10(6) [8/194] 3 scored (Murphy)
Run rate: 11.94  Required: 14.57
Ball 4 Harry Brook 10(6), Josh Tongue 28(9) [8/197] 0 scored
Run rate: 11.82  Required: 15.30
Ball 5 Harry Brook 10(7), Josh Tongue 28(9) [8/197] 0 scored
Run rate: 11.70  Required: 16.11
Ball 6 Harry Brook 10(8), Josh Tongue 28(9) [8/197] 2 scored (Inglis)
Run rate: 11.71  Required: 16.33
Over produced: 6 Score: (8/199)

Over 18.0 Bowler: Cameron Green 0/0  (0.0 overs)
Ball 1 Josh Tongue 28(9), Harry Brook 12(9) [8/199] 4 scored (Lyon)
Run rate: 11.83  Required: 15.88
Ball 2 Josh Tongue 32(10), Harry Brook 12(9) [8/203] 4 scored (Green)
Required: 41 from 16
Ball 3 Josh Tongue 36(11), Harry Brook 12(9) [8/207] 2 scored (Cummins)
Required: 39 from 15
Ball 4 Josh Tongue 38(12), Harry Brook 12(9) [8/209] 1 scored (Carey)
Required: 38 from 14
Ball 5 Harry Brook 12(9), Josh Tongue 39(13) [8/210] 1 scored (Smith)
Required: 37 from 13
Ball 6 Josh Tongue 39(13), Harry Brook 13(10) [8/211] 3 scored (Carey)
Required: 34 from 12
Over produced: 15 Score: (8/214)

Over 19.0 Bowler: Usman Khawaja 1/41  (3.0 overs)
Ball 1 Josh Tongue 42(14), Harry Brook 13(10) [8/214] 1 scored (Smith)
Required: 33 from 11
Ball 2 Harry Brook 13(10), Josh Tongue 43(15) [8/215] 6 scored (Khawaja)
Required: 27 from 10
Ball 3 Harry Brook 19(11), Josh Tongue 43(15) [8/221] 6 scored (Starc)
Required: 21 from 9
Ball 4 Harry Brook 25(12), Josh Tongue 43(15) [8/227] 1 scored (Warner)
Required: 20 from 8
Ball 5 Josh Tongue 43(15), Harry Brook 26(13) [8/228] 0 scored
Required: 20 from 7
Ball 6 Josh Tongue 43(16), Harry Brook 26(13) [8/228] 1 scored (Khawaja)
Required: 19 from 6
Over produced: 15 Score: (8/229)

Over 20.0 Bowler: Scott Boland 1/35  (3.0 overs)
Ball 1 Josh Tongue 44(17), Harry Brook 26(13) [8/229] 2 scored (Starc)
Required: 17 from 5
Ball 2 Josh Tongue 46(18), Harry Brook 26(13) [8/231] 4 scored (Inglis)
Required: 13 from 4
Ball 3 Josh Tongue 50(19), Harry Brook 26(13) [8/235] 0 scored
Required: 13 from 3
Ball 4 Josh Tongue 50(20), Harry Brook 26(13) [8/235] 0 scored
Required: 13 from 2
Ball 5 Josh Tongue 50(21), Harry Brook 26(13) [8/235] 4 scored (Starc)
Required: 9 from 1
Ball 6 Josh Tongue 54(22), Harry Brook 26(13) [8/239] 4 scored (Starc)
Over produced: 14 Score: (8/243)


England Scorecard

Jonny Bairstow      bowled(Boland)         11 (8)
Dan Lawrence        run out (Cummins)      1 (1)
Chris Woakes        run out (Lyon)         44 (27)
Ollie Robinson      bowled(Cummins)        0 (1)
Joe Root            lbw (Carey)            22 (12)
James Anderson      run out (Warner)       38 (14)
Moeen Ali           bowled(Khawaja)        21 (13)
Stuart Broad        lbw (Cummins)          17 (8)
Josh Tongue         not out                58 (23)
Harry Brook         not out                26 (13)
Ben Stokes          not out                0 (0)
Extras                                     5

Total 8 for 243

Bowling

Josh Inglis        0/58 (24)
Scott Boland       1/49 (24)
Pat Cummins        2/36 (24)
Cameron Green      0/15 (6)
Usman Khawaja      1/56 (24)
Alex Carey         1/29 (18)

Press Enter to continue...
Australia (8/247) beat England (8/243)

Overall analysis
Games played: 1
Australia wins: 1
England wins: 0
Draws: 0
Average Australia Score: 247.00
Average England Score: 243.00

Thursday, July 13, 2023

0000 0000 1100 1100

XIAO ESP32S3 Problem Solver

I have two problems in my life at the moment. OK that is a gross simplification - I have hundreds of problems in my life at the moment, but two that might be able to be solved pretty easily with some hardware I have laying about the place and some small snippets of code. Plus - a tiny toy rubbish bin!

Firstly, our WiFi out here in the middle of nowhere is pretty patchy - also we rely on the internet for our "landline" phone as well. It has often been the case that we have been unaware that we are out of communication as the broadband has crashed.

I'd like to know if the WiFi strength is good, and ultimately if we are actually connected to the internet. An ESP32 with the right code should be able to:

1. test WiFi strength (strength = WiFi.RSSI())

2. test internet connection (internet = Ping.ping("www.google.com"))

Secondly - and this might be a uniquely Australian problem - I can never remember when the recycling bin is to be picked up! The normal household rubbish bin is collected each week, but the recycling only on every second week. Of course our local council website has been coded by the work experience kid.

Without checking our neighbour's choice or phoning the dysfunctional council in question (and there are so many questions) there is no way of knowing when the pickup is happening.

I decided that maybe if I could code an ESP32 to find out the date (via an ntp server) then I could maybe have an LED or two indicating which bin to put out for collection. This produced a bit of a side journey into ntp protocols etc - and also a little bit of trickery with the change over (check the time every four hours, but only change on the day after the collection, but only once that day - ouch my head).

There was some other code trickery I enjoyed solving including:

1. Save the bin choice to EEProm in case of power failure. I could have used preferences.h here, but I went with EEProm due to familiarity.

2. Configure the ESP32 as an AP as well as connected to the WiFi so that I can log into it to change the bin choice as well as monitor the WiFi availability and strength.

3. React to the loss of the internet as well as loss of WiFi signal. 

4. Serve up an HTML page on the AP so that I can change the bin choice.

Finally I decided to use a XIAO ESP32S3 that Seeed Studios sent me recently, and therefore due to lack of available GPIOs (it's tiny!) I whipped up a 74HC595/LED Bar Graph combo to output the signal strength.

There were some other little issues along the journey, but the full code is below for your dining pleasure.

/*
   The bin project aims to solve two problems:
   a) is the WiFi working?
   b) what bins do I put out this week

   The code is therefore doing this:
   1. Every "pollingtime" (set below) the ESP32 checks the strength of the WiFi signal
   2. If the signal is out, the ESP32 attempts reconnection and flashes red
   3. The ESP32 can be told which bins are out this week
   4. It saves the data then changes each "changeday" at 1am
   5. The ESP32 connects with an ntp server to keep track of time
   6. Data is saved to EEPROM in case of reset

   OneCircuit Sun 09 Jul 2023 13:20:25 AEST
   https://www.youtube.com/@onecircuit-as
   https://onecircuit.blogspot.com/

*/

// libraries used
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include "time.h"
#include <Arduino.h>
#include <AsyncTCP.h>
#include <EEPROM.h>
#include <ESP32Ping.h>

#define EEPROM_SIZE 1

// change for your AP as required
const char* binssid = "BinXMonitor";
const char* binpassword = NULL;

// server for time, and the offsets for location
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 32400;
const int daylightOffset_sec = 3600;

// Pin allocations for XIAO ESP32S3

// Pins for the 74HC595
const uint8_t latchPin = 1;
const uint8_t clockPin = 2;
const uint8_t dataPin = 3;

// Pins for the Green and Yellow LEDs
const uint8_t GreenLed = 4;
const uint8_t YellLed = 5;

bool YellLedState = LOW;

// your WiFi credentials - change as required
const char* ssid = "YourWifiSSID";
const char* password = "YourWiFiPass";

// the html page served up from the ESP32 to change bin status
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE html>
<html>
<head>
  <title>Bin Selection</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<center>
  <h1>Select Bins for next week</h1>
    <form action="/" method="POST">
      <font size="+2">
      <input type="radio" name="bintype" value="Green Bin">
      <label for="GB">Green Bin only</label>
      <br>
      <input type="radio" name="bintype" value="Recycle Bin">
      <label for="RB">Recycle Bin too</label><br><br>
      <input type="submit" value="Enter Choice">
      </font>
    </form>
</center>
</body>
</html>
)rawliteral";

// params and variables for html polling
const char* PARAM_INPUT_1 = "bintype";
String bintype;
bool newRequest = false;

// variables for day and hour from ntp server
char Day[10];
int Hour;

// I'm going to check time every...
const unsigned long timelapse = 14400000;  // 4 hours in milliseconds
unsigned long currentMillis;
unsigned long previousMillis;

// which day and hour to change LED indicators
const String changeday = "Wednesday";
const int changehour = 1;

// after changing, don't change again until next week
// e.g. numchanges (7) x timelapse (4 hours) = 28 hours
uint8_t changecount = 0; // how many times checked timelapse?
const uint8_t numchanges = 7; // reset changecount after this

// how often to check WiFi status?
const int pollingtime = 2000;

// LED lights for bar graph
// see https://deepbluembedded.com/esp32-wifi-signal-strength-arduino-rssi/
uint8_t strength = 0;
const uint8_t lowstrength = 90; // change as required
const uint8_t maxstrength = 30; // change as required
uint8_t lights = 0;

// how many times for attempting WiFi and time check before restart?
const uint8_t wifitries = 50;

// start the webserver on the ESP32
AsyncWebServer server(80);

// array for bargraph - out to 74HC595 shift register
const uint8_t ledpattern[9] = {
  0b00000000,  // 0
  0b00000001,  // 1
  0b00000011,  // 2
  0b00000111,  // 3
  0b00001111,  // 4
  0b00011111,  // 5
  0b00111111,  // 6
  0b01111111,  // 7
  0b11111111   // 8
};

// get time from the ntp server
void GetLocalTime() {
  struct tm timeinfo;
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  int numtries = 0;
  while (!getLocalTime(&timeinfo)) {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[0]);
    digitalWrite(latchPin, HIGH);
    delay(100);
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[8]);
    digitalWrite(latchPin, HIGH);
    delay(100);
    numtries = numtries + 1;
    if (numtries > wifitries) {
      numtries = 0;
      ESP.restart();
    }
  }
  strftime(Day, 10, "%A", &timeinfo);
  Hour = timeinfo.tm_hour;
}

// initiate the WiFi connection
void initWiFi() {
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(ssid, password);
  int numtries = 0;
  while (WiFi.status() != WL_CONNECTED) {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[0]);
    digitalWrite(latchPin, HIGH);
    delay(100);
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[8]);
    digitalWrite(latchPin, HIGH);
    delay(100);
    numtries = numtries + 1;
    if (numtries > wifitries) {
      numtries = 0;
      ESP.restart();
    }
  }
}

void setup() {
  // breathe
  delay(200);

  // 74HC595 pins to output
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

  // LEDs to output and start green (always on)
  pinMode(GreenLed, OUTPUT);
  digitalWrite(GreenLed, HIGH);
  pinMode(YellLed, OUTPUT);
  digitalWrite(YellLed, YellLedState);

  // 74HC595 "remembers" last state, so clear
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[0]);
  digitalWrite(latchPin, HIGH);

  // start WiFi
  initWiFi();

  // get time
  GetLocalTime();

  // set up AP for ESP32
  WiFi.softAP(binssid, binpassword);

  // what is in EEPROM? Set accordingly
  EEPROM.begin(EEPROM_SIZE);
  YellLedState = EEPROM.read(0);
  digitalWrite(YellLed, YellLedState);

  // Web Server Root URL
  server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) {
    request->send(200, "text/html", index_html);
  });

  // Handle request (form)
  server.on("/", HTTP_POST, [](AsyncWebServerRequest* request) {
    int params = request->params();
    for (int i = 0; i < params; i++) {
      AsyncWebParameter* p = request->getParam(i);
      if (p->isPost()) {
        // HTTP POST input1 value (direction)
        if (p->name() == PARAM_INPUT_1) {
          bintype = p->value().c_str();
        }
      }
    }
    request->send(200, "text/html", index_html);
    newRequest = true;
  });

  server.begin();
}

void loop() {
  // keep track of time for checking ntp server
  currentMillis = millis();
  if ((currentMillis - previousMillis) >= timelapse) {
    previousMillis = currentMillis;
    GetLocalTime();
    String today = String(Day);
    // it's time to change LEDs and save to EEPROM
    if ((today == changeday) && (Hour >= changehour)) {
      if (changecount == 0) {
        YellLedState = !YellLedState;
        digitalWrite(YellLed, YellLedState);
        EEPROM.write(0, YellLedState);
        EEPROM.commit();
      }
      // after change LED, forward to next day to
      // prevent further changes on changeday
      changecount = changecount + 1;
      if (changecount >= numchanges) {
        changecount = 0;
      }
    }
  }

  // output loss of WiFi
  int numtries = 0;


  while (!(Ping.ping("www.google.com", 1))) {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[8]);
    digitalWrite(latchPin, HIGH);
    delay(100);
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[0]);
    digitalWrite(latchPin, HIGH);
    delay(100);
    numtries = numtries + 1;
    if (numtries > wifitries) {
      numtries = 0;
      ESP.restart();
    }
  }

  // adjust according to your WiFi strength
  // output strength to 74HC595
  strength = abs(WiFi.RSSI());
  lights = map(strength, lowstrength, maxstrength, 0, 8);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, ledpattern[lights]);
  digitalWrite(latchPin, HIGH);

  // process any polling requests to change bins (and save)
  if (newRequest) {
    if (bintype == "Recycle Bin") {
      YellLedState = HIGH;
      digitalWrite(YellLed, YellLedState);
      EEPROM.write(0, YellLedState);
      EEPROM.commit();
    } else {
      YellLedState = LOW;
      digitalWrite(YellLed, YellLedState);
      EEPROM.write(0, YellLedState);
      EEPROM.commit();
    }
    newRequest = false;
  }

  delay(pollingtime);
}

The whole thing fits nicely and appropriately into a bin!


The video is below for your enjoyment - go put a like and comment on YouTube - it'd be great to see you there.




Wednesday, June 28, 2023

0000 0000 1100 1011

Art for Art's Sake

Coaxed out of a hiatus bought about by an impending house move by Seeed Studio I embarked upon a project which both them and I will probably regret!

Firstly I'd been consuming too much Ben Eater goodness around his 6502 based breadboard computer and the idea of emulating an early Apple - coincidentally the first computer I used to learn programming was an AppleII, way back in 1978!

Secondly I'd recently found two amazing 6502 resources:

1. The online assembler, emulator and instructions set from Mass:Werk.

2. The amazing KimUno project - how to run a 6502 on a custom PCB with an Arduino Pro Mini, or a STM32 or even an ESP32 (introductory manual)

With my head full of this nostalgia and the tools to match, in comes Seeed Studio with their XIAO range of minuscule but powerful modules. "Would you like to try some XIAO modules?" they said. "Yes!"

I thought it would be aesthetically pleasing to shoehorn the KimUno project into the XIAO.

Of course there were some issues! Chiefly I wanted to run the XIAO ESP32C3 over serial, but the module only has ACM serial as standard - and it was being severely interfered with by Pin Assignments. I was able to get around this initially by using a Frankenstein combination of a CP2102 UART to USB module and some resistors on the strapping pins, but...

Considering there was no hardware KimUno - I simply wrote the pins out of the code as per the green area below! The red represents the original ESP32 pin assignments.


One weird artefact of using the /dev/ttyACM0 interface was fixed serial speed of 115200 baud. It just ignores the code and you get what you get!

After way too many false starts, head scratching and dead ends, finally success! The joy of running MicroChess on this thumb size device is difficult to describe.

See for yourself - enjoy the video.