title: Foosball result prediction
body: <p>In our office, we regularly enjoy some rounds of foosball / table football after work. I have put together a small java program that generates random 2vs2 lineups from the available players and stores the match results in a database afterwards.</p>
  
  <p>The current prediction of the outcome uses a simple average of all previous match results from the 4 involved players. This gives a very rough estimation, but I'd like to replace it with something more sophisticated, taking into account things like:</p>
  
  <ul>
  <li>players may be good playing as attacker but bad as defender (or vice versa)</li>
  <li>players do well against a specific opponent / bad against others</li>
  <li>some teams work well together, others don't</li>
  <li>skills change over time</li>
  </ul>
  
  <p>What would be the best algorithm to predict the game outcome as accurately as possible?</p>
  
  <p>Someone suggested using a neural network for this, which sounds quite interesting... but I do not have enough knowledge on the topic to say if that could work, and I also suspect it might take too many games to be reasonably trained.</p>
  
  <p>EDIT:<br>
  Had to take a longer break from this due to some project deadlines. To make the question more specific:</p>
  
  <p>Given the following mysql table containing all matches played so far:</p>
  
  <pre><code>table match_result
  
  match_id      int pk
  match_start   datetime
  duration      int (match length in seconds)
  blue_defense  int fk to table player
  blue_attack   int fk to table player
  red_defense   int fk to table player
  red_attack    int fk to table player
  score_blue    int
  score_red     int
  </code></pre>
  
  <p>How would you write a function predictResult(blueDef, blueAtk, redDef, redAtk) {...}<br>
  to estimate the outcome as closely as possible, executing any sql, doing calculations or using external libraries?</p>