Two players have a set of dice each. The first player has nine dice with four faces each, with numbers one to four. The second player has six normal dice with six faces each, each face has the usual numbers from one to six.

They roll their dice and sum the totals of the faces. The player with the highest total wins (it's a draw if the totals are the same). What's the probability of the first player beating the second player?

Later the two players use a different set of dice each. Now the first player has five dice with ten faces each, and the second player has six dice with seven faces each. Now what's the probability of the first player beating the second player?

This task was adapted from the Project Euler Problem n.205:
https://projecteuler.net/problem=205

' Gambas module file
 
Public Sub Main()
Dim iSides, iPlayer1, iPlayer2, iTotal1, iTotal2, iCount, iCount0 As Integer
Dim iDice1 As Integer = 9
Dim iDice2 As Integer = 6
Dim iSides1 As Integer = 4
Dim iSides2 As Integer = 6
 
Randomize
 
For iCount0 = 0 To 1
  For iCount = 1 To 100000
    iPlayer1 = Roll(iDice1, iSides1)
    iPlayer2 = Roll(iDice2, iSides2)
    If iPlayer1 > iPlayer2 Then
      iTotal1 += 1
    Else If iPlayer1 <> iPlayer2 Then
      iTotal2 += 1
    Endif
  Next
 
  Print "Tested " & Str(iCount - 1) & " times"
  Print "Player1 with " & Str(iDice1) & " dice of " & Str(iSides1) & " sides"
  Print "Player2 with " & Str(iDice2) & " dice of " & Str(iSides2) & " sides"
  Print "Total wins Player1 = " & Str(iTotal1) & " - " & Str(iTotal2 / iTotal1)
  Print "Total wins Player2 = " & Str(iTotal2) 
  Print Str((iCount - 1) - (iTotal1 + iTotal2)) & " draws" & gb.NewLine
 
  iDice1 = 5
  iDice2 = 6
  iSides1 = 10
  iSides2 = 7
  iTotal1 = 0
  iTotal2 = 0
Next
 
End
 
Public Sub Roll(iDice As Integer, iSides As Integer) As Integer
Dim iCount, iTotal As Short
 
For iCount = 1 To iDice
  iTotal += Rand(1, iSides)
Next
 
Return iTotal
 
End