diff --git a/README.md b/README.md index dfd74ff..8a9e259 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ Special thanks and dedication to LeMerluche, crushing its opponents on chess.com ## How to play with interface ```python -from pyalapin.interface.interface import MyApp +from pyalapin.interface import ChessApp if __name__ == '__main__': - MyApp( + ChessApp( play_with_ai=False # Set to True if you want to play agains AI ).run() @@ -24,11 +24,9 @@ if __name__ == '__main__': ```python -import sys -sys.path.append("python/") -import python.engine as engine +from pyalapin.engine import ChessGame -game = engine.engine.Game( +game = ChessGame( automatic_draw=True, # Set to True if you want # to have each turn drawn in terminal ai=False, # set to True if you want to play agains AI diff --git a/pyalapin/__init__.py b/pyalapin/__init__.py index 33749f8..7f38ff0 100644 --- a/pyalapin/__init__.py +++ b/pyalapin/__init__.py @@ -1,6 +1,7 @@ """ pyalapin, chess python package. """ +# from .interface import interface as interface __version__ = "0.0.1" __author__ = "Vincent Auriau" diff --git a/pyalapin/engine/__init__.py b/pyalapin/engine/__init__.py index e69de29..d3001ab 100644 --- a/pyalapin/engine/__init__.py +++ b/pyalapin/engine/__init__.py @@ -0,0 +1 @@ +from .engine import ChessGame \ No newline at end of file diff --git a/pyalapin/engine/color.py b/pyalapin/engine/color.py index 4b2c455..9d6570f 100644 --- a/pyalapin/engine/color.py +++ b/pyalapin/engine/color.py @@ -1,4 +1,4 @@ -class Color: +class Color(object): GREEN = "\x1b[32m" WHITE = "\033[0m" RED = "\x1b[31m" diff --git a/pyalapin/engine/engine.py b/pyalapin/engine/engine.py index ffb626e..b17cdcd 100644 --- a/pyalapin/engine/engine.py +++ b/pyalapin/engine/engine.py @@ -14,13 +14,13 @@ import pyalapin.engine.material as material -class Color: +class Color(object): GREEN = "\x1b[32m" WHITE = "\033[0m" RED = "\x1b[31m" -class Cell: +class Cell(object): """ Cell class representing a base element of a board. @@ -387,7 +387,7 @@ def is_threatened( return False -class Board: +class Board(object): """ Board class representing the chess board. @@ -937,7 +937,7 @@ def draw(self, printing=True): return whole_text -class Game: +class ChessGame(object): """ Game class, used to play a chess game, interact with the board and move pieces. diff --git a/pyalapin/engine/move.py b/pyalapin/engine/move.py index 9815b9e..196636a 100644 --- a/pyalapin/engine/move.py +++ b/pyalapin/engine/move.py @@ -4,7 +4,7 @@ import pyalapin.engine.material as material -class Move: +class Move(object): """Base class for material movement. Implements various checks and is able to operate a piece movement along additional actions such as taking an diff --git a/pyalapin/interface/__init__.py b/pyalapin/interface/__init__.py new file mode 100644 index 0000000..dd1cc2a --- /dev/null +++ b/pyalapin/interface/__init__.py @@ -0,0 +1 @@ +from .interface import ChessApp, BoardInterface \ No newline at end of file diff --git a/pyalapin/interface/interface.py b/pyalapin/interface/interface.py index 5971d02..a62adf0 100644 --- a/pyalapin/interface/interface.py +++ b/pyalapin/interface/interface.py @@ -1,6 +1,5 @@ import numpy as np import os -import time from kivy.app import App from kivy.uix.gridlayout import GridLayout @@ -12,7 +11,7 @@ from kivy.graphics import Rectangle, Color, Canvas -from pyalapin.engine.engine import Game +from pyalapin.engine.engine import ChessGame class LoginScreen(GridLayout): @@ -56,7 +55,7 @@ def __init__(self, row, column, **kwargs): self.column = column -class TableScreen(GridLayout): +class BoardInterface(GridLayout): """ Main class to represent and display the board, as well as to play a chess game. @@ -64,7 +63,7 @@ class TableScreen(GridLayout): ---------- path_to_illustrations: str Path to the images to use to display cells & pieces - game: engine.Game + game: engine.ChessGame game to actually represent ai_playing: bool whether or not an AI is playing (only one of the players for now) @@ -89,7 +88,7 @@ def __init__(self, game, **kwargs): game: engine.Game to represent """ - super(TableScreen, self).__init__(**kwargs) + super(BoardInterface, self).__init__(**kwargs) self.path_to_illustrations = "illustrations" self.game = game @@ -378,7 +377,7 @@ def click_cell(self, event): self.update() -class MyApp(App): +class ChessApp(App): """ Main app to use to play game, by calling MyApp().buil() and then player. """ @@ -394,6 +393,6 @@ def build(self): """ Builds the game and the display board along with it. """ - game = Game(automatic_draw=False, ai=self.play_with_ai) + game = ChessGame(automatic_draw=False, ai=self.play_with_ai) print("game created") - return TableScreen(game) + return BoardInterface(game) diff --git a/run_app.py b/run_app.py index 391f364..a0901b2 100644 --- a/run_app.py +++ b/run_app.py @@ -1,4 +1,5 @@ -from pyalapin.interface.interface import MyApp +from pyalapin.interface import ChessApp +# import pyalapin.interface as interface if __name__ == "__main__": - MyApp(play_with_ai=False).run() + ChessApp(play_with_ai=False).run()