TablePicker() currently has a very simple semantic which makes it useful
only to one operation: picking a good table for a new player to play at.
In particular, it always picks the fullest game that the player can sit
at.

What I think we should have is actually three settings:
"min_players" "max_players", "preferred_players"

[field #0] Item ID: 2368[field #1] Group ID: 1588[field #2] Open/Closed: Open[field #3] Severity: 4 - Important[field #4] Privacy: Public[field #9] Category: poker-network[field #10] Submitted by: bkuhn[field #11] Assigned to: bkuhn[field #12] Submitted on: Tuesday 06/23/2009 at 02:14[field #13] Summary: TablePicker() should select the most empty table if many match criteria[field #14] Original Submission: The TablePicker() packet currently returns the first table matching the criteria. Ideally, it would examine every possible table matching the criteria, and pick the one with the fewest players that does match. That way, the tables across the site remain more balanced.

There is already a test that should pass if this feature is implemented. Namely, PokerAvatarTablePickerTestCase.test04_tablePicker_twoPossibleGivesMostEmpty in test-pokeravatar.py.in. (Currently, that test is set to return True at all times.)

Implementation of PacketPokerTablePicker(), merged from table-picker branch.
Detailed implementation logs are in table-picker branch, r5830 to r5933.
The commit message below contains a summary of the feature implementation
details. The feature itself is best documented in the "Semantics" section
for the PacketPokerTablePicker() (in pokerpackets.py). This merge
closes sr #2364.

Implementation Details:
* Expanded the method PokerService.listTables() to include various
additional criteria needed to find a list of tables that matched the
desired parameters sought by the requesting player. Additional
indexes were added on dbtable, pokertables, to speed this up.

* PokerService.getTableBestByCriteria() uses the aforementioned new
listTables(). getTableBestByCriteria() loops through the tables
returned by listTables(). It eliminates tables that:
+ are full, or
+ have too many players sitting out, such that the requested
minimum player count would (effectively) not be reached, or
+ have minimum buy-ins such that the requesting player could not
afford to play.

* Refactored PokerAvatar.handlePacketLogic() somewhat to create a
variety of so-called "perform" functions. These functions move some
of the code that was originally in-line inside the giant "if"
statement into their own methods.

* PokerAvatar.performPacketPokerTablePicker() takes advantage of the
aforementioned "perform" functions to ensure its sequence of
automatic packet operations work exactly as if the client had sent
those very packets itself.

* Added a helper function for constructing a string ready for
PokerService.listTables() in PokerAvatar.

Tests Implementation Details:
* Created PokerAvatarTestCaseBaseClass so additional client/server test
case classes can be created to reuse some of the methods from the
original PokerAvatarTestCase.

* Various feature-oriented tests are in PokerAvatarTablePickerTestCase,
which also serves as unit test coverage for handlePacketLogic().

* Standard unit test coverage for the new listTables() and for
getTableBestByCriteria() is provided.

Future Work:

During implementation, the idea came up that table selection by the
TablePicker should help keep the cash game tables site-wide as balanced
as possible, which is the inspiration for sr #2368 and for the

The TablePicker() packet currently returns the first table matching the criteria. Ideally, it would examine every possible table matching the criteria, and pick the one with the fewest players that does match. That way, the tables across the site remain more balanced.

There is already a test that should pass if this feature is implemented. Namely, PokerAvatarTablePickerTestCase.test04_tablePicker_twoPossibleGivesMostEmpty in test-pokeravatar.py.in. (Currently, that test is set to return True at all times.)

Copyright (C) 2004-2006, the Gna! people. Posted items are owned by whoever posted them.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.