chess 0.0.1 → 0.0.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.
- data/ext/chess.c +29 -0
- data/ext/chess.h +2 -0
- data/lib/chess/version.rb +1 -1
- metadata +2 -2
data/ext/chess.c
CHANGED
@@ -275,8 +275,35 @@ game_each (VALUE self)
|
|
275
275
|
return self;
|
276
276
|
}
|
277
277
|
|
278
|
+
/*
|
279
|
+
* call-seq: rollback!
|
280
|
+
*
|
281
|
+
* Rollback last move.
|
282
|
+
*/
|
283
|
+
VALUE
|
284
|
+
game_rollback (VALUE self)
|
285
|
+
{
|
286
|
+
Game *g;
|
287
|
+
Data_Get_Struct (self, Game, g);
|
288
|
+
rollback (g);
|
289
|
+
return self;
|
290
|
+
}
|
291
|
+
|
278
292
|
// Board
|
279
293
|
|
294
|
+
/*
|
295
|
+
* call-seq: [square]
|
296
|
+
*
|
297
|
+
* Return the piece in +square+ of the board.
|
298
|
+
*/
|
299
|
+
VALUE
|
300
|
+
board_get_piece_at (VALUE self, VALUE square)
|
301
|
+
{
|
302
|
+
Board *board;
|
303
|
+
Data_Get_Struct (self, Board, board);
|
304
|
+
return CHR2FIX (board->placement[NUM2INT (square)]);
|
305
|
+
}
|
306
|
+
|
280
307
|
/*
|
281
308
|
* call-seq: check?
|
282
309
|
*
|
@@ -456,6 +483,7 @@ Init_chess ()
|
|
456
483
|
rb_define_method (game, "result", game_result, 0);
|
457
484
|
rb_define_method (game, "size", game_size, 0);
|
458
485
|
rb_define_method (game, "each", game_each, 0);
|
486
|
+
rb_define_method (game, "rollback!", game_rollback, 0);
|
459
487
|
|
460
488
|
/*
|
461
489
|
* This class rappresents a chess board.
|
@@ -463,6 +491,7 @@ Init_chess ()
|
|
463
491
|
* This ensures a fast library.
|
464
492
|
*/
|
465
493
|
board_klass = rb_define_class_under (chess, "Board", rb_cObject);
|
494
|
+
rb_define_method (board_klass, "[]", board_get_piece_at, 1);
|
466
495
|
rb_define_method (board_klass, "check?", board_king_in_check, 0);
|
467
496
|
rb_define_method (board_klass, "checkmate?", board_king_in_checkmate, 0);
|
468
497
|
rb_define_method (board_klass, "stalemate?", board_stalemate, 0);
|
data/ext/chess.h
CHANGED
@@ -23,10 +23,12 @@ VALUE game_threefold_repetition (VALUE self);
|
|
23
23
|
VALUE game_result (VALUE self);
|
24
24
|
VALUE game_size (VALUE self);
|
25
25
|
VALUE game_each (VALUE self);
|
26
|
+
VALUE game_rollback (VALUE self);
|
26
27
|
|
27
28
|
|
28
29
|
// Board
|
29
30
|
|
31
|
+
VALUE board_get_piece_at (VALUE self, VALUE square);
|
30
32
|
VALUE board_king_in_check (VALUE self);
|
31
33
|
VALUE board_king_in_checkmate (VALUE self);
|
32
34
|
VALUE board_stalemate (VALUE self);
|
data/lib/chess/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A fast chess library that use bitboards to play chess with Ruby.
|
15
15
|
email:
|