Skip to content

Commit

Permalink
Magic Numbers replaced by constants
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Oct 19, 2024
1 parent df62a95 commit bdfb981
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/phevaluator/evaluator_omaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
NO_FLUSH_BASE_VALUE = 10000
MIN_FLUSH_COUNT_BOARD = 3
MIN_FLUSH_COUNT_HOLE = 2
MAX_FLUSH_HOLE_HASH = 1365
MAX_NO_FLUSH_HOLE_HASH = 1820
TOTAL_CARD_COUNT = COMMUNITY_CARD_COUNT + HOLE_CARD_COUNT


Expand Down Expand Up @@ -131,7 +133,7 @@ def _determine_flush_value(
suit_binary_hole |= padding[HOLE_CARD_COUNT - flush_count_hole]
board_hash = hash_binary(suit_binary_board, COMMUNITY_CARD_COUNT)
hole_hash = hash_binary(suit_binary_hole, HOLE_CARD_COUNT)
return FLUSH_OMAHA[board_hash * 1365 + hole_hash]
return FLUSH_OMAHA[board_hash * MAX_FLUSH_HOLE_HASH + hole_hash]


def _determine_noflush_value(community_cards: list[int], hole_cards: list[int]) -> int:
Expand All @@ -147,4 +149,4 @@ def _determine_noflush_value(community_cards: list[int], hole_cards: list[int])
board_hash = hash_quinary(quinary_board, COMMUNITY_CARD_COUNT)
hole_hash = hash_quinary(quinary_hole, HOLE_CARD_COUNT)

return NO_FLUSH_OMAHA[board_hash * 1820 + hole_hash]
return NO_FLUSH_OMAHA[board_hash * MAX_NO_FLUSH_HOLE_HASH + hole_hash]

0 comments on commit bdfb981

Please sign in to comment.