Skip to content

Commit

Permalink
Release v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
josephlou5 committed Jun 9, 2023
1 parent b2907da commit 1613e7f
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 83 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v2.0.0

_2023-06-08 21:42_

- Removed test file (wasn't supposed to be published)
- Added `__all__` tuples to each file
- Added absolute imports (previous version wasn't event working)

## v1.0.1

_2023-06-08 21:15_
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This project allows you to play Alice Chess, a variant of chess.

## Installastion
## Installation

The package may be installed through `pip`:

Expand Down Expand Up @@ -91,17 +91,10 @@ methods for making a move and promoting a pawn. This class (not an instance) can
then be passed into the `Game` constructor to start a game. See the
[API Documentation][docs] for more information.

## Advanced Usage

The only dependency for this project is `Pillow` to use the images in the
interactive window. As such, you could technically clone the repository and run
it without the window with only the Python builtins. Not sure why you would want
to do that, but that is another alternative option to installing through `pip`.
[docs]: https://github.com/josephlou5/alicechess/blob/main/Documentation.md

## Credit

Thank you to Artyom Lisitsyn for inspiring me to pursue this project and to
Trung Phan for being my chess consultant and answering all my questions on rules
and technicalities.

[docs]: https://github.com/josephlou5/alicechess/blob/main/Documentation.md
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ line_length = 79

[tool.poetry]
name = "alicechess"
version = "1.0.1"
version = "2.0.0"
description = "A Python package to play Alice Chess"
authors = ["Joseph Lou <[email protected]>"]
license = "MIT License"
Expand Down
8 changes: 4 additions & 4 deletions src/alicechess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Alice Chess.
"""

from game import Game
from game_state import GameState
from player import HumanPlayer, Player
from utils import Color, PieceType, PromoteType
from alicechess.game import Game
from alicechess.game_state import GameState
from alicechess.player import HumanPlayer, Player
from alicechess.utils import Color, PieceType, PromoteType
4 changes: 2 additions & 2 deletions src/alicechess/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

# ======================================================================

from game import Game
from player import HumanPlayer
from alicechess.game import Game
from alicechess.player import HumanPlayer

# ======================================================================

Expand Down
2 changes: 1 addition & 1 deletion src/alicechess/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Version for `alicechess` package.
"""

__version__ = "1.0.1"
__version__ = "2.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from functools import partial
from typing import Dict, Iterator, List, Optional, Sequence, Tuple

from pieces import King, Pawn, Piece, Rook
from position import BoardPosition, Position
from utils import Color, PieceType, check_brc, check_brc_bool
from alicechess.pieces import King, Pawn, Piece, Rook
from alicechess.position import BoardPosition, Position
from alicechess.utils import Color, PieceType, check_brc, check_brc_bool

# =============================================================================

Expand Down
15 changes: 11 additions & 4 deletions src/alicechess/bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
import random
from typing import Dict

from game_state import GameState
from player import Player
from position import Move
from utils import PieceType, PromoteType
from alicechess.game_state import GameState
from alicechess.player import Player
from alicechess.position import Move
from alicechess.utils import PieceType, PromoteType

# =============================================================================

__all__ = (
"RandomPlayer",
"PrioritizedRandomPlayer",
)

# =============================================================================

Expand Down
11 changes: 8 additions & 3 deletions src/alicechess/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

from typing import Type

from game_state import GameState
from player import AnyPlayer, _PlayerBase
from alicechess.game_state import GameState
from alicechess.player import AnyPlayer, _PlayerBase

# =============================================================================

__all__ = ("Game",)

# =============================================================================

Expand Down Expand Up @@ -49,7 +53,8 @@ def start_window(self, **kwargs):
"""
# import here so that games that don't use the window don't need
# to be run in a virtual environment (requires Pillow)
from window import Window # pylint: disable=import-outside-toplevel
# pylint: disable=import-outside-toplevel
from alicechess.window import Window

game_state = self.new()
window = Window(game_state, **kwargs)
Expand Down
12 changes: 6 additions & 6 deletions src/alicechess/game_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from itertools import count, zip_longest
from typing import Dict, Iterable, Iterator, Optional, Self, Type

import pieces
from moves_calculator import BoardDict, MovesCalculator
from pieces import Piece, make_promoted
from player import AnyPlayer
from position import Move, PieceMove, PieceMoved, Position
from utils import Color, EndGameState, PieceType, PromoteType
from alicechess import pieces
from alicechess._moves_calculator import BoardDict, MovesCalculator
from alicechess.pieces import Piece, make_promoted
from alicechess.player import AnyPlayer
from alicechess.position import Move, PieceMove, PieceMoved, Position
from alicechess.utils import Color, EndGameState, PieceType, PromoteType

# =============================================================================

Expand Down
31 changes: 14 additions & 17 deletions src/alicechess/pieces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

import typing as _t

from utils import Color as _Color
from utils import PieceType as _PieceType
from utils import PromoteType as _PromoteType

from .king import King
from .pawn import Pawn
from .piece import Piece
from alicechess.pieces.king import King
from alicechess.pieces.pawn import Pawn
from alicechess.pieces.piece import Piece
from alicechess.utils import Color, PieceType, PromoteType

# =============================================================================

Expand Down Expand Up @@ -40,7 +37,7 @@ class Subclass(Piece):
def _check_start_position(self) -> bool:
if self._pos.bn != 0:
return False
if self._color is _Color.WHITE:
if self._color is Color.WHITE:
row = rows[0]
else:
row = rows[1]
Expand All @@ -58,22 +55,22 @@ def _check_start_position(self) -> bool:


# queen is always on the left for this particular board setup
Queen = _make_simple_piece(_PieceType.QUEEN, (7, 0), (3,))
Rook = _make_simple_piece(_PieceType.ROOK, (7, 0), (0, 7))
Knight = _make_simple_piece(_PieceType.KNIGHT, (7, 0), (1, 6))
Bishop = _make_simple_piece(_PieceType.BISHOP, (7, 0), (2, 5))
Queen = _make_simple_piece(PieceType.QUEEN, (7, 0), (3,))
Rook = _make_simple_piece(PieceType.ROOK, (7, 0), (0, 7))
Knight = _make_simple_piece(PieceType.KNIGHT, (7, 0), (1, 6))
Bishop = _make_simple_piece(PieceType.BISHOP, (7, 0), (2, 5))

# =============================================================================


def make_promoted(
pawn: Pawn, promote_type: _PromoteType
pawn: Pawn, promote_type: PromoteType
) -> _t.Union[Queen, Rook, Knight, Bishop]:
PROMOTE_CLASSES = {
_PromoteType.QUEEN: Queen,
_PromoteType.ROOK: Rook,
_PromoteType.KNIGHT: Knight,
_PromoteType.BISHOP: Bishop,
PromoteType.QUEEN: Queen,
PromoteType.ROOK: Rook,
PromoteType.KNIGHT: Knight,
PromoteType.BISHOP: Bishop,
}
return PROMOTE_CLASSES[promote_type](
pawn.id, pawn.color, pawn.pos, has_moved=pawn.has_moved
Expand Down
5 changes: 2 additions & 3 deletions src/alicechess/pieces/king.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

# =============================================================================

from utils import Color, PieceType

from .piece import Piece
from alicechess.pieces.piece import Piece
from alicechess.utils import Color, PieceType

# =============================================================================

Expand Down
5 changes: 2 additions & 3 deletions src/alicechess/pieces/pawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

# =============================================================================

from utils import Color, PieceType

from .piece import Piece
from alicechess.pieces.piece import Piece
from alicechess.utils import Color, PieceType

# =============================================================================

Expand Down
4 changes: 2 additions & 2 deletions src/alicechess/pieces/piece.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from typing import Iterator, Optional, Set

from position import BoardPosition, PieceMove, Position
from utils import Color, PieceType, check_brc
from alicechess.position import BoardPosition, PieceMove, Position
from alicechess.utils import Color, PieceType, check_brc

# =============================================================================

Expand Down
16 changes: 8 additions & 8 deletions src/alicechess/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

# =============================================================================

import typing as _t
from typing import Union

import utils as _utils
from position import Move as _Move
from alicechess.position import Move
from alicechess.utils import Color, PromoteType

# =============================================================================

Expand All @@ -24,12 +24,12 @@ class _PlayerBase:

is_human = False

def __init__(self, color: _utils.Color):
def __init__(self, color: Color):
"""Initializes a player."""
self._color = color

@property
def color(self) -> _utils.Color:
def color(self) -> Color:
"""The player color."""
return self._color

Expand All @@ -48,7 +48,7 @@ class Player(_PlayerBase):
Called when this player can promote a pawn.
"""

def make_move(self, game_state: "GameState") -> _Move:
def make_move(self, game_state: "GameState") -> Move:
"""Called when this player should make their next move.
Args:
Expand All @@ -61,7 +61,7 @@ def make_move(self, game_state: "GameState") -> _Move:
f"{self.__class__.__name__}: method `make_move()` not implemented"
)

def promote(self, game_state: "GameState") -> _utils.PromoteType:
def promote(self, game_state: "GameState") -> PromoteType:
"""Called when this player can promote a pawn.
The move being made is accessible through `game_state.move`.
Expand All @@ -85,4 +85,4 @@ class HumanPlayer(_PlayerBase):

# =============================================================================

AnyPlayer = _t.Union[Player, HumanPlayer]
AnyPlayer = Union[Player, HumanPlayer]
2 changes: 1 addition & 1 deletion src/alicechess/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from functools import total_ordering
from typing import Iterable, Optional, Self, Tuple

from utils import check_brc
from alicechess.utils import check_brc

# =============================================================================

Expand Down
11 changes: 0 additions & 11 deletions src/alicechess/test.py

This file was deleted.

14 changes: 9 additions & 5 deletions src/alicechess/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
"""
) from ex

from game_state import GameState
from pieces import Piece
from position import BoardPosition, Position
from utils import Color, PieceType, PromoteType, check_brc_bool
from alicechess.game_state import GameState
from alicechess.pieces import Piece
from alicechess.position import BoardPosition, Position
from alicechess.utils import Color, PieceType, PromoteType, check_brc_bool

# =============================================================================

__all__ = ("Window",)

# =============================================================================

Expand Down Expand Up @@ -63,7 +67,7 @@
FONTS = ("SF Pro",)

# Images
PICTURE_FOLDER = Path("pictures")
PICTURE_FOLDER = Path(__file__).parent / "pictures"
PICTURE_EXT = ".png"

# =============================================================================
Expand Down

0 comments on commit 1613e7f

Please sign in to comment.