Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Tournament Poker > STT Strategy

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2007, 07:14 AM
Gabethebabe Gabethebabe is offline
Junior Member
 
Join Date: Oct 2007
Posts: 12
Default Creating an ICM calculator in MS Access.

Hi all, Im new to this forum and I plan to browse these forums and absorb knowledge to improve my play.

My first post is this one and Id like to make a contribution that I hope you will find helpful. Maybe it is already available in some other form on the forums. In that case, well, I have wasted my time [img]/images/graemlins/smile.gif[/img]

Most of you have heard of ICM and some of you might even understand the mathematics. But still, calculating your equity in the prize money isnt an easy feat. Yes, there are calculators available and yes, you can buy software that does it for you.

The first has the disadvantage that youre likely limited to 10-seat SnGs with payout structure of first-third and the second option has the disadvantage that it costs you money.

If you have MS office installed on your computer, either legally or illegally [img]/images/graemlins/wink.gif[/img] you can create your own ICM calculator. I have written the code myself because the link to the ICM source code that can be fund on the www is not available anymore (http://sharnett.bol.ucla.edu/ICM/ICM.html).

Create a new (or open an existing) MS Access database.

1) Create a table "Players" with the fields "Player" (Integer/Long Integer), "Stack" (Long Integer) and "Equity" (Double).
2) Create a table "Prizes" with the fields "Place" (Integer) and "Prize" (Single).
3) Create a module "ISeeYourHoleCards" (or whatever name youd like) and paste into it the following VBA code:

<font class="small">Code:</font><hr /><pre>
Option Compare Database
Option Explicit
Dim StackSum As Long
Dim Stack() As Long
Dim Equity(), Prize() As Double
Sub CalculateEquity()
Dim NoPlayers, NoPrizes, Player As Integer
Dim tStacks, tPrize
Dim sPermutation As String

'Database has table "Prizes" with fields "Place" (Integer) and "Prize" (Single)
Set tPrize = CurrentDb.openrecordset("Prizes")

'Database has table "Players" with fields "Player" (Integer), "Stack" (Long) and "Equity" (Double)
Set tStacks = CurrentDb.openrecordset("Players")

'Size global arrays
NoPlayers = tStacks.RecordCount
NoPrizes = tPrize.RecordCount

ReDim Stack(NoPlayers)
ReDim Equity(NoPlayers)
ReDim Prize(NoPrizes)

'Get stack info
StackSum = 0
tStacks.MoveFirst
While Not tStacks.EOF
Stack(tStacks!Player) = tStacks!Stack
StackSum = StackSum + Stack(tStacks!Player)
tStacks.MoveNext
Wend

'Get prize info
tPrize.MoveFirst
While Not tPrize.EOF
Prize(tPrize!Place) = tPrize!Prize
tPrize.MoveNext
Wend

'Create all permutations
sPermutation = ""
For Player = 1 To NoPlayers
sPermutation = sPermutation &amp; Chr(Player)
Next Player

If NoPrizes &gt; NoPlayers Then
Call GetPermutation("", sPermutation, NoPlayers)
Else
Call GetPermutation("", sPermutation, NoPrizes)
End If

'Write the equities to table
tStacks.MoveFirst
For Player = 1 To NoPlayers
tStacks.edit
tStacks!Equity = Equity(Player)
tStacks.Update
tStacks.MoveNext
Next Player

'Close tables
tStacks.Close
tPrize.Close
Set tStacks = Nothing
Set tPrize = Nothing
End Sub
Sub GetPermutation(x As String, y As String, ByVal No As Integer)
Dim i, j, k, Player, Place As Integer
Dim P As Double

j = Len(y)
k = Len(x)

If k = No Then
'Calculate chance that this permutation occurs
P = P_ICM(x)
'Update equities of classified players
For Place = 1 To k
Player = Asc(Mid$(x, Place, 1))
Equity(Player) = Equity(Player) + P * Prize(Place)
Next Place
Else
For i = 1 To j
Call GetPermutation(x &amp; Mid(y, i, 1), Left(y, i - 1) &amp; Right(y, j - i), No)
Next i
End If
End Sub
Function P_ICM(Permutation As String)
Dim Place, Player As Integer
Dim TotalChips, Chips As Long
Dim Chance As Double

TotalChips = StackSum
Chance = 1
'Calculate chance that this classification occurs
For Place = 1 To Len(Permutation)
Chips = Stack(Asc(Mid$(Permutation, Place, 1))) 'Amount of chips of the classified player
If TotalChips &gt; 0 Then Chance = Chance * Chips / TotalChips
TotalChips = TotalChips - Chips
Next Place

P_ICM = Chance

End Function
</pre><hr />

4) Create a form and insert two subforms in there: the tables "Players" and "Prizes" so you can edit both tables directly from your form.
5) Create a button on the form and paste into its ClickEvent the following code:

<font class="small">Code:</font><hr /><pre>
Call CalculateEquity
Me.Requery
Me.Refresh</pre><hr />

And it should work! You should be able to calculate your equity for tournaments of 'any' size, with the observation that calculation time will increase DRAMATICALLY as the amount of prizes/players increase.

Good luck!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.