|
- /**
- * \param payouts Payout structure, e.g.: new double[]{0.5,0.3,0.2}
- * \param stacks Player stacks
- * \param player Index of selected player in the stack-array
- * \returns ICM equity for selected player
- */
- public static double getEquity ( double [] payouts, double [] stacks, int player )
- {
- double total = 0 ;
- for ( int i = 0 ; i < stacks.length; i++ )
- total += stacks [ i ] ;
- return getEquity ( payouts, stacks.clone () , total, player, 0 ) ;
- }
- //Recursive method doing the actual calculation.
- private static double getEquity ( double [] payouts, double [] stacks, double total, int player, int depth )
- {
- double eq = stacks [ player ] / total * payouts [ depth ] ;
- if ( depth + 1 < payouts.length )
- for ( int i = 0 ; i < stacks.length; i++ )
- if ( i != player && stacks [ i ] > 0.0 ) {
- double c = stacks [ i ] ;
- stacks [ i ] = 0.0 ;
- eq += getEquity ( payouts, stacks, total - c, player, depth + 1 ) * c / total;
- stacks [ i ] = c;
- }
-
- return eq;
- }
复制代码 来源: http://www.holdemresources.net/hr/sngs/icm/icmjava.html
Bean是Java高手,一定懂的。我还在慢慢琢磨 |
|