# Simple math problem

## Recommended Posts

KingSpoom    122
4 defensivebacks and 4 receivers to cover. There are 2 classes of defensivebacks (cornerbacks and safeties, and I'd prefer if they remain statistically similar). I want coverage to [i]normally[/i] be between 2 and 4 with the majority being 3. However, I want each player to decide who to cover by themselves instead of delegating how many are covered and assigning who to cover. Instead of covering man to man, the defensivebacks can also double-cover or cover rushes. In addition, I'd like a delayed cover to occur about once among all the defensivebacks per pass play. The defensivebacks themselves have a rating to determine how well they decide who to cover, rated from 1 (poorly) to 16 (reliably). That should affect whether the player covers an open receiver, a covered receiver, or waits for a rusher. Receivers can only be fast and hope the quarterback times his throws right.

I also have plans for a "failed play" deal where normal coverage is instead 0 to 2 with majority being 1, but I'm hoping that such a thing would be trivial to math once the base problem is solved.

I'm sure I'm leaving something out. I'll just have to respond to requests for further details if needed.

##### Share on other sites
Hodgman    51223
[quote name='KingSpoom' timestamp='1310618810' post='4835126']I'm sure I'm leaving something out.[/quote]Perhaps the simple math problem mentioned in the title?

##### Share on other sites
alvaro    21246
I think the correct title is "Please, design my American football game for me".

##### Share on other sites
KingSpoom    122
[quote name='Hodgman' timestamp='1310619871' post='4835128']
[quote name='KingSpoom' timestamp='1310618810' post='4835126']I'm sure I'm leaving something out.[/quote]Perhaps the simple math problem mentioned in the title?
[/quote]

I'm looking to acheive a coverage of 3 the majority of the time, with a coverage of 2 and 4 the remainder of the time, given that each of the 4 defenders is individually deciding who to cover based on their own rating of 1-16. In addition, 1 covering defender should lag behind the WR a majority of the time based upon a constant percentage.

[quote name='alvaro' timestamp='1310620150' post='4835130']
I think the correct title is "Please, design my American football game for me".
[/quote]
Looks like I already designed it, I just can't code it.

##### Share on other sites
LorenzoGatti    4442
I don't see any math problem in computing weights for random selection of moves. Just normalize the probability of all branches of a certain choice to add up to 1, and everything is going to work. If you aren't sure of your formulas, don't worry: you'll change them over and over to search for behaviours that are realistic and reasonably smart, fun to control, and bug-free.

The only issue that seems implied in your rather confused description is that you appear to be trying to decide player movement in advance for a whole play, with excessive abstractions and complications, instead of iteratively in smaller and well defined decisions.
A reasonable defender might decide to start a play running towards a certain player hoping he gets a pass, but if the ball went the other way or enough teammates seem likely to take care of the opponent first he'll decide to turn towards another objective. Meanwhile, players stumble, slow down, drop the ball, and so on: every event might require a separate reaction.

On a related note, what do you mean by covering "poorly" or "reliably"? Defender skill can presumably broken down into a chance to guess the offense team's plan, adjusting running direction more or less often, a chance to notice events, running faster or slower, making tighter or wider turns, a chance to catch the ball, and other well-defined elementary parts; real players do not purposefully place themselves in wrong locations, and such an unrealistic model is likely to cause trouble.

You should code as much as possible of your American football game and ask for help when you have a definite stumbling block to show.

##### Share on other sites
LorenzoGatti    4442
[quote name='KingSpoom' timestamp='1310621053' post='4835135']

I'm looking to acheive a coverage of 3 the majority of the time, with a coverage of 2 and 4 the remainder of the time, given that each of the 4 defenders is individually deciding who to cover based on their own rating of 1-16. In addition, 1 covering defender should lag behind the WR a majority of the time based upon a constant percentage.
[/quote]

I don't claim to understand this American football jargon, but let's figure out probabilities for something of the sort.
Four defenders 1,2,3,4 can choose between "covering" any one of receivers A,B,C,D or lagging (L) behind. Let's call the 20 probabilities A1 for player 1 covering player A and so on.
Constraints:
Ai+Bi+Ci+Di+Li=1 for each defender i because they have no other option.
The average number of lagging defenders is a constant LE:
L1+L2+L3+L4=LE
Each defender has a preference for covering each attacker, expressed by known weights (Pa1 for player 1 wanting to cover player A and so on):

Ai/Pai=Bi/Pbi=Ci/Pci=Di/Pdi=Ki

Ki is a constant of each defender that turns out to represent propensity to cover. By substitution,

Ki*Pai+Ki*Pbi+Ki*Pci+Ki*Pdi+Li=1

Ki= (1-Li)/(Pai+Pbi+Pci+Pdi)

The system is still underconstrained, but choosing the Li values immediately determines all probabilities, making your "coverage" objectives inapplicable.

Obviously designating one defender as lagging with probability LE is going to work better than allowing 2,3 or all 4 defenders to lag because they decide independently.
It's similarly possible for all defenders to cover the same player: a team that assigns defenders to receivers sensibly is going to win more often.
You might reduce the influence of defender propensity to choose receivers: most defenders get assigned someone, and only some of them have the privilege of falling between two attackers and choosing one at whim.

##### Share on other sites
Emergent    982
I don't know how fancy you want to get, but to me it sounds like there's an [url="http://en.wikipedia.org/wiki/Assignment_problem"]assignment problem[/url] in there.