chess 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/ext/chess.c +29 -0
  2. data/ext/chess.h +2 -0
  3. data/lib/chess/version.rb +1 -1
  4. metadata +2 -2
@@ -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);
@@ -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);
@@ -1,5 +1,5 @@
1
1
  # The Chess library module.
2
2
  module Chess
3
3
  # The library version.
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
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.1
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-01 00:00:00.000000000 Z
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: