chess 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/Chess/Board.html +8 -13
- data/doc/Chess/CGame.html +7 -8
- data/doc/README_rdoc.html +1 -1
- data/doc/created.rid +15 -15
- data/doc/index.html +1 -1
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/ext/bitboard.c +10 -18
- data/ext/board.c +14 -17
- data/ext/chess.c +20 -23
- data/ext/common.c +1 -1
- data/ext/game.c +5 -6
- data/lib/chess/version.rb +1 -1
- 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: 94e7a4ac7ec5ae63ad5987a9fb74e1dbc5cb7800
|
4
|
+
data.tar.gz: bd70ea660bd6c47e95da157e5ea2a6024465f3ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e097138279b50d5465e58c47cc2ca5b1967c1872c3db54811efd8a3267874996c68eb87637b6cc1842ac5af94f027c2ca016b9865541ca06880255ed3db432ea
|
7
|
+
data.tar.gz: b14cb7c634fb759d2d485f653915a311c98aa756494c2f6fb5fa072879e0a641151b4c2e090e91222ce1fb18eac490f0f5d7e4bf33fc13683559336312b5caee
|
data/doc/Chess/Board.html
CHANGED
@@ -185,14 +185,12 @@ board_get_piece (VALUE self, VALUE square)
|
|
185
185
|
Board *board;
|
186
186
|
Data_Get_Struct (self, Board, board);
|
187
187
|
int i;
|
188
|
-
char piece[2];
|
189
|
-
piece[1] = '\0';
|
190
188
|
if (TYPE (square) == T_STRING)
|
191
189
|
i = coord_to_square (StringValuePtr (square));
|
192
190
|
else
|
193
191
|
i = FIX2INT (square);
|
194
|
-
piece
|
195
|
-
return
|
192
|
+
char piece = board->placement[i];
|
193
|
+
return rb_str_new (&piece, 1);
|
196
194
|
}</pre>
|
197
195
|
</div>
|
198
196
|
|
@@ -529,25 +527,22 @@ board_placement (VALUE self)
|
|
529
527
|
{
|
530
528
|
Board *board;
|
531
529
|
Data_Get_Struct (self, Board, board);
|
532
|
-
int i;
|
533
|
-
char piece[2];
|
534
|
-
piece[1] = '\0';
|
535
530
|
if (!rb_block_given_p ())
|
536
531
|
{
|
537
532
|
VALUE placement = rb_ary_new ();
|
538
|
-
for (i = 0; i < 64; i++)
|
533
|
+
for (int i = 0; i < 64; i++)
|
539
534
|
{
|
540
|
-
piece
|
541
|
-
rb_ary_push (placement,
|
535
|
+
char piece = board->placement[i];
|
536
|
+
rb_ary_push (placement, rb_str_new (&piece, 1));
|
542
537
|
}
|
543
538
|
return placement;
|
544
539
|
}
|
545
540
|
else
|
546
541
|
{
|
547
|
-
for (i = 0; i < 64; i++)
|
542
|
+
for (int i = 0; i < 64; i++)
|
548
543
|
{
|
549
|
-
piece
|
550
|
-
rb_yield_values (2,
|
544
|
+
char piece = board->placement[i];
|
545
|
+
rb_yield_values (2, rb_str_new (&piece, 1), INT2FIX (i));
|
551
546
|
}
|
552
547
|
return self;
|
553
548
|
}
|
data/doc/Chess/CGame.html
CHANGED
@@ -242,9 +242,8 @@ game_coord_moves (VALUE self)
|
|
242
242
|
{
|
243
243
|
Game *g;
|
244
244
|
Data_Get_Struct (self, Game, g);
|
245
|
-
int i;
|
246
245
|
VALUE moves = rb_ary_new ();
|
247
|
-
for (i = 0; i < g->current; i++)
|
246
|
+
for (int i = 0; i < g->current; i++)
|
248
247
|
rb_ary_push (moves, rb_str_new2 (g->coord_moves[i]));
|
249
248
|
return moves;
|
250
249
|
}</pre>
|
@@ -372,12 +371,13 @@ game_each (VALUE self)
|
|
372
371
|
{
|
373
372
|
if (!rb_block_given_p ())
|
374
373
|
return game_moves(self);
|
375
|
-
int i;
|
376
374
|
Game *g;
|
377
375
|
Data_Get_Struct (self, Game, g);
|
378
|
-
for (i = 0; i < g->current; i++)
|
379
|
-
rb_yield_values (4,
|
380
|
-
|
376
|
+
for (int i = 0; i < g->current; i++)
|
377
|
+
rb_yield_values (4,
|
378
|
+
Data_Wrap_Struct (board_klass, 0, 0, get_board (g, i)),
|
379
|
+
rb_str_new2 (g->moves[i]),
|
380
|
+
rb_str_new2 (g->coord_moves[i]),
|
381
381
|
INT2FIX (i));
|
382
382
|
return self;
|
383
383
|
}</pre>
|
@@ -652,9 +652,8 @@ game_moves (VALUE self)
|
|
652
652
|
{
|
653
653
|
Game *g;
|
654
654
|
Data_Get_Struct (self, Game, g);
|
655
|
-
int i;
|
656
655
|
VALUE moves = rb_ary_new ();
|
657
|
-
for (i = 0; i < g->current; i++)
|
656
|
+
for (int i = 0; i < g->current; i++)
|
658
657
|
rb_ary_push (moves, rb_str_new2 (g->moves[i]));
|
659
658
|
return moves;
|
660
659
|
}</pre>
|
data/doc/README_rdoc.html
CHANGED
@@ -127,7 +127,7 @@ project and send a pull request.</p>
|
|
127
127
|
|
128
128
|
<h2 id="label-Copyright">Copyright<span><a href="#label-Copyright">¶</a> <a href="#top">↑</a></span></h2>
|
129
129
|
|
130
|
-
<p>Copyright ©
|
130
|
+
<p>Copyright © 2017 <a href="https://github.com/pioz">Enrico Pilotto
|
131
131
|
(@pioz)</a>. See <a
|
132
132
|
href="https://github.com/pioz/chess/blob/master/LICENSE">LICENSE</a> for
|
133
133
|
details.</p>
|
data/doc/created.rid
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
README.rdoc
|
3
|
-
lib/chess.rb
|
4
|
-
lib/chess/exceptions.rb
|
5
|
-
lib/chess/game.rb
|
6
|
-
lib/chess/gnuchess.rb
|
7
|
-
lib/chess/pgn.rb
|
8
|
-
lib/chess/utf8_notation.rb
|
9
|
-
lib/chess/version.rb
|
10
|
-
ext/bitboard.c
|
11
|
-
ext/board.c
|
12
|
-
ext/chess.c
|
13
|
-
ext/common.c
|
14
|
-
ext/game.c
|
15
|
-
ext/special.c
|
1
|
+
Thu, 20 Jul 2017 15:24:00 +0200
|
2
|
+
README.rdoc Thu, 20 Jul 2017 14:48:45 +0200
|
3
|
+
lib/chess.rb Thu, 20 Jul 2017 14:48:45 +0200
|
4
|
+
lib/chess/exceptions.rb Thu, 20 Jul 2017 14:48:45 +0200
|
5
|
+
lib/chess/game.rb Thu, 20 Jul 2017 14:48:45 +0200
|
6
|
+
lib/chess/gnuchess.rb Thu, 20 Jul 2017 14:48:45 +0200
|
7
|
+
lib/chess/pgn.rb Thu, 20 Jul 2017 14:48:45 +0200
|
8
|
+
lib/chess/utf8_notation.rb Thu, 20 Jul 2017 14:48:45 +0200
|
9
|
+
lib/chess/version.rb Thu, 20 Jul 2017 14:48:45 +0200
|
10
|
+
ext/bitboard.c Thu, 20 Jul 2017 15:18:42 +0200
|
11
|
+
ext/board.c Thu, 20 Jul 2017 15:21:27 +0200
|
12
|
+
ext/chess.c Thu, 20 Jul 2017 15:14:18 +0200
|
13
|
+
ext/common.c Thu, 20 Jul 2017 14:48:45 +0200
|
14
|
+
ext/game.c Thu, 20 Jul 2017 15:22:45 +0200
|
15
|
+
ext/special.c Thu, 20 Jul 2017 14:48:45 +0200
|
data/doc/index.html
CHANGED
@@ -144,7 +144,7 @@ project and send a pull request.</p>
|
|
144
144
|
|
145
145
|
<h2 id="label-Copyright">Copyright<span><a href="#label-Copyright">¶</a> <a href="#top">↑</a></span></h2>
|
146
146
|
|
147
|
-
<p>Copyright ©
|
147
|
+
<p>Copyright © 2017 <a href="https://github.com/pioz">Enrico Pilotto
|
148
148
|
(@pioz)</a>. See <a
|
149
149
|
href="https://github.com/pioz/chess/blob/master/LICENSE">LICENSE</a> for
|
150
150
|
details.</p>
|
data/doc/js/navigation.js.gz
CHANGED
Binary file
|
data/doc/js/search_index.js.gz
CHANGED
Binary file
|
data/doc/js/searcher.js.gz
CHANGED
Binary file
|
data/ext/bitboard.c
CHANGED
@@ -94,9 +94,8 @@ square2 (bboard b)
|
|
94
94
|
void
|
95
95
|
squares (bboard b, int *array, int *n)
|
96
96
|
{
|
97
|
-
int i;
|
98
97
|
*n = 0;
|
99
|
-
for (i = 0; i < 64; i++)
|
98
|
+
for (int i = 0; i < 64; i++)
|
100
99
|
if (b & 1ULL << i)
|
101
100
|
{
|
102
101
|
array[*n] = i;
|
@@ -130,10 +129,9 @@ get2 (bboard b, int file, int rank)
|
|
130
129
|
void
|
131
130
|
print_bitboard (bboard b)
|
132
131
|
{
|
133
|
-
int i
|
134
|
-
for (i = 7; i >= 0; i--) // rank => top to bottom
|
132
|
+
for (int i = 7; i >= 0; i--) // rank => top to bottom
|
135
133
|
{
|
136
|
-
for (j = 0; j < 8; j++) // file => left to right
|
134
|
+
for (int j = 0; j < 8; j++) // file => left to right
|
137
135
|
printf ("%d ", get2 (b, j, i) ? 1 : 0);
|
138
136
|
printf ("\n");
|
139
137
|
}
|
@@ -228,8 +226,7 @@ sliding_attacks (bboard slider, bboard propagator, int dir)
|
|
228
226
|
void
|
229
227
|
precalculate_xray_attack_white_pawn (bboard xray[64])
|
230
228
|
{
|
231
|
-
int i;
|
232
|
-
for (i = 0; i < 64; i++)
|
229
|
+
for (int i = 0; i < 64; i++)
|
233
230
|
{
|
234
231
|
xray[i] = EMPTY_BOARD;
|
235
232
|
xray[i] = shift_one (1ULL << i, 7) | shift_one (1ULL << i, 1);
|
@@ -239,8 +236,7 @@ precalculate_xray_attack_white_pawn (bboard xray[64])
|
|
239
236
|
void
|
240
237
|
precalculate_xray_attack_black_pawn (bboard xray[64])
|
241
238
|
{
|
242
|
-
int i;
|
243
|
-
for (i = 0; i < 64; i++)
|
239
|
+
for (int i = 0; i < 64; i++)
|
244
240
|
{
|
245
241
|
xray[i] = EMPTY_BOARD;
|
246
242
|
xray[i] = shift_one (1ULL << i, 5) | shift_one (1ULL << i, 3);
|
@@ -250,8 +246,7 @@ precalculate_xray_attack_black_pawn (bboard xray[64])
|
|
250
246
|
void
|
251
247
|
precalculate_xray_knight (bboard xray[64])
|
252
248
|
{
|
253
|
-
int i;
|
254
|
-
for (i = 0; i < 64; i++)
|
249
|
+
for (int i = 0; i < 64; i++)
|
255
250
|
{
|
256
251
|
xray[i] = 1ULL << i;
|
257
252
|
xray[i] = ((xray[i] << 17) & NOT_FILE_A)
|
@@ -268,11 +263,10 @@ precalculate_xray_knight (bboard xray[64])
|
|
268
263
|
void
|
269
264
|
precalculate_xray_king (bboard xray[64])
|
270
265
|
{
|
271
|
-
int i
|
272
|
-
for (i = 0; i < 64; i++)
|
266
|
+
for (int i = 0; i < 64; i++)
|
273
267
|
{
|
274
268
|
xray[i] = EMPTY_BOARD;
|
275
|
-
for (j = 0; j < 8; j++)
|
269
|
+
for (int j = 0; j < 8; j++)
|
276
270
|
xray[i] = sliding_attacks (1ULL << i, EMPTY_BOARD, j) | xray[i];
|
277
271
|
}
|
278
272
|
}
|
@@ -328,10 +322,9 @@ xray_attack_black_pawn (int square)
|
|
328
322
|
bboard
|
329
323
|
xray_rook (bboard occupied_square, int square)
|
330
324
|
{
|
331
|
-
int i, dir;
|
332
325
|
bboard xray[4];
|
333
326
|
bboard collision, shielded_square;
|
334
|
-
for (i = 0, dir = 0; i < 4; i++, dir+=2)
|
327
|
+
for (int i = 0, dir = 0; i < 4; i++, dir+=2)
|
335
328
|
{
|
336
329
|
xray[i] = sliding_attacks (1ULL << square, FULL_BOARD, dir);
|
337
330
|
collision = xray[i] & occupied_square;
|
@@ -350,10 +343,9 @@ xray_knight (int square)
|
|
350
343
|
bboard
|
351
344
|
xray_bishop (bboard occupied_square, int square)
|
352
345
|
{
|
353
|
-
int i, dir;
|
354
346
|
bboard xray[4];
|
355
347
|
bboard collision, shielded_square;
|
356
|
-
for (i = 0, dir = 1; i < 4; i++, dir+=2)
|
348
|
+
for (int i = 0, dir = 1; i < 4; i++, dir+=2)
|
357
349
|
{
|
358
350
|
xray[i] = sliding_attacks (1ULL << square, FULL_BOARD, dir);
|
359
351
|
collision = xray[i] & occupied_square;
|
data/ext/board.c
CHANGED
@@ -55,12 +55,11 @@ print_board (Board *board)
|
|
55
55
|
{
|
56
56
|
char *s = (char *) malloc (251);
|
57
57
|
int si = 0;
|
58
|
-
int i
|
59
|
-
for (i = 7; i >= 0; i--) // rank => top to bottom
|
58
|
+
for (int i = 7; i >= 0; i--) // rank => top to bottom
|
60
59
|
{
|
61
60
|
sprintf (&s[si], "\e[37m%d\e[0m ", i + 1);
|
62
61
|
si += 11;
|
63
|
-
for (j = 0; j < 8; j++) // file => left to right
|
62
|
+
for (int j = 0; j < 8; j++) // file => left to right
|
64
63
|
{
|
65
64
|
char piece = board->placement[8 * i + j];
|
66
65
|
sprintf (&s[si], "%c ", piece == 0 ? '.' : piece);
|
@@ -145,11 +144,10 @@ xray (Board *board, int from, bool only_attack)
|
|
145
144
|
bboard
|
146
145
|
all_xray (Board *board, int color, bool only_attack)
|
147
146
|
{
|
148
|
-
int i, piece_color;
|
149
147
|
bboard x = EMPTY_BOARD; // xray for all pieces
|
150
|
-
for (i = 0; i < 64; i++)
|
148
|
+
for (int i = 0; i < 64; i++)
|
151
149
|
{
|
152
|
-
piece_color = get_color (board, i);
|
150
|
+
int piece_color = get_color (board, i);
|
153
151
|
// Calculate xray for pieces of color [c]
|
154
152
|
if (piece_color == color)
|
155
153
|
x |= xray (board, i, only_attack);
|
@@ -180,10 +178,10 @@ remove_piece (Board *board, int square, Board *new_board)
|
|
180
178
|
int
|
181
179
|
same_pieces_that_can_capture_a_square (Board *board, int color, int square, int *pieces, char piece_filter)
|
182
180
|
{
|
183
|
-
int
|
181
|
+
int index = 0;
|
184
182
|
char p;
|
185
183
|
Board new_board;
|
186
|
-
for (i = 0; i < 64; i++)
|
184
|
+
for (int i = 0; i < 64; i++)
|
187
185
|
if (get_color (board, i) == color)
|
188
186
|
{
|
189
187
|
p = board->placement[i];
|
@@ -268,11 +266,10 @@ king_in_checkmate (Board *board, int color)
|
|
268
266
|
bool
|
269
267
|
stalemate (Board *board, int color)
|
270
268
|
{
|
271
|
-
int i, j;
|
272
269
|
int s[64];
|
273
270
|
int n;
|
274
271
|
Board new_board;
|
275
|
-
for (i = 0; i < 64; i++)
|
272
|
+
for (int i = 0; i < 64; i++)
|
276
273
|
if (get_color (board, i) == color)
|
277
274
|
{
|
278
275
|
bboard b = xray (board, i, FALSE) & ~board->pieces[color];
|
@@ -280,7 +277,7 @@ stalemate (Board *board, int color)
|
|
280
277
|
if (b)
|
281
278
|
{
|
282
279
|
squares (b, s, &n);
|
283
|
-
for (j = 0; j < n; j++)
|
280
|
+
for (int j = 0; j < n; j++)
|
284
281
|
if (try_move (board, i, s[j], 'Q', &new_board, 0, 0))
|
285
282
|
return FALSE;
|
286
283
|
}
|
@@ -342,15 +339,15 @@ pseudo_legal_move (Board *board, int from, int to)
|
|
342
339
|
void
|
343
340
|
get_coord (Board *board, char piece, const char *disambiguating, const char *to_coord, char promote_in, int *from, int *to)
|
344
341
|
{
|
345
|
-
int
|
342
|
+
int count = 0;
|
346
343
|
char file, rank;
|
347
344
|
bboard x;
|
348
345
|
*to = coord_to_square (to_coord);
|
349
346
|
if (!piece)
|
350
347
|
piece = 'P';
|
351
|
-
for (i = 0; i < 64; i++)
|
348
|
+
for (int i = 0; i < 64; i++)
|
352
349
|
{
|
353
|
-
c = get_color (board, i);
|
350
|
+
int c = get_color (board, i);
|
354
351
|
if (c == board->active_color && piece == toupper (board->placement[i]))
|
355
352
|
{
|
356
353
|
x = xray (board, i, FALSE) & ~board->pieces[c];
|
@@ -514,11 +511,11 @@ to_fen (Board *board)
|
|
514
511
|
{
|
515
512
|
// 1. Placement
|
516
513
|
char placement[65];
|
517
|
-
int
|
514
|
+
int cur = 0;
|
518
515
|
char p, pp = '-';
|
519
|
-
for (i = 7; i >= 0; i--)
|
516
|
+
for (int i = 7; i >= 0; i--)
|
520
517
|
{
|
521
|
-
for (j = 0; j < 8; j++)
|
518
|
+
for (int j = 0; j < 8; j++)
|
522
519
|
{
|
523
520
|
p = board->placement[j+i*8];
|
524
521
|
if (p == '\0' && p == pp)
|
data/ext/chess.c
CHANGED
@@ -248,9 +248,8 @@ game_moves (VALUE self)
|
|
248
248
|
{
|
249
249
|
Game *g;
|
250
250
|
Data_Get_Struct (self, Game, g);
|
251
|
-
int i;
|
252
251
|
VALUE moves = rb_ary_new ();
|
253
|
-
for (i = 0; i < g->current; i++)
|
252
|
+
for (int i = 0; i < g->current; i++)
|
254
253
|
rb_ary_push (moves, rb_str_new2 (g->moves[i]));
|
255
254
|
return moves;
|
256
255
|
}
|
@@ -265,9 +264,8 @@ game_coord_moves (VALUE self)
|
|
265
264
|
{
|
266
265
|
Game *g;
|
267
266
|
Data_Get_Struct (self, Game, g);
|
268
|
-
int i;
|
269
267
|
VALUE moves = rb_ary_new ();
|
270
|
-
for (i = 0; i < g->current; i++)
|
268
|
+
for (int i = 0; i < g->current; i++)
|
271
269
|
rb_ary_push (moves, rb_str_new2 (g->coord_moves[i]));
|
272
270
|
return moves;
|
273
271
|
}
|
@@ -344,12 +342,13 @@ game_each (VALUE self)
|
|
344
342
|
{
|
345
343
|
if (!rb_block_given_p ())
|
346
344
|
return game_moves(self);
|
347
|
-
int i;
|
348
345
|
Game *g;
|
349
346
|
Data_Get_Struct (self, Game, g);
|
350
|
-
for (i = 0; i < g->current; i++)
|
351
|
-
rb_yield_values (4,
|
352
|
-
|
347
|
+
for (int i = 0; i < g->current; i++)
|
348
|
+
rb_yield_values (4,
|
349
|
+
Data_Wrap_Struct (board_klass, 0, 0, get_board (g, i)),
|
350
|
+
rb_str_new2 (g->moves[i]),
|
351
|
+
rb_str_new2 (g->coord_moves[i]),
|
353
352
|
INT2FIX (i));
|
354
353
|
return self;
|
355
354
|
}
|
@@ -399,25 +398,22 @@ board_placement (VALUE self)
|
|
399
398
|
{
|
400
399
|
Board *board;
|
401
400
|
Data_Get_Struct (self, Board, board);
|
402
|
-
int i;
|
403
|
-
char piece[2];
|
404
|
-
piece[1] = '\0';
|
405
401
|
if (!rb_block_given_p ())
|
406
402
|
{
|
407
403
|
VALUE placement = rb_ary_new ();
|
408
|
-
for (i = 0; i < 64; i++)
|
404
|
+
for (int i = 0; i < 64; i++)
|
409
405
|
{
|
410
|
-
piece
|
411
|
-
rb_ary_push (placement,
|
406
|
+
char piece = board->placement[i];
|
407
|
+
rb_ary_push (placement, rb_str_new (&piece, 1));
|
412
408
|
}
|
413
409
|
return placement;
|
414
410
|
}
|
415
411
|
else
|
416
412
|
{
|
417
|
-
for (i = 0; i < 64; i++)
|
413
|
+
for (int i = 0; i < 64; i++)
|
418
414
|
{
|
419
|
-
piece
|
420
|
-
rb_yield_values (2,
|
415
|
+
char piece = board->placement[i];
|
416
|
+
rb_yield_values (2, rb_str_new (&piece, 1), INT2FIX (i));
|
421
417
|
}
|
422
418
|
return self;
|
423
419
|
}
|
@@ -427,7 +423,7 @@ board_placement (VALUE self)
|
|
427
423
|
* call-seq: [square]
|
428
424
|
*
|
429
425
|
* Returns the piece on the +square+ of the chessboard. If there is no piece or
|
430
|
-
* the square is not valid return
|
426
|
+
* the square is not valid return +nil+.
|
431
427
|
*
|
432
428
|
* Each square on the chessboard is represented by an integer according to the
|
433
429
|
* following scheme:
|
@@ -444,7 +440,7 @@ board_placement (VALUE self)
|
|
444
440
|
*
|
445
441
|
* Parameters are:
|
446
442
|
* +square+:: the square of the board. Can be a fixnum between 0 and 63 or a
|
447
|
-
* string like 'a2', 'c5'...
|
443
|
+
* string like 'a2', 'c5'...
|
448
444
|
*/
|
449
445
|
VALUE
|
450
446
|
board_get_piece (VALUE self, VALUE square)
|
@@ -452,14 +448,15 @@ board_get_piece (VALUE self, VALUE square)
|
|
452
448
|
Board *board;
|
453
449
|
Data_Get_Struct (self, Board, board);
|
454
450
|
int i;
|
455
|
-
char piece[2];
|
456
|
-
piece[1] = '\0';
|
457
451
|
if (TYPE (square) == T_STRING)
|
458
452
|
i = coord_to_square (StringValuePtr (square));
|
459
453
|
else
|
460
454
|
i = FIX2INT (square);
|
461
|
-
piece
|
462
|
-
|
455
|
+
char piece = board->placement[i];
|
456
|
+
if (i < 0 || i > 63 || !piece)
|
457
|
+
return Qnil;
|
458
|
+
else
|
459
|
+
return rb_str_new (&piece, 1);
|
463
460
|
}
|
464
461
|
|
465
462
|
/*
|
data/ext/common.c
CHANGED
data/ext/game.c
CHANGED
@@ -29,8 +29,7 @@ init_game ()
|
|
29
29
|
void
|
30
30
|
free_game (Game *g)
|
31
31
|
{
|
32
|
-
int i;
|
33
|
-
for (i = 0; i < g->current; i++)
|
32
|
+
for (int i = 0; i < g->current; i++)
|
34
33
|
{
|
35
34
|
free (g->boards[i]);
|
36
35
|
free (g->moves[i]);
|
@@ -54,7 +53,7 @@ get_board (Game *g, int index)
|
|
54
53
|
return &STARTING_BOARD;
|
55
54
|
if (index < g->current)
|
56
55
|
return g->boards[index];
|
57
|
-
return
|
56
|
+
return NULL;
|
58
57
|
}
|
59
58
|
|
60
59
|
char*
|
@@ -147,8 +146,8 @@ threefold_repetition (Game *g)
|
|
147
146
|
char* s[g->current + 1];
|
148
147
|
s[0] = (char *) malloc (80);
|
149
148
|
strcpy (s[0], "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -");
|
150
|
-
int i, j;
|
151
149
|
bool found = FALSE;
|
150
|
+
int i, j;
|
152
151
|
for (i = 0; i < g->current; i++)
|
153
152
|
{
|
154
153
|
fen = to_fen (g->boards[i]);
|
@@ -344,9 +343,9 @@ main ()
|
|
344
343
|
{
|
345
344
|
// Valgrind run
|
346
345
|
init_chess_library ();
|
347
|
-
int
|
346
|
+
int from, to;
|
348
347
|
|
349
|
-
for (i = 0; i < 1000; i++)
|
348
|
+
for (int i = 0; i < 1000; i++)
|
350
349
|
{
|
351
350
|
Game *g = init_game ();
|
352
351
|
Board *board;
|
data/lib/chess/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.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
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|