Imagine this game:

Player A rolls a number of dice, each dice has a set number of sides. For example, there might be a four-sided die with sides 1,2,3, and 4. He sums up all the numbers on his rolled dice and this number is his "power".

Player B then rollsanothernumber of dice with the same rules and gets his "power".

Given the number of dice and the number of their individual sides for each player, how can I calculate the probability of player A's power beating player B's power?

For example, the function A_beats_B may receive as input that player A rolls two 20-sided dice while player B rolls one 20-sided die and one 10-sided die.

Finding the average power of each player is easy, but I've been, so far, unable to discover an algorithm to compute the probability of A beating B.

A complete solution or even a clue that would set me in the right direction is appreciated.