#1
|
|||
|
|||
Quick math question
I'm trying to finish up a new hand converter (since the old one is broken and there's no indication it'll be fixed soon). My brain is a little fried so I need this bit of math solved for me: if you know your seat number, and you know what number the button is, what's the formula to get my position for this hand? I know it's got to be simple, but for some reason it's all just fuzzy tonight.
|
#2
|
|||
|
|||
Re: Quick math question
well its not super easy since its a function of how many players are left and where they are sitting.
|
#3
|
|||
|
|||
Re: Quick math question
You have to parse the text after the words "dealt to" and replace that with the word HERO.
|
#4
|
|||
|
|||
Re: Quick math question
To get position, put each seat into an array list. Look for the text seat X is the button and use that for your 0 index.
Better brush up on your regular expressions [img]/images/graemlins/smile.gif[/img] |
#5
|
|||
|
|||
Re: Quick math question
Yeah, I can go through an number them. Yes I can parse out the data. But I really think there should be a calculation that'll just let me get one of the positions directly. Modulus will do the 'around the corner' math. It should work. I want to solve it in a single line.
I'm looking for the elegant way, not the easiest way. |
#6
|
|||
|
|||
Re: Quick math question
[ QUOTE ]
Better brush up on your regular expressions [img]/images/graemlins/smile.gif[/img] [/ QUOTE ] I'm actually pretty handly with regular expressions. I've done a few screen scraping applications in the past so I've had a lot of practice. All of the hand reading stuff is done, I'm just trying to format it for output. |
#7
|
|||
|
|||
Re: Quick math question
*bump*
Someone... |
#8
|
|||
|
|||
Re: Quick math question
Ok I knew it was just a fuzzy head at night thing. The formula for figuring out your position is:
(Seat number - button seat number - 2) modulus (player count) |
#9
|
|||
|
|||
Re: Quick math question
Oh yeah, you need to get an absolute value before you mod it. Some modulus operators automatically do this (I've always thought of the modulus as being a non-negative value), but in some cases you have to do it yourself.
Now I have another question. In what order to positions get named? In other words, if you have 4 people left, is it UTG, Button, SB, and BB? What about 5, 7, 9? Need help on this please. |
#10
|
|||
|
|||
Re: Quick math question
[ QUOTE ]
Oh yeah, you need to get an absolute value before you mod it. Some modulus operators automatically do this (I've always thought of the modulus as being a non-negative value), but in some cases you have to do it yourself. [/ QUOTE ] the mod operator should never return a negative value. not saying they don'e but they shouldn't. I really think you are probably better off just assigning the seats manually, because none of it really works otherwise unless the players are sitting in consecutive seats. My thoughts would be to start at the button. And go backwards from there. i.e. if the button is seat 6. Then assign that player the button. Then assign the BB and count back to find the SB if there is one. Then count backwards from the button assigning any unassigned players a seat in backwards order ... CO, MP3, MP2, ..., UTG Of course there is probably an easier way. |
|
|