Friday, January 17, 2014

Dice Football Simulation Game on Python

To start off the second quarter, we wanted to think of project that we would enjoy doing everyday when we went to stats class. After a lot of brainstorming, we came up with an idea. We decided to use a game that my family made a long time ago at my house, called dice football, and try to make it into a simulation game on the computer. We thought this would be a good project for stats class because not only does the game have to do with probability and math, but we can also simulate games hundreds of times to find data, which is what this class is really about.

None of us, Joe, Buster or I, knew anything about the Python Program or how to code. So with the help of Mr. Pethan, and even a little bit from Evan Richardson,  we were able to come up with a series of codes to make our game on the computer. We had to come up with codes to simulate three dice being rolled on offense and two dice being rolled on defense. Depending on what each team rolled, and the play type called by the offense, different outcomes can occur. Just like in regular football, in our game you could score touchdowns or field goals, fumble the ball, or throw an interception. We had to make functions for all of these which took a lot of time and hard work. While working on this project, we also wanted to know which strategy was best for the game (when was the best time to pass, run, or kick a field goal). We decided to create individual "teams" with their own unique functions. For example, one could make a function so they could only run on 3rd down if you had 3 or less yards to go. By making these funcitions, and repeating the results on python, we were able to see patterns of which functions worked better than others. I learned a ton from this project, especially in coding. While I'm still not that great of a coder, I learned the basics needed if I was ever to do something like this again. This project also is great in that it helps you learn how to overcome obstacles. For example, we could take three or four days just to get a function  for runs, pass, kickoffs, or scoring. While we had to be patient, it was worth it in the end to see our game actually work.

If I was to do this project again, the only thing I would do is work on it more and figure out more codes to make the game more specific and fun. For example, we never really made a kickoff or onside function because we never had the time. I would have liked to completely finish the project, but between the modules and our other final project, we never really had the time. Overall, it was a very fun project to work on and it taught me a lot about statistics and the basics of coding. Below are examples of the type of coding we did in Python.



2 comments:

  1. Is your code available somewhere? I'm looking to play around with something similar and would love to see what you ended up with...

    ReplyDelete
  2. I couldn't find any of their project :(
    Sorry about that!

    ReplyDelete