chess 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/bitboard.c +1 -1
- data/ext/bitboard.h +1 -1
- data/ext/board.c +1 -1
- data/ext/board.h +1 -1
- data/ext/chess.c +1 -1
- data/ext/chess.h +1 -1
- data/ext/common.c +1 -1
- data/ext/common.h +1 -1
- data/ext/game.c +2 -2
- data/ext/game.h +1 -1
- data/ext/special.c +10 -3
- data/ext/special.h +3 -2
- data/lib/chess/version.rb +1 -1
- data/test/test_load_fen.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 713285e67727bcfff37a5f5ca1f5d0df7df0bd6c
|
4
|
+
data.tar.gz: 37d1a5a1d261dc7f09d50c82bec412a2608fa121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a4bf8496ec140aa5718ef32451ce9875c9a5c456cec8aa05b49a0589ed22ce0194155352fb10436a569ff1599180cbebe05c9a23753fd5863cec6bd19249afa
|
7
|
+
data.tar.gz: 40f7d06171a88dead660f28ffa33394c196ab17a4ddd1a4d9f01d7780c720efc193cedfa2d12c4bd56bf3316c38792665a2a1977a59c8dad96b14844c8e0c9e8
|
data/ext/bitboard.c
CHANGED
data/ext/bitboard.h
CHANGED
data/ext/board.c
CHANGED
data/ext/board.h
CHANGED
data/ext/chess.c
CHANGED
data/ext/chess.h
CHANGED
data/ext/common.c
CHANGED
data/ext/common.h
CHANGED
data/ext/game.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* chess - a fast library to play chess in Ruby
|
3
3
|
*
|
4
|
-
* Copyright (c) 2011-
|
4
|
+
* Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
|
5
5
|
* This code is under LICENSE LGPLv3
|
6
6
|
*/
|
7
7
|
|
@@ -98,7 +98,7 @@ apply_move (Game *g, int from, int to, char promote_in)
|
|
98
98
|
}
|
99
99
|
}
|
100
100
|
// Ok move is legal, update the game
|
101
|
-
update_castling (new_board, from);
|
101
|
+
update_castling (new_board, from, to);
|
102
102
|
update_en_passant (new_board, from, to);
|
103
103
|
if (new_board->active_color)
|
104
104
|
new_board->fullmove_number++;
|
data/ext/game.h
CHANGED
data/ext/special.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* chess - a fast library to play chess in Ruby
|
3
3
|
*
|
4
|
-
* Copyright (c) 2011-
|
4
|
+
* Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
|
5
5
|
* This code is under LICENSE LGPLv3
|
6
6
|
*/
|
7
7
|
|
@@ -9,9 +9,9 @@
|
|
9
9
|
|
10
10
|
// Update the board castling bits (FEN style).
|
11
11
|
void
|
12
|
-
|
12
|
+
update_castling_by_square (Board *board, int square)
|
13
13
|
{
|
14
|
-
switch (
|
14
|
+
switch (square)
|
15
15
|
{
|
16
16
|
case A1:
|
17
17
|
board->castling ^= board->castling & 0x0100;
|
@@ -34,6 +34,13 @@ update_castling (Board *board, int from)
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
|
37
|
+
// Update the board castling bits checking if squares from and to are involved.
|
38
|
+
void
|
39
|
+
update_castling (Board *board, int from, int to) {
|
40
|
+
update_castling_by_square (board, from);
|
41
|
+
update_castling_by_square (board, to);
|
42
|
+
}
|
43
|
+
|
37
44
|
// Returns the castling type for the move from-to. If not a castling move
|
38
45
|
// returns 0.
|
39
46
|
int
|
data/ext/special.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* chess - a fast library to play chess in Ruby
|
3
3
|
*
|
4
|
-
* Copyright (c) 2011-
|
4
|
+
* Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
|
5
5
|
* This code is under LICENSE LGPLv3
|
6
6
|
*/
|
7
7
|
|
@@ -11,7 +11,8 @@
|
|
11
11
|
#include "common.h"
|
12
12
|
#include "board.h"
|
13
13
|
|
14
|
-
void
|
14
|
+
void update_castling_by_square (Board *board, int square);
|
15
|
+
void update_castling (Board *board, int from, int to);
|
15
16
|
int castling_type (Board *board, int from, int to);
|
16
17
|
char* castling (Board *board, int castling_type, Board *new_board);
|
17
18
|
void update_en_passant (Board *board, int from, int to);
|
data/lib/chess/version.rb
CHANGED
data/test/test_load_fen.rb
CHANGED
@@ -38,4 +38,16 @@ class ChessTest < Minitest::Test
|
|
38
38
|
assert_equal :stalemate, g.status
|
39
39
|
end
|
40
40
|
|
41
|
+
def test_fen_castling_from
|
42
|
+
g = Chess::Game.load_fen('2b1kbnr/rpq1pp1p/2n3p1/8/3Q4/2P5/PP3PPP/RN2KBNR w KQk - 0 9')
|
43
|
+
g.move('Kd1')
|
44
|
+
assert_equal '2b1kbnr/rpq1pp1p/2n3p1/8/3Q4/2P5/PP3PPP/RN1K1BNR b k - 1 9', g.board.to_fen
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_fen_castling_to
|
48
|
+
g = Chess::Game.load_fen('2b1kbnr/rpq1pp1p/2n3p1/8/3Q4/2P5/PP3PPP/RN2KBNR w KQk - 0 9')
|
49
|
+
g.move('Qh8')
|
50
|
+
assert_equal '2b1kbnQ/rpq1pp1p/2n3p1/8/8/2P5/PP3PPP/RN2KBNR b KQ - 0 9', g.board.to_fen
|
51
|
+
end
|
52
|
+
|
41
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Enrico Pilotto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|