Fri 24 Oct 2008
Football has always been an American pastime and also a programming one as well. Ever year EA Games as well as many others are busy building the next years hottest simulator for our entertainment sports.
When I played pro football, I never set out to hurt anyone deliberately - unless it was, you know, important, like a league game or something.
-Dick Butkus
Today I’m going to teach you how to build something similar to NES Tecmo Super Bowl, without the play sequence. The play sequence is too fast to simulate on web and will be left as an exercise with flash or a related software.
The steps I’ve chosen to do to accomplish this are as follows
Determine a basic win/loss formula for play selection
Develop In Depth Data for more realistic feel
Bring it all together
So for the first step it’s quite easy. I want to think of something that after the play is chosen in football, how to determine the outcome. A simple formula might involve the following variables
Offensive play choice
Defensive play choice
Offensive team power
Defensive team power
Random Variation
Based around these simple variables I should be able to determine what is the outcome of a given play. Here is an example in php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | $off_play_choice = $_GET['oselect']; $def_play_choice = $_GET['oselect_def']; $off_power = determine_off_strength(); // a summation of individual's strength $def_power = determine_def_strength(); if($playtype = 'run'){ $min_yards_run = .3; $max_yards_run = 3.6; $avg_run = 2; $minstd = calc_std($min_yards_run,$max_yards_run,$avg_run); $maxstd = calc_std($min_yards_run,$max_yards_run,$avg_run); }else{ $min_yards_pass = .3; $max_yards_pass = 3.6; $avg_pass = 2; $minstd = calc_std($min_yards_run,$max_yards_run,$avg_run); $maxstd = calc_std($min_yards_run,$max_yards_run,$avg_run); } // this forumla takes all variables and returns a yardage which would be reported to the user(s) $yards_balance = $off_playchoice - $def_playchoice * ($off_power - $def_power) * rand($minstd,$maxstd); ?> |
$yards_balance in this example above is the goal, once we have this we can then build placement of the marker and basically have a game. In the next post we will will also build the user interface and show what this thing really can do.