Skip to content

Commit

Permalink
0.5 hf2 backport to 0.7 (#114)
Browse files Browse the repository at this point in the history
- Change list, dict to List, Dict
- Adds python version matrix in GH workflows
  • Loading branch information
SirRender00 authored Jun 7, 2022
1 parent d1bf8d1 commit abccf59
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
python-version: 3.9
- name: Install poetry
uses: snok/install-poetry@v1.0.0
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ concurrency:

jobs:
build:
strategy:
fail-fast: true
matrix:
python-version: [ "3.8", "3.10" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: snok/install-poetry@v1.0.0
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
python-version: 3.9
- name: Install poetry
uses: snok/install-poetry@v1.0.0
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/windows-gui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ defaults:

jobs:
build:
strategy:
fail-fast: true
matrix:
python-version: [ "3.8", "3.10" ]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ A python package for Texas Hold 'Em Poker providing

| Version Name | Latest Tag | Release Notes | Patch Notes | Documentation | Release Date | End Support Date |
| ------------ | ---------- | ------------- | ----------- | ------------- | ------------ | ---------------- |
| 0.7 | v0.7.1 | [Release Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.7.1) | [Patch Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.7.0) | [Documentation](https://texasholdem.readthedocs.io/en/0.7/) | 16 April 2022 | |
| 0.6 | v0.6.4 | [Release Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.6.0) | [Patch Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.6.4) | [Documentation](https://texasholdem.readthedocs.io/en/0.6/) | 24 March 2022 | |
| 0.5 | v0.5.2 | [Release Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.5.0) | [Patch Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.5.2) | [Documentation](https://texasholdem.readthedocs.io/en/0.5/) | 21 March 2022 | |
| 0.7 | v0.7.2 | [Release Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.7.0) | [Patch Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.7.2) | [Documentation](https://texasholdem.readthedocs.io/en/0.7/) | 16 April 2022 | |
| 0.6 | v0.6.5 | [Release Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.6.0) | [Patch Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.6.5) | [Documentation](https://texasholdem.readthedocs.io/en/0.6/) | 24 March 2022 | |
| 0.5 | v0.5.3 | [Release Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.5.0) | [Patch Notes](https://github.com/SirRender00/texasholdem/releases/tag/v0.5.3) | [Documentation](https://texasholdem.readthedocs.io/en/0.5/) | 21 March 2022 | |

Current Roadmap \
[v1.0.0](https://github.com/SirRender00/texasholdem/wiki/Version-1.0.0-Roadmap)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = 'Evyn Machi'

# The full version, including alpha/beta/rc tags
release = 'v0.7.1'
release = 'v0.7.2'


# -- General configuration ---------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "texasholdem"
version = "0.7.1"
version = "0.7.2"
description = "A texasholdem python package"
authors = ["Evyn Machi <[email protected]>"]
keywords = ['texasholdem', 'holdem', 'poker']
Expand All @@ -20,7 +20,7 @@ include = [
"Wiki" = "https://github.com/SirRender00/texasholdem/wiki"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
Deprecated = "^1.2.13"
windows-curses = { version = "^2.3.0", markers = "sys_platform == 'win32'" }

Expand All @@ -31,7 +31,7 @@ pylint = "^2.11.1"
sphinx-rtd-theme = "^1.0.0"

[tool.pylint.master]
disable = ["import-error", "missing-module-docstring"]
disable = ["import-error", "missing-module-docstring", "unknown-option-value"]

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- Method for stripping comments from a history string.
"""
import os
from typing import Union
from typing import Union, Tuple
from pathlib import Path
import random

Expand Down Expand Up @@ -129,7 +129,7 @@ def call_agent():
"""

def get_action(game: TexasHoldEm) -> tuple[ActionType, None]:
def get_action(game: TexasHoldEm) -> Tuple[ActionType, None]:
player = game.players[game.current_player]
if player.state == PlayerState.TO_CALL:
return ActionType.CALL, None
Expand All @@ -148,7 +148,7 @@ def random_agent():
"""

def get_action(game: TexasHoldEm, no_fold: bool = False) -> tuple[ActionType, int]:
def get_action(game: TexasHoldEm, no_fold: bool = False) -> Tuple[ActionType, int]:
bet_amount = game.player_bet_amount(game.current_player)
chips = game.players[game.current_player].chips
min_raise = game.value_to_total(game.min_raise(), game.current_player)
Expand Down
32 changes: 16 additions & 16 deletions tests/evaluator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
a certain board.
"""
import itertools
from typing import Optional
from typing import Optional, List, Dict
import random

from texasholdem.card.card import Card
Expand All @@ -18,10 +18,10 @@
ALL_SUITS = tuple(Card.CHAR_SUIT_TO_INT_SUIT.keys())


def is_flush(cards: list[Card]) -> bool:
def is_flush(cards: List[Card]) -> bool:
"""
Arguments:
cards (list[Card]): The hand to use
cards (List[Card]): The hand to use
Returns:
bool: True if there exists a five-card hand combo in the given cards
that results in a flush, False o/w
Expand All @@ -33,10 +33,10 @@ def is_flush(cards: list[Card]) -> bool:
for hand in itertools.combinations(cards, 5))


def find_nonflush_suit(suits: Optional[list[str]] = None) -> str:
def find_nonflush_suit(suits: Optional[List[str]] = None) -> str:
"""
Arguments:
suits (Optional[list[str]]): The suits to use, default None
suits (Optional[List[str]]): The suits to use, default None
Returns:
str: A suit such that suits + [suit] is not a flush
Raises:
Expand All @@ -58,7 +58,7 @@ def find_nonflush_suit(suits: Optional[list[str]] = None) -> str:
return suit_candidate


def generate_nonflush_suits(board: Optional[list[Card]] = None) -> list[str]:
def generate_nonflush_suits(board: Optional[List[Card]] = None) -> List[str]:
"""
Arguments:
board (Optional[List[Card]]): The board to use of length 3, 4, or 5 (default None).
Expand All @@ -79,7 +79,7 @@ def generate_nonflush_suits(board: Optional[list[Card]] = None) -> list[str]:
return suits


def is_straight(ranks: list[int]) -> bool:
def is_straight(ranks: List[int]) -> bool:
"""
Arguments:
ranks (List[int]): The ranks to use
Expand All @@ -98,7 +98,7 @@ def is_straight(ranks: list[int]) -> bool:
for hand in itertools.combinations(ranks, 5))


def find_nonstraight_rank(ranks: list[int]) -> int:
def find_nonstraight_rank(ranks: List[int]) -> int:
"""
Arguments:
ranks (List[int]): a list of ranks
Expand All @@ -122,7 +122,7 @@ def find_nonstraight_rank(ranks: list[int]) -> int:
return rank_cand


def get_rank_counts(rank_list: list[int]) -> dict[int, int]:
def get_rank_counts(rank_list: List[int]) -> Dict[int, int]:
"""
Arguments:
rank_list (List[int]): A list of ranks
Expand All @@ -139,7 +139,7 @@ def get_rank_counts(rank_list: list[int]) -> dict[int, int]:
return counts


def less_hands_same_class(rank_class: int, hand1: list[Card], hand2: list[Card]) -> bool:
def less_hands_same_class(rank_class: int, hand1: List[Card], hand2: List[Card]) -> bool:
"""
Compares two hands from the same rank_class against each other, returning True if
hand1 loses against hand2, False otherwise.
Expand All @@ -165,7 +165,7 @@ def less_hands_same_class(rank_class: int, hand1: list[Card], hand2: list[Card])
return list(counts1.keys()) < list(counts2.keys())


def generate_nonstraight_noncombo(board: Optional[list[Card]] = None) -> list[str]:
def generate_nonstraight_noncombo(board: Optional[List[Card]] = None) -> List[str]:
"""
Arguments:
board (Optional[List[Card]]): The board to use of length 3, 4, or 5 (default None).
Expand All @@ -189,7 +189,7 @@ def generate_nonstraight_noncombo(board: Optional[list[Card]] = None) -> list[st
return [Card.STR_RANKS[rank] for rank in ranks]


def generate_straight(board: Optional[list[Card]] = None) -> list[str]:
def generate_straight(board: Optional[List[Card]] = None) -> List[str]:
"""
Arguments:
board (Optional[List[Card]]): The board to use of length 3, 4, or 5 (default None).
Expand Down Expand Up @@ -218,7 +218,7 @@ def generate_straight(board: Optional[list[Card]] = None) -> list[str]:
raise ValueError("Could not generate a straight.")


def generate_flush(board: Optional[list[Card]] = None) -> list[str]:
def generate_flush(board: Optional[List[Card]] = None) -> List[str]:
"""
Arguments:
board (Optional[List[Card]]): The board to use of length 3, 4, or 5 (default None).
Expand All @@ -242,7 +242,7 @@ def generate_flush(board: Optional[list[Card]] = None) -> list[str]:
return 2 * [Card.INT_SUIT_TO_CHAR_SUIT[suit_choices[0]]]


def generate_combo(*combos: int, board: Optional[list[Card]] = None) -> list[Card]:
def generate_combo(*combos: int, board: Optional[List[Card]] = None) -> List[Card]:
"""
Easy generation of combos, examples below give a clearer picture:
Expand Down Expand Up @@ -337,14 +337,14 @@ def find_edit_distance_within(rank_dict, combos_list, distance=2):
return cards


def generate_sample_hand(rank_class: int, board: Optional[list[Card]] = None) -> list[Card]:
def generate_sample_hand(rank_class: int, board: Optional[List[Card]] = None) -> List[Card]:
"""
Given a rank_class this function will generate a random list of cards from that rank
class with uniform probability.
Arguments:
rank_class (int): The class rank to generate a hand from
board (Optional[list[Card]]): The board to use
board (Optional[List[Card]]): The board to use
Returns:
List[Card]: A uniformly random five-card hand of the given class (two if board is given)
that forms the given rank class when combined with the board
Expand Down
4 changes: 2 additions & 2 deletions texasholdem/agents/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def call_agent(game: TexasHoldEm) -> Tuple[ActionType, None]:
Arguments:
game (TexasHoldEm): The TexasHoldEm game
Returns:
tuple[ActionType, None]: CALL if someone raised, else CHECK
Tuple[ActionType, None]: CALL if someone raised, else CHECK
"""
player = game.players[game.current_player]
Expand All @@ -42,7 +42,7 @@ def random_agent(game: TexasHoldEm, no_fold: bool = False) -> Tuple[ActionType,
game (TexasHoldEm): The TexasHoldEm game
no_fold (bool): Removes the possibility of folding if no one raised, default False.
Returns:
tuple[ActionType, int]: Returns a uniformly random action from the
Tuple[ActionType, int]: Returns a uniformly random action from the
available moves.
"""
Expand Down
10 changes: 5 additions & 5 deletions texasholdem/card/card.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import math
from typing import Union, Iterable
from typing import Union, Iterable, List


class Card(int):
Expand Down Expand Up @@ -238,12 +238,12 @@ def binary_string(self) -> str:
return "".join(output)


def card_strings_to_int(card_strs: Iterable[str]) -> list[Card]:
def card_strings_to_int(card_strs: Iterable[str]) -> List[Card]:
"""
Args:
card_strs (Iterable[str]): An iterable of card strings.
Returns:
list[Card]: The cards in the corresponding int format.
List[Card]: The cards in the corresponding int format.
"""
bhand = []
Expand Down Expand Up @@ -298,13 +298,13 @@ def prime_product_from_rankbits(rankbits: int) -> int:
return product


def card_list_to_pretty_str(cards: list[Card]) -> str:
def card_list_to_pretty_str(cards: List[Card]) -> str:
"""
Prints the given card in a human-readable pretty string with
ascii suit.
Args:
cards (list[Card]): A list of card ints in the proper form.
cards (List[Card]): A list of card ints in the proper form.
Returns:
string: A human-readable pretty string with ascii suits.
Expand Down
10 changes: 6 additions & 4 deletions texasholdem/card/deck.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import random
from typing import List

from texasholdem.card import card
from texasholdem.card.card import Card

Expand All @@ -10,7 +12,7 @@ class Deck:
makes a copy of this object and shuffles it.
"""
_FULL_DECK: list[Card] = []
_FULL_DECK: List[Card] = []

def __init__(self):
self.cards = Deck._get_full_deck()
Expand All @@ -23,14 +25,14 @@ def shuffle(self) -> None:
"""
random.shuffle(self.cards)

def draw(self, num=1) -> list[Card]:
def draw(self, num=1) -> List[Card]:
"""
Draw card(s) from the deck. These cards leave the deck and are not saved.
Args:
num (int): How many cards to draw. Defaults to 1.
Returns:
list[Card]: A list of length n of cards (See :class:`~texasholdem.card.card.Card`).
List[Card]: A list of length n of cards (See :class:`~texasholdem.card.card.Card`).
Raises:
ValueError: If the deck size is less than the given n.
Expand All @@ -46,7 +48,7 @@ def __str__(self) -> str:
return card.card_list_to_pretty_str(self.cards)

@staticmethod
def _get_full_deck() -> list[Card]:
def _get_full_deck() -> List[Card]:
if Deck._FULL_DECK:
return list(Deck._FULL_DECK)

Expand Down
Loading

0 comments on commit abccf59

Please sign in to comment.