diff --git a/.gitignore b/.gitignore index d87ca8af70a62fc80e93653e1c80b0827bda62db..bb81600cfa36a6be9fbc4bfcb431ad0e9ee7b778 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +# Add by PCwqyy + +.vscode/ +ignore/ + # Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,django,windows # Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode,django,windows diff --git a/core/BuiltinChess/Rook.py b/core/BuiltinChess/Rook.py new file mode 100644 index 0000000000000000000000000000000000000000..9f88819c11243623dd2b1f6643bf7db2545a6d57 --- /dev/null +++ b/core/BuiltinChess/Rook.py @@ -0,0 +1,30 @@ +from ..Chess import ChessBase +from ..Death import DeathBase +from ..Move import MoveBase +from ..Pos import Pos, PosSet +from ..Skill import SkillBase +from .Universal import * + +ROOK_DIRECTIONS=['left','right','left_up','left_down','right_up','right_down'] + +class RookMove(MoveBase): + def __init__(self, chess: ChessBase): + super().__init__(chess=chess) + def get_movable(self): + res=PosSet() + for dir in ROOK_DIRECTIONS: + now=self.owner.pos + while True: + now.go(dir) + if(not now.valid()): + break + res.add(now) + if(self.owner.board.has_chess(now)): + break + return res + def get_movable(self) -> "PosSet": + return PosSet() + def get_eatable(self) -> "PosSet": + return PosSet() + def on_moved(self): + pass \ No newline at end of file diff --git a/core/BuiltinChess/Universal.py b/core/BuiltinChess/Universal.py index c1228ade6d98c953ce36b48ae6a64c5614d4988b..d677a3e23462902045a90bd776846a8174c79b0f 100644 --- a/core/BuiltinChess/Universal.py +++ b/core/BuiltinChess/Universal.py @@ -5,8 +5,11 @@ from typing import TYPE_CHECKING, Callable, Optional if TYPE_CHECKING: from ..Chess import ChessBase TOP = 2 +'''顶角''' LEFT = 1 +'''左下角''' RIGHT = 3 +'''右下角''' # 这里还没有 Transferer... # 都是以 LEFT 为参考,重新写的相对方向函数 diff --git a/core/Pos.py b/core/Pos.py index 9b3513bd879a955c6844192f2b5aea880c3dd696..f2ac0a2cf64c8e185409373838d9e10a13e14505 100644 --- a/core/Pos.py +++ b/core/Pos.py @@ -7,6 +7,8 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: from .Chess import ChessBase +BOARDSIZE=12 + class Pos: def __init__(self, bw: bool, x: int, y: int) -> None: self.bw = bw @@ -131,6 +133,11 @@ class Pos: return next_pos def go(self, method="left", det=1): + ''' + 走多步 + `method` 方向 + `det` 步数 + ''' res = Pos(self.bw, self.x, self.y) for i in range(det): getattr(res, method)() @@ -146,13 +153,14 @@ class Pos: return (self.bw, self.x, self.y) def valid(self): - if self.bw == 1: - return 1 <= self.x and self.x <= 11 and 1 <= self.y and self.y <= 11 - else: - return 1 <= self.x and self.x <= 12 and 1 <= self.y and self.y <= 12 + '''是否超出棋盘''' + delta = 1 if self.bw==1 else 0 + return 1 <= self.x and self.x <= BOARDSIZE-delta and \ + 1 <= self.y and self.y <= BOARDSIZE-delta @staticmethod def checkValid(bw: int, x: int, y: int): + '''是否超出棋盘''' return Pos(bw, x, y).valid() def toNAR(self): diff --git a/tempory note.md b/tempory note.md index ca86e8840cdc106d39a6ba262b9c131c5cd909cc..6de11732bfd87fe82f71208340db0498aa48ce63 100644 --- a/tempory note.md +++ b/tempory note.md @@ -1,3 +1,16 @@ 1 左下角 2 顶角 -3 右下角 \ No newline at end of file +3 右下角 + +棋盘表示方法:~~想象一个苦读代码的PC~~ + +- 黑白格拆开为两个棋盘 + 每个棋盘都是半个正方形 + 所以白格棋盘边长12,黑格棋盘边长11 +- Python 字典存储棋子 `tuple(bw,x,y)->chess` +- 左下角为 0,0 +- 三个方向被表示为 + 0°: `left` `right` + 60°: `left_down` `right_up` + 120°: `left_up` `right_down` +- 对于对角方向,在前面加 `x_` \ No newline at end of file diff --git "a/\347\211\271\346\256\212\347\202\271.md" "b/\347\211\271\346\256\212\347\202\271.md" index f625fa4200b9a2078d20a42088f690361123c79f..01d95343f4ed1c99c652114e4d3c0db56d366fe9 100644 --- "a/\347\211\271\346\256\212\347\202\271.md" +++ "b/\347\211\271\346\256\212\347\202\271.md" @@ -20,7 +20,7 @@ #### 5. factory -可以给自己旁边空余格子加一个 shell,要花分数。 +可以给自己旁边空余格子加一个 product,要花分数。 #### 6. scoring