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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94f141e456c7e4e8785e896078d23b7841b7ce69
4
- data.tar.gz: 6322e565f5d324f9690c21f525b60d64937c0777
3
+ metadata.gz: 713285e67727bcfff37a5f5ca1f5d0df7df0bd6c
4
+ data.tar.gz: 37d1a5a1d261dc7f09d50c82bec412a2608fa121
5
5
  SHA512:
6
- metadata.gz: 56838a11d896e19e7bfdd5cda01652ec85f00128182ecdff3caaad87464ca4c6e02c812d996bf1bb97d02ca7d684437a4c602f2b5e2603a656a35cbe6b5bb999
7
- data.tar.gz: 1794476a87a451831cb07dc4d37c07c60db55081cb61a33ee5ae72174d309c2c5d50726bbb7011f7b8f39c992789f47c742879281caefa833d2c995754641012
6
+ metadata.gz: 7a4bf8496ec140aa5718ef32451ce9875c9a5c456cec8aa05b49a0589ed22ce0194155352fb10436a569ff1599180cbebe05c9a23753fd5863cec6bd19249afa
7
+ data.tar.gz: 40f7d06171a88dead660f28ffa33394c196ab17a4ddd1a4d9f01d7780c720efc193cedfa2d12c4bd56bf3316c38792665a2a1977a59c8dad96b14844c8e0c9e8
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
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-2017, Enrico Pilotto <epilotto@gmx.com>
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
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
4
+ * Copyright (c) 2011-2018, Enrico Pilotto <epilotto@gmx.com>
5
5
  * This code is under LICENSE LGPLv3
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
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
- update_castling (Board *board, int from)
12
+ update_castling_by_square (Board *board, int square)
13
13
  {
14
- switch (from)
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
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * chess - a fast library to play chess in Ruby
3
3
  *
4
- * Copyright (c) 2011-2017, Enrico Pilotto <epilotto@gmx.com>
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 update_castling (Board *board, int from);
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);
@@ -1,5 +1,5 @@
1
1
  # The Chess library module.
2
2
  module Chess
3
3
  # The library version.
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
@@ -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.1
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: 2017-11-01 00:00:00.000000000 Z
11
+ date: 2018-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler