Skip to content

Commit

Permalink
Merge branch 'fairy-stockfish:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RainRat authored Dec 30, 2024
2 parents 6842608 + 4d8f3d2 commit 3d34712
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ffishjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ jobs:
- uses: actions/checkout@v4
- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{env.EM_CACHE_FOLDER}}
key: emsdk-${{env.EM_VERSION}}-${{ runner.os }}
- uses: mymindstorm/setup-emsdk@v7
- uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Build ffish.js ES6/ES2015 module
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ jobs:
if: ${{ matrix.arch == 'x86-64' }}
run: cd src && make clean && make -j build COMP=mingw ARCH=${{ matrix.arch }} EXE=fairy-stockfish-all_${{ matrix.arch }}.exe largeboards=yes all=yes && strip fairy-stockfish-all_${{ matrix.arch }}.exe

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: fairy-stockfish
name: fairy-stockfish-windows-${{ matrix.arch }}
path: src/fairy-stockfish*.exe
if-no-files-found: error
compression-level: 9

linux:
strategy:
Expand All @@ -56,7 +58,9 @@ jobs:
if: ${{ matrix.arch == 'x86-64' }}
run: cd src && make clean && make -j build COMP=gcc ARCH=${{ matrix.arch }} EXE=fairy-stockfish-all_${{ matrix.arch }} largeboards=yes all=yes && strip fairy-stockfish-all_${{ matrix.arch }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: fairy-stockfish
name: fairy-stockfish-linux-${{ matrix.arch }}
path: src/fairy-stockfish*
if-no-files-found: error
compression-level: 9
8 changes: 4 additions & 4 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
CIBW_SKIP: "pp* *-win32 *-manylinux_i686 *-musllinux_* cp36-* cp37-*"
CIBW_TEST_COMMAND: python {project}/test.py

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: dist
name: dist-wheel-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_sdist:
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: dist
name: dist-source
path: dist/*.tar.gz
10 changes: 8 additions & 2 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960,
token = char(toupper(token));

if (castling_enabled() && token == 'K')
for (rsq = make_square(var->castlingRookKingsideFile, castling_rank(c)); !(castling_rook_pieces(c) & type_of(piece_on(rsq))) || color_of(piece_on(rsq)) != c; --rsq) {}
for (rsq = make_square(var->castlingRookKingsideFile, castling_rank(c)); (!(castling_rook_pieces(c) & type_of(piece_on(rsq))) || color_of(piece_on(rsq)) != c) && file_of(rsq) > FILE_A; --rsq) {}

else if (castling_enabled() && token == 'Q')
for (rsq = make_square(var->castlingRookQueensideFile, castling_rank(c)); !(castling_rook_pieces(c) & type_of(piece_on(rsq))) || color_of(piece_on(rsq)) != c; ++rsq) {}
for (rsq = make_square(var->castlingRookQueensideFile, castling_rank(c)); (!(castling_rook_pieces(c) & type_of(piece_on(rsq))) || color_of(piece_on(rsq)) != c) && file_of(rsq) < max_file(); ++rsq) {}

else if (token >= 'A' && token <= 'A' + max_file())
rsq = make_square(File(token - 'A'), castling_rank(c));
Expand All @@ -382,6 +382,12 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960,
st->castlingKingSquare[c] = isChess960 && piece_on(rsq) == make_piece(c, castling_king_piece(c)) ? rsq
: castlingKings && (!more_than_one(castlingKings) || isChess960) ? lsb(castlingKings)
: make_square(castling_king_file(), castling_rank(c));
// Skip invalid castling rights
if (!(castlingKings & st->castlingKingSquare[c]))
{
st->castlingKingSquare[c] = SQ_NONE;
continue;
}
}

// Set gates (and skip castling rights)
Expand Down
6 changes: 6 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ def test_get_fen(self):
result = sf.get_fen("chess", "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w 1 2", [])
self.assertEqual(result, "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 1 2")

# invalid castling rights
result = sf.get_fen("chess", "8/rnbqkbnr/pppppppp/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", [])
self.assertEqual(result, "8/rnbqkbnr/pppppppp/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1")
result = sf.get_fen("chess", "r7/1nbqkbnr/pppppppp/8/8/P6P/RPPPPPPR/1NBQKBN1 w KQkq - 0 1", [])
self.assertEqual(result, "r7/1nbqkbnr/pppppppp/8/8/P6P/RPPPPPPR/1NBQKBN1 w - - 0 1")

# alternative piece symbols
result = sf.get_fen("janggi", "rhea1aehr/4k4/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/4K4/RHEA1AEHR w - - 0 1", [])
self.assertEqual(result, JANGGI)
Expand Down

0 comments on commit 3d34712

Please sign in to comment.