Identify Positions on the Poker Table - Sit'n Go Tournaments

Note. I am using javascript code according to ajrwhite answer. Hope this helps someone.

Link: http://codepen.io/eMineiro/pen/EKrNBe

Open the codepen console to see working examples.

In poker, we determine the position of the player depending on the dealer. Like this:

enter image description here

Blue: small blind and large blind positions

Green: late and dealership / late positions

Yellow: middle position

Pink: early position

So, assuming these two arrays:

players:[1,2,3,4,5,6,7,8,9,10]; positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"]; 

In this case, “player1” is “Big Blind”, “player2” is “Small Blind”, “player3” is “button” .....

I want to sort an array of players when changePositions (dealer) is called. Example:

 changePosition(10); //means that "player10" now is the new Dealer 

And the result should be:

 players:[2,1,10,9,8,7,6,5,4,3]; positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"]; 

During the game, players can be eliminated. Therefore, I have a function to exclude the "last position" in the "array of positions" and exclude the player. Then I need to call changePosition (X) again, where X is the next unused player to the left of "player10" (actual dealer).

An example for eliminating "player 1", new arrays should be:

 players:[2,10,9,8,7,6,5,4,3]; positions:["bb","sb","btn","late","medium","medium","medium","early","early"]; 

And I need to call changePosition (X) again to determine new positions, in this case X = 2, since "player2" is to the left of the actual dealer "player10"

 changePosition(2); 

And it should turn out:

 players:[4,3,2,10,9,8,7,6,5]; positions:["bb","sb","btn","late","medium","medium","medium","early","early"]; 

How can I find a new dealer when I delete a player?

Note. I created a function called changeNextDealer () . A negative index was not a problem because the next dealer is clockwise. It is in the link with the code.

 dealerArrayPosition-1; //But if bigBlind and smallBlind was eliminated simultaneously I get a negative position. 

How to match a negative index, for example -1, with the last position. Or -2 in LastPosition-1? Is there a quick way?

Note. This question still does not answer, but is not the main issue of this discussion. I think they will ask in a separate message.

How do I execute the changePosition (dealer) function?

I've tried so much, but can't figure out how to do this.

Note. I created a function called changePosition () . This is encoded.

+6
source share
1 answer

Suppose players are always numbered 1-10. We do not need two data structures for storing player positions and statuses. We need only one indexed data structure to store the player’s state:

State 1

 positions:["btn","sb","bb","early","early","early","medium","medium","medium","late"]; 

State 2

 positions: ["late","btn","sb","bb","early","early","early","medium","medium","medium"] 

State 3

 positions: ["eliminated","late","btn","sb","bb","early","early","early","medium","medium"]; 

It stores the same amount of information as your two arrays, and is more consistent. You simply access positions[0] to find out what state of player 1 or positions[9] for player 10.

Now with this more consistent structure, it should be easier to handle status changes at the end of each round.

Player Elimination

After each round, change the status of the excluded player to "eliminated" . You may need a temporary array so that you can check what happened in the previous round, and will still update the information for the next round.

How to handle an array like a circle

Move the dealer chip "btn" to (currentPositionOfBtn+1)%10 - this means that the button moves from 1 to 2 to 3, etc., but using the remainder operator and the total number of players, we guarantee that the transition from position 9 (Player 10) cyclically returns to 0 (Player 1).

If the player in currentPositionOfBtn+1)%10 been deleted, check currentPositionOfBtn+2)%10 , etc. is a simple loop to implement.

Recalculation of positions

Now, given that the description of the positions changes as the players are eliminated (by the end you do not have an “early” or “average”), I would suggest recounting the positions from the Dealer and further at the end of each round, skipping over any players marked as “eliminated” "

+2
source

All Articles