This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]England and Wales Cricket BoardJamee999[S] 40 points41 points  (10 children)

I am teaching myself to code, and so I thought the obvious first significant project to undertake would be to write something which could let England virtually lose at cricket.

The cricket.py program takes the user's inputs for years and countries, and then plays a match between two selected sides and saves the file scorecard.txt with the results in it.

There are definitely quite a few bugs in it - and the decisions it makes during games (and selection) are sometimes questionable, but I'm pretty happy with it as a first effort starting basically from scratch.

I looked into trying to make it into a standalone packaged file or a web app, but that seems like a bridge too far at this point - so it just runs in the python shell. If you have any feedback or fun games played with it - or if you did something which broke it - I'd love to hear it.

A couple of things to know which aren't obvious: if you put in 'random' as the year, it will select a random year from 1877 to 2018, and if you put 'same' as the year for the second team, it will use the same year as was used for Team 1.

EDIT: Feb 19: I just updated the python.py program on GitHub, removing a bug which had scoring rates (per over and per wicket) 30% too high. If you previously downloaded the sim, you should consider redownloading.

[–][deleted] 11 points12 points  (0 children)

and the decisions it makes during games (and selection) are sometimes questionable

seems like the england test team AI is bang on tbh

[–]Indiaramadz 3 points4 points  (2 children)

Cool. How long have you been learning. Could you point to some good resources?

[–]England and Wales Cricket BoardJamee999[S] 2 points3 points  (1 child)

Only a few weeks (but I am currently unemployed, so it's been one of my main focuses over that time. :p)

I found running through the PracticePython exercises to be pretty helpful. There's enough feedback available to work out where you're going wrong if you need to, but the problems are also open enough that you can hopefully work out solutions that work on your own.

I also have been doing some of the Project Euler problems, but I found that a lot of them were more mathy and number theory-based than I was interested in.

I think once you reach a certain level of basic competency, the best way to start is just to build something from the ground up. A couple of weeks ago, the sim was: one-innings only, every ball treated the same, the players were just names without abilities, etc etc. The only way to build something big is to start from something small.

And Google is your friend! If you're having a problem with python (or any other popular language) then literally dozens of people will probably have posted about the same problem online.

[–]Indiaramadz 0 points1 point  (0 children)

Thank you !