#1
|
|||
|
|||
troubleshoot vba code, icm for 4 prizes
i've been playing a lot of 2 table sngs that pay 4 places lately. i found one online calculator that can handle more than 3 prizes but i wanted my own offline version (excel). probably won't make sense here to just post code snippets but i can pm a file/link to anyone interested. just in case, here's the code to calculate 3rd place (working) but my code for 4th place is wrong. i'm not a programmer nor do i completely understand the math. thought i could figure it out as i went. 99% sure i don't have 'probability of j getting 2nd' defined correctly. i get different results when i test against the online version. if i try it using 3 places it matches. thanks.
<font class="small">Code:</font><hr /><pre> 'third place results (works) For i = 1 To gbl_MAXPLAYERS 'i is first If stacks(i) > 0 Then For j = 1 To gbl_MAXPLAYERS 'j is second If j <> i And stacks(j) > 0 Then tempTotal = totalChips - stacks(i) - stacks(j) For k = 1 To gbl_MAXPLAYERS 'k is third If k <> i And k <> j Then If tempTotal <> 0 Then totalFinish(k)(3) = totalFinish(k)(3) + stacks(k) / tempTotal * totalFinish(i)(1) * stacks(j) / (tempTotal + stacks(j)) 'Probability of k getting third times probability of i getting first times probability of j getting 2nd given i got first. End If End If Next k End If Next j End If Next i 'fourth place results (not working) For i = 1 To gbl_MAXPLAYERS 'i is first If stacks(i) > 0 Then For j = 1 To gbl_MAXPLAYERS 'j is second If j <> i And stacks(j) > 0 Then For k = 1 To gbl_MAXPLAYERS 'k is third If k <> i And k <> j And stacks(k) > 0 Then For l = 1 To gbl_MAXPLAYERS 'l is fourth If l <> i And l <> j And l <> k Then tempTotal = totalChips - stacks(i) - stacks(j) - stacks(k) If tempTotal <> 0 Then totalFinish(l)(4) = totalFinish(l)(4) + stacks(l) / tempTotal * totalFinish(i)(1) * totalFinish(j)(2) * stacks(k) / (tempTotal + stacks(k)) 'Probability of l getting forth times probability of i getting first times probability of j getting 2nd times probability of k getting 3rd given i got first. End If End If Next l End If Next k End If Next j End If Next i </pre><hr /> |
Thread Tools | |
Display Modes | |
|
|