Wednesday, 28 December 2011

Java: Texas Hold Em (29)

Well, got a migraine today, so sorry, folks, can't give you the big one I promised. Instead, I'll cover it whenever this blasted thing is gone, and cover the method that returns a player's allowed actions tonight.

Here it is, short as possible:

As you can see on the method declaration, this method returns a set of actions, so, what the players can do!
To know what players can do, we should probably know what the player's bet is.
Lines 245-249 cover the first half of the main if-statement, which is what happens if this player has no bet down. The rest of this block says that our actions can include checking as well as (assuming you haven't hit your raise limit) betting.
Lines 250-262 cover the second half of our statement, itself having some nested if-statements.
First, if the player's bet is lower than the table's bet (line 251), add the ability to call. As long as the raising limit hasn't been hit, also allow raises.
Otherwise, (lines 256-259) just add the ability to check and raise (if the limit hasn't been hit).

Just to finish it off, on line 263, allow players to fold all the time, then return all the available actions.

Easy and short, now I can tend to my head. Like a goddamn jackhammer in my brain. See you tomorrow, hopefully, questions and comments welcome.


  1. You wrote all this with a migraine? You're my hero.

    But yeah, I get it all today.

  2. Hope you feel better! Have a good day!