chess 0.1.3 → 0.1.4

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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +44 -0
  4. data/Rakefile +6 -7
  5. data/chess.gemspec +1 -1
  6. data/ext/bitboard.c +24 -0
  7. data/ext/board.c +78 -24
  8. data/ext/board.h +4 -2
  9. data/ext/chess.c +216 -196
  10. data/ext/chess.h +1 -0
  11. data/ext/common.c +10 -0
  12. data/ext/game.c +33 -16
  13. data/ext/special.c +14 -11
  14. data/ext/special.h +1 -2
  15. data/lib/chess/exceptions.rb +7 -10
  16. data/lib/chess/game.rb +66 -50
  17. data/lib/chess/gnuchess.rb +19 -25
  18. data/lib/chess/pgn.rb +49 -9
  19. data/lib/chess/utf8_notation.rb +11 -9
  20. data/lib/chess/version.rb +1 -1
  21. data/test/pgn_collection/illegal/0001.pgn +18 -0
  22. data/test/pgn_collection/illegal/0002.pgn +17 -0
  23. data/test/pgn_collection/illegal/0003.pgn +13 -0
  24. data/test/pgn_collection/illegal/0004.pgn +15 -0
  25. data/test/pgn_collection/illegal/0005.pgn +16 -0
  26. data/test/pgn_collection/invalid/0001.pgn +20 -0
  27. data/test/pgn_collection/invalid/0002.pgn +16 -0
  28. data/test/pgn_collection/invalid/0003.pgn +13 -0
  29. data/test/pgn_collection/invalid/0004.pgn +15 -0
  30. data/test/pgn_collection/valid/0001.pgn +6 -7
  31. data/test/pgn_collection/valid/0002.pgn +8 -9
  32. data/test/pgn_collection/valid/0005.pgn +7 -8
  33. data/test/pgn_collection/valid/0009.pgn +14 -15
  34. data/test/pgn_collection/valid/0010.pgn +6 -7
  35. data/test/pgn_collection/valid/0011.pgn +5 -6
  36. data/test/pgn_collection/valid/0012.pgn +0 -1
  37. data/test/pgn_collection/valid/0013.pgn +5 -6
  38. data/test/pgn_collection/valid/0014.pgn +6 -7
  39. data/test/pgn_collection/valid/0020.pgn +6 -7
  40. data/test/pgn_collection/valid/0021.pgn +15 -16
  41. data/test/pgn_collection/valid/0971.pgn +22 -14
  42. data/test/test_big_pgn_collection.rb +12 -5
  43. data/test/test_helper.rb +1 -1
  44. data/test/test_illegal_moves.rb +14 -0
  45. data/test/test_insufficient_material.rb +13 -1
  46. data/test/test_particular_situations.rb +14 -0
  47. data/test/test_pgn.rb +24 -0
  48. data/test/test_pgn_collection.rb +1 -4
  49. metadata +30 -63
  50. data/README.rdoc +0 -44
  51. data/doc/Chess.html +0 -112
  52. data/doc/Chess/BadNotationError.html +0 -107
  53. data/doc/Chess/Board.html +0 -700
  54. data/doc/Chess/CGame.html +0 -1004
  55. data/doc/Chess/Game.html +0 -684
  56. data/doc/Chess/Gnuchess.html +0 -215
  57. data/doc/Chess/IllegalMoveError.html +0 -105
  58. data/doc/Chess/InvalidFenFormatError.html +0 -105
  59. data/doc/Chess/InvalidPgnFormatError.html +0 -105
  60. data/doc/Chess/Pgn.html +0 -309
  61. data/doc/Chess/UTF8Notation.html +0 -174
  62. data/doc/README_rdoc.html +0 -143
  63. data/doc/created.rid +0 -15
  64. data/doc/css/fonts.css +0 -167
  65. data/doc/css/rdoc.css +0 -590
  66. data/doc/fonts/Lato-Light.ttf +0 -0
  67. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  68. data/doc/fonts/Lato-Regular.ttf +0 -0
  69. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  70. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  71. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  72. data/doc/images/add.png +0 -0
  73. data/doc/images/arrow_up.png +0 -0
  74. data/doc/images/brick.png +0 -0
  75. data/doc/images/brick_link.png +0 -0
  76. data/doc/images/bug.png +0 -0
  77. data/doc/images/bullet_black.png +0 -0
  78. data/doc/images/bullet_toggle_minus.png +0 -0
  79. data/doc/images/bullet_toggle_plus.png +0 -0
  80. data/doc/images/date.png +0 -0
  81. data/doc/images/delete.png +0 -0
  82. data/doc/images/find.png +0 -0
  83. data/doc/images/loadingAnimation.gif +0 -0
  84. data/doc/images/macFFBgHack.png +0 -0
  85. data/doc/images/package.png +0 -0
  86. data/doc/images/page_green.png +0 -0
  87. data/doc/images/page_white_text.png +0 -0
  88. data/doc/images/page_white_width.png +0 -0
  89. data/doc/images/plugin.png +0 -0
  90. data/doc/images/ruby.png +0 -0
  91. data/doc/images/tag_blue.png +0 -0
  92. data/doc/images/tag_green.png +0 -0
  93. data/doc/images/transparent.png +0 -0
  94. data/doc/images/wrench.png +0 -0
  95. data/doc/images/wrench_orange.png +0 -0
  96. data/doc/images/zoom.png +0 -0
  97. data/doc/index.html +0 -160
  98. data/doc/js/darkfish.js +0 -161
  99. data/doc/js/jquery.js +0 -4
  100. data/doc/js/navigation.js +0 -142
  101. data/doc/js/navigation.js.gz +0 -0
  102. data/doc/js/search.js +0 -109
  103. data/doc/js/search_index.js +0 -1
  104. data/doc/js/search_index.js.gz +0 -0
  105. data/doc/js/searcher.js +0 -229
  106. data/doc/js/searcher.js.gz +0 -0
  107. data/doc/table_of_contents.html +0 -331
Binary file
data/doc/js/search.js DELETED
@@ -1,109 +0,0 @@
1
- Search = function(data, input, result) {
2
- this.data = data;
3
- this.$input = $(input);
4
- this.$result = $(result);
5
-
6
- this.$current = null;
7
- this.$view = this.$result.parent();
8
- this.searcher = new Searcher(data.index);
9
- this.init();
10
- }
11
-
12
- Search.prototype = $.extend({}, Navigation, new function() {
13
- var suid = 1;
14
-
15
- this.init = function() {
16
- var _this = this;
17
- var observer = function(e) {
18
- switch(e.originalEvent.keyCode) {
19
- case 38: // Event.KEY_UP
20
- case 40: // Event.KEY_DOWN
21
- return;
22
- }
23
- _this.search(_this.$input[0].value);
24
- };
25
- this.$input.keyup(observer);
26
- this.$input.click(observer); // mac's clear field
27
-
28
- this.searcher.ready(function(results, isLast) {
29
- _this.addResults(results, isLast);
30
- })
31
-
32
- this.initNavigation();
33
- this.setNavigationActive(false);
34
- }
35
-
36
- this.search = function(value, selectFirstMatch) {
37
- value = jQuery.trim(value).toLowerCase();
38
- if (value) {
39
- this.setNavigationActive(true);
40
- } else {
41
- this.setNavigationActive(false);
42
- }
43
-
44
- if (value == '') {
45
- this.lastQuery = value;
46
- this.$result.empty();
47
- this.$result.attr('aria-expanded', 'false');
48
- this.setNavigationActive(false);
49
- } else if (value != this.lastQuery) {
50
- this.lastQuery = value;
51
- this.$result.attr('aria-busy', 'true');
52
- this.$result.attr('aria-expanded', 'true');
53
- this.firstRun = true;
54
- this.searcher.find(value);
55
- }
56
- }
57
-
58
- this.addResults = function(results, isLast) {
59
- var target = this.$result.get(0);
60
- if (this.firstRun && (results.length > 0 || isLast)) {
61
- this.$current = null;
62
- this.$result.empty();
63
- }
64
-
65
- for (var i=0, l = results.length; i < l; i++) {
66
- var item = this.renderItem.call(this, results[i]);
67
- item.setAttribute('id', 'search-result-' + target.childElementCount);
68
- target.appendChild(item);
69
- };
70
-
71
- if (this.firstRun && results.length > 0) {
72
- this.firstRun = false;
73
- this.$current = $(target.firstChild);
74
- this.$current.addClass('search-selected');
75
- }
76
- if (jQuery.browser.msie) this.$element[0].className += '';
77
-
78
- if (isLast) this.$result.attr('aria-busy', 'false');
79
- }
80
-
81
- this.move = function(isDown) {
82
- if (!this.$current) return;
83
- var $next = this.$current[isDown ? 'next' : 'prev']();
84
- if ($next.length) {
85
- this.$current.removeClass('search-selected');
86
- $next.addClass('search-selected');
87
- this.$input.attr('aria-activedescendant', $next.attr('id'));
88
- this.scrollIntoView($next[0], this.$view[0]);
89
- this.$current = $next;
90
- this.$input.val($next[0].firstChild.firstChild.text);
91
- this.$input.select();
92
- }
93
- return true;
94
- }
95
-
96
- this.hlt = function(html) {
97
- return this.escapeHTML(html).
98
- replace(/\u0001/g, '<em>').
99
- replace(/\u0002/g, '</em>');
100
- }
101
-
102
- this.escapeHTML = function(html) {
103
- return html.replace(/[&<>]/g, function(c) {
104
- return '&#' + c.charCodeAt(0) + ';';
105
- });
106
- }
107
-
108
- });
109
-
@@ -1 +0,0 @@
1
- var search_data = {"index":{"searchIndex":["chess","badnotationerror","board","cgame","game","gnuchess","illegalmoveerror","invalidfenformaterror","invalidpgnformaterror","pgn","utf8notation","<<()","[]()","[]()","active_color()","active_player()","board()","check?()","checkmate?()","coord_moves()","current()","draw()","each()","fifty_rule_move?()","fullmove_number()","gnuchess_move()","gnuchess_move!()","halfmove_clock()","inactive_player()","insufficient_material?()","load()","load_fen()","load_pgn()","move()","move()","move2()","move3()","move=()","moves()","moves=()","new()","new()","over?()","pgn()","placement()","resign()","result()","rollback!()","set_fen!()","size()","stalemate?()","status()","threefold_repetition?()","to_fen()","to_s()","to_s()","to_s()","to_utf8()","write()","readme"],"longSearchIndex":["chess","chess::badnotationerror","chess::board","chess::cgame","chess::game","chess::gnuchess","chess::illegalmoveerror","chess::invalidfenformaterror","chess::invalidpgnformaterror","chess::pgn","chess::utf8notation","chess::game#<<()","chess::board#[]()","chess::cgame#[]()","chess::board#active_color()","chess::game#active_player()","chess::cgame#board()","chess::board#check?()","chess::board#checkmate?()","chess::cgame#coord_moves()","chess::cgame#current()","chess::cgame#draw()","chess::cgame#each()","chess::board#fifty_rule_move?()","chess::board#fullmove_number()","chess::gnuchess#gnuchess_move()","chess::gnuchess#gnuchess_move!()","chess::board#halfmove_clock()","chess::game#inactive_player()","chess::board#insufficient_material?()","chess::pgn#load()","chess::game::load_fen()","chess::game::load_pgn()","chess::cgame#move()","chess::game#move()","chess::cgame#move2()","chess::cgame#move3()","chess::game#move=()","chess::cgame#moves()","chess::game#moves=()","chess::game::new()","chess::pgn::new()","chess::game#over?()","chess::game#pgn()","chess::board#placement()","chess::cgame#resign()","chess::cgame#result()","chess::cgame#rollback!()","chess::cgame#set_fen!()","chess::cgame#size()","chess::board#stalemate?()","chess::game#status()","chess::cgame#threefold_repetition?()","chess::board#to_fen()","chess::board#to_s()","chess::cgame#to_s()","chess::pgn#to_s()","chess::utf8notation#to_utf8()","chess::pgn#write()",""],"info":[["Chess","","Chess.html","","<p>The Chess library module.\n"],["Chess::BadNotationError","","Chess/BadNotationError.html","","<p>This exception will be raised when an invalid short algebraic chess\nnotation string is passed to the …\n"],["Chess::Board","","Chess/Board.html","","<p>This class rappresents a chess board. The rappresentation of the board use\n<em>bitboards</em> where each bit represents …\n"],["Chess::CGame","","Chess/CGame.html","","<p>This class rappresents a collection of boards of a single chess game.\n"],["Chess::Game","","Chess/Game.html","","<p>This class rappresents a chess game.\n"],["Chess::Gnuchess","","Chess/Gnuchess.html","","<p>Use Gnuchess to I.A. <em>(Only a draft)</em> To use this module, extend a\ngame object with Chess::Gnuchess. Gnuchess …\n"],["Chess::IllegalMoveError","","Chess/IllegalMoveError.html","","<p>This exception will be raised when making an illegal move.\n"],["Chess::InvalidFenFormatError","","Chess/InvalidFenFormatError.html","","<p>This exception will be raised when an invalid FEN string is used.\n"],["Chess::InvalidPgnFormatError","","Chess/InvalidPgnFormatError.html","","<p>This exception will be raised when a malformed PGN file is loaded.\n"],["Chess::Pgn","","Chess/Pgn.html","","<p>Rappresents a game in PGN (Portable Game Notation) format.\n"],["Chess::UTF8Notation","","Chess/UTF8Notation.html","","<p>With this module is possible call the method <code>to_utf8</code> on a\nstring. This method convert the chess piece …\n"],["<<","Chess::Game","Chess/Game.html#method-i-3C-3C","(m)",""],["[]","Chess::Board","Chess/Board.html#method-i-5B-5D","(p1)","<p>Returns the piece on the <code>square</code> of the chessboard. If there is\nno piece or the square is not valid return …\n"],["[]","Chess::CGame","Chess/CGame.html#method-i-5B-5D","(p1)","<p>Returns the <code>n</code>-th Board of the Game or <code>nil</code> if the\n<code>n</code>-th Board does not exist.\n"],["active_color","Chess::Board","Chess/Board.html#method-i-active_color","()","<p>Returns the active color: <code>false</code> means white turn,\n<code>true</code> means black turn.\n"],["active_player","Chess::Game","Chess/Game.html#method-i-active_player","()","<p>Returns <code>:white</code> if the active player is the white player,\n<code>:black</code> otherwise.\n"],["board","Chess::CGame","Chess/CGame.html#method-i-board","()",""],["check?","Chess::Board","Chess/Board.html#method-i-check-3F","()","<p>Returns <code>true</code> if the king of the color that has the turn is in\ncheck, <code>false</code> otherwise.\n"],["checkmate?","Chess::Board","Chess/Board.html#method-i-checkmate-3F","()","<p>Returns <code>true</code> if the king of the color that has the turn is in\ncheckmate, <code>false</code> otherwise.\n"],["coord_moves","Chess::CGame","Chess/CGame.html#method-i-coord_moves","()","<p>Returns the array with all moves done in coordinate chess notation <em>(es:\nb1c3)</em>.\n"],["current","Chess::CGame","Chess/CGame.html#method-i-current","()","<p>Returns the current Board of the Game (the current chess position of the\ngame).\n"],["draw","Chess::CGame","Chess/CGame.html#method-i-draw","()","<p>The game result is set to draw.\n"],["each","Chess::CGame","Chess/CGame.html#method-i-each","()","<p>Calls <code>block</code> once for each <code>board</code> in self, passing\nthat <code>board</code>, <code>move</code>, <code>coord_move</code> and\n<code>index</code> as parameters. …\n"],["fifty_rule_move?","Chess::Board","Chess/Board.html#method-i-fifty_rule_move-3F","()","<p>Returns <code>true</code> if a player can claim draw by the fifty-move\nrule, <code>false</code> otherwise.\n"],["fullmove_number","Chess::Board","Chess/Board.html#method-i-fullmove_number","()","<p>Returns the fullmove number: the number of the full move. It starts at 1,\nand is incremented after black&#39;s …\n"],["gnuchess_move","Chess::Gnuchess","Chess/Gnuchess.html#method-i-gnuchess_move","()","<p>Return the next move calculated by Gnuchess. Gnuchess must be installed!\n"],["gnuchess_move!","Chess::Gnuchess","Chess/Gnuchess.html#method-i-gnuchess_move-21","()","<p>Make a move using Gnuchess engine. This add a new Board in the Game. Return\nthe next move calculated …\n"],["halfmove_clock","Chess::Board","Chess/Board.html#method-i-halfmove_clock","()","<p>Returns the halfmove clock that is the number of halfmoves since the last\npawn advance or capture. This …\n"],["inactive_player","Chess::Game","Chess/Game.html#method-i-inactive_player","()","<p>Returns <code>:white</code> if the inactive player is the white player,\n<code>:black</code> otherwise.\n"],["insufficient_material?","Chess::Board","Chess/Board.html#method-i-insufficient_material-3F","()","<p>Returns <code>true</code> if the board has insufficient material to\ncheckmate, <code>false</code> otherwise.\n"],["load","Chess::Pgn","Chess/Pgn.html#method-i-load","(filename)","<p>Load a PGN from file.\n"],["load_fen","Chess::Game","Chess/Game.html#method-c-load_fen","(fen)","<p>Creates a new game from a FEN string.\n<p>May be raise an InvalidFenFormatError.\n<p><strong>Warning</strong>: this game do not …\n"],["load_pgn","Chess::Game","Chess/Game.html#method-c-load_pgn","(file)","<p>Creates a new game from a file in PGN format.\n<p>May be raise an InvalidPgnFormatError or IllegalMoveError …\n"],["move","Chess::CGame","Chess/CGame.html#method-i-move","(p1, p2, p3, p4)","<p>Make a move. This add a new Board in the Game.\n<p>Parameters are:\n<p>piece &mdash; the character of the moving piece …\n"],["move","Chess::Game","Chess/Game.html#method-i-move","(m)","<p>Make a move. This add a new Board in the Storyboard.\n<p>Parameters are:\n<p>m &mdash; represents the short algebraic chess …\n"],["move2","Chess::CGame","Chess/CGame.html#method-i-move2","(p1, p2, p3)","<p>Make a move. This add a new Board in the Game.\n<p>Parameters are:\n<p>from &mdash; the 2 character string representing …\n"],["move3","Chess::CGame","Chess/CGame.html#method-i-move3","(p1, p2, p3)","<p>Make a move. This add a new Board in the Game.\n<p>Each square on the chessboard is represented by an integer …\n"],["move=","Chess::Game","Chess/Game.html#method-i-move-3D","(m)",""],["moves","Chess::CGame","Chess/CGame.html#method-i-moves","()","<p>Returns the array with all moves done <em>(es: Nc3)</em>.\n"],["moves=","Chess::Game","Chess/Game.html#method-i-moves-3D","(moves)","<p>Make the array of moves.\n"],["new","Chess::Game","Chess/Game.html#method-c-new","(moves = [])","<p>Create a new game. If an array of moves is provided, the moves will be\nperformed.\n<p>May be raise an IllegalMoveError …\n"],["new","Chess::Pgn","Chess/Pgn.html#method-c-new","(filename = nil)","<p>Creates a new PGN. If param <code>filename</code>, load it from file.\n"],["over?","Chess::Game","Chess/Game.html#method-i-over-3F","()","<p>Returns <code>true</code> if the game is over\n"],["pgn","Chess::Game","Chess/Game.html#method-i-pgn","()","<p>Returns the PGN rappresenting the game.\n"],["placement","Chess::Board","Chess/Board.html#method-i-placement","()","<p>Calls <code>block</code> once for each square in the board, passing the\n<code>piece</code> in the square and the <code>index</code> as parameters.\n…\n"],["resign","Chess::CGame","Chess/CGame.html#method-i-resign","(p1)","<p>The game result is set to &#39;1-0&#39; if <code>color</code> is “black”,\notherwise is set to &#39;0-1&#39; …\n"],["result","Chess::CGame","Chess/CGame.html#method-i-result","()","<p>Returns the result of the game:\n<p>* &mdash; game in progress;\n<p>1-0 &mdash; white won;\n"],["rollback!","Chess::CGame","Chess/CGame.html#method-i-rollback-21","()","<p>Rollback last move.\n"],["set_fen!","Chess::CGame","Chess/CGame.html#method-i-set_fen-21","(p1)","<p>Set the game position with a FEN string.\n<p>Parameters are:\n<p>fen &mdash; the FEN (Forsyth–Edwards Notation) string …\n"],["size","Chess::CGame","Chess/CGame.html#method-i-size","()","<p>Returns the number of moves done.\n"],["stalemate?","Chess::Board","Chess/Board.html#method-i-stalemate-3F","()","<p>Returns <code>true</code> if the pieces of the color that has the turn are\nin stalemate, <code>false</code> otherwise.\n"],["status","Chess::Game","Chess/Game.html#method-i-status","()","<p>Returns the status of the game.\n<p>Possible states are:\n<p><p>in_progress &mdash; the game is in progress.\n"],["threefold_repetition?","Chess::CGame","Chess/CGame.html#method-i-threefold_repetition-3F","()","<p>Returns <code>true</code> if a player can claim draw by the threefold\nrepetition rule, <code>false</code> otherwise.\n"],["to_fen","Chess::Board","Chess/Board.html#method-i-to_fen","()","<p>Return the FEN string of the board.\n"],["to_s","Chess::Board","Chess/Board.html#method-i-to_s","()","<p>Board to string.\n"],["to_s","Chess::CGame","Chess/CGame.html#method-i-to_s","()","<p>Current board to string.\n"],["to_s","Chess::Pgn","Chess/Pgn.html#method-i-to_s","()","<p>PGN to string.\n"],["to_utf8","Chess::UTF8Notation","Chess/UTF8Notation.html#method-i-to_utf8","()","<p>Replace the piece identifier characters with UTF8 chess characters\n"],["write","Chess::Pgn","Chess/Pgn.html#method-i-write","(filename)","<p>Write PGN to file.\n"],["README","","README_rdoc.html","","<p>Chess\n<p>A fast Ruby library to play chess with Ruby. This library is quite fast\nbecause rappresent the game …\n"]]}}
Binary file
data/doc/js/searcher.js DELETED
@@ -1,229 +0,0 @@
1
- Searcher = function(data) {
2
- this.data = data;
3
- this.handlers = [];
4
- }
5
-
6
- Searcher.prototype = new function() {
7
- // search is performed in chunks of 1000 for non-blocking user input
8
- var CHUNK_SIZE = 1000;
9
- // do not try to find more than 100 results
10
- var MAX_RESULTS = 100;
11
- var huid = 1;
12
- var suid = 1;
13
- var runs = 0;
14
-
15
- this.find = function(query) {
16
- var queries = splitQuery(query);
17
- var regexps = buildRegexps(queries);
18
- var highlighters = buildHilighters(queries);
19
- var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
20
- var _this = this;
21
-
22
- this.currentSuid = state.n;
23
-
24
- if (!query) return;
25
-
26
- var run = function() {
27
- // stop current search thread if new search started
28
- if (state.n != _this.currentSuid) return;
29
-
30
- var results =
31
- performSearch(_this.data, regexps, queries, highlighters, state);
32
- var hasMore = (state.limit > 0 && state.pass < 4);
33
-
34
- triggerResults.call(_this, results, !hasMore);
35
- if (hasMore) {
36
- setTimeout(run, 2);
37
- }
38
- runs++;
39
- };
40
- runs = 0;
41
-
42
- // start search thread
43
- run();
44
- }
45
-
46
- /* ----- Events ------ */
47
- this.ready = function(fn) {
48
- fn.huid = huid;
49
- this.handlers.push(fn);
50
- }
51
-
52
- /* ----- Utilities ------ */
53
- function splitQuery(query) {
54
- return jQuery.grep(query.split(/(\s+|::?|\(\)?)/), function(string) {
55
- return string.match(/\S/);
56
- });
57
- }
58
-
59
- function buildRegexps(queries) {
60
- return jQuery.map(queries, function(query) {
61
- return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
62
- });
63
- }
64
-
65
- function buildHilighters(queries) {
66
- return jQuery.map(queries, function(query) {
67
- return jQuery.map(query.split(''), function(l, i) {
68
- return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
69
- }).join('');
70
- });
71
- }
72
-
73
- // function longMatchRegexp(index, longIndex, regexps) {
74
- // for (var i = regexps.length - 1; i >= 0; i--){
75
- // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
76
- // };
77
- // return true;
78
- // }
79
-
80
-
81
- /* ----- Mathchers ------ */
82
-
83
- /*
84
- * This record matches if the index starts with queries[0] and the record
85
- * matches all of the regexps
86
- */
87
- function matchPassBeginning(index, longIndex, queries, regexps) {
88
- if (index.indexOf(queries[0]) != 0) return false;
89
- for (var i=1, l = regexps.length; i < l; i++) {
90
- if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
91
- return false;
92
- };
93
- return true;
94
- }
95
-
96
- /*
97
- * This record matches if the longIndex starts with queries[0] and the
98
- * longIndex matches all of the regexps
99
- */
100
- function matchPassLongIndex(index, longIndex, queries, regexps) {
101
- if (longIndex.indexOf(queries[0]) != 0) return false;
102
- for (var i=1, l = regexps.length; i < l; i++) {
103
- if (!longIndex.match(regexps[i]))
104
- return false;
105
- };
106
- return true;
107
- }
108
-
109
- /*
110
- * This record matches if the index contains queries[0] and the record
111
- * matches all of the regexps
112
- */
113
- function matchPassContains(index, longIndex, queries, regexps) {
114
- if (index.indexOf(queries[0]) == -1) return false;
115
- for (var i=1, l = regexps.length; i < l; i++) {
116
- if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
117
- return false;
118
- };
119
- return true;
120
- }
121
-
122
- /*
123
- * This record matches if regexps[0] matches the index and the record
124
- * matches all of the regexps
125
- */
126
- function matchPassRegexp(index, longIndex, queries, regexps) {
127
- if (!index.match(regexps[0])) return false;
128
- for (var i=1, l = regexps.length; i < l; i++) {
129
- if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
130
- return false;
131
- };
132
- return true;
133
- }
134
-
135
-
136
- /* ----- Highlighters ------ */
137
- function highlightRegexp(info, queries, regexps, highlighters) {
138
- var result = createResult(info);
139
- for (var i=0, l = regexps.length; i < l; i++) {
140
- result.title = result.title.replace(regexps[i], highlighters[i]);
141
- result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
142
- };
143
- return result;
144
- }
145
-
146
- function hltSubstring(string, pos, length) {
147
- return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
148
- }
149
-
150
- function highlightQuery(info, queries, regexps, highlighters) {
151
- var result = createResult(info);
152
- var pos = 0;
153
- var lcTitle = result.title.toLowerCase();
154
-
155
- pos = lcTitle.indexOf(queries[0]);
156
- if (pos != -1) {
157
- result.title = hltSubstring(result.title, pos, queries[0].length);
158
- }
159
-
160
- result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
161
- for (var i=1, l = regexps.length; i < l; i++) {
162
- result.title = result.title.replace(regexps[i], highlighters[i]);
163
- result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
164
- };
165
- return result;
166
- }
167
-
168
- function createResult(info) {
169
- var result = {};
170
- result.title = info[0];
171
- result.namespace = info[1];
172
- result.path = info[2];
173
- result.params = info[3];
174
- result.snippet = info[4];
175
- result.badge = info[6];
176
- return result;
177
- }
178
-
179
- /* ----- Searching ------ */
180
- function performSearch(data, regexps, queries, highlighters, state) {
181
- var searchIndex = data.searchIndex;
182
- var longSearchIndex = data.longSearchIndex;
183
- var info = data.info;
184
- var result = [];
185
- var i = state.from;
186
- var l = searchIndex.length;
187
- var togo = CHUNK_SIZE;
188
- var matchFunc, hltFunc;
189
-
190
- while (state.pass < 4 && state.limit > 0 && togo > 0) {
191
- if (state.pass == 0) {
192
- matchFunc = matchPassBeginning;
193
- hltFunc = highlightQuery;
194
- } else if (state.pass == 1) {
195
- matchFunc = matchPassLongIndex;
196
- hltFunc = highlightQuery;
197
- } else if (state.pass == 2) {
198
- matchFunc = matchPassContains;
199
- hltFunc = highlightQuery;
200
- } else if (state.pass == 3) {
201
- matchFunc = matchPassRegexp;
202
- hltFunc = highlightRegexp;
203
- }
204
-
205
- for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
206
- if (info[i].n == state.n) continue;
207
- if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
208
- info[i].n = state.n;
209
- result.push(hltFunc(info[i], queries, regexps, highlighters));
210
- state.limit--;
211
- }
212
- };
213
- if (searchIndex.length <= i) {
214
- state.pass++;
215
- i = state.from = 0;
216
- } else {
217
- state.from = i;
218
- }
219
- }
220
- return result;
221
- }
222
-
223
- function triggerResults(results, isLast) {
224
- jQuery.each(this.handlers, function(i, fn) {
225
- fn.call(this, results, isLast)
226
- })
227
- }
228
- }
229
-
Binary file
@@ -1,331 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>Table of Contents - Chess</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "./";
11
- var index_rel_prefix = "./";
12
- </script>
13
-
14
- <script src="./js/jquery.js"></script>
15
- <script src="./js/darkfish.js"></script>
16
-
17
- <link href="./css/fonts.css" rel="stylesheet">
18
- <link href="./css/rdoc.css" rel="stylesheet">
19
-
20
-
21
-
22
- <body id="top" class="table-of-contents">
23
- <main role="main">
24
- <h1 class="class">Table of Contents - Chess</h1>
25
-
26
- <h2 id="pages">Pages</h2>
27
- <ul>
28
- <li class="file">
29
- <a href="README_rdoc.html">README</a>
30
-
31
- <ul>
32
- <li><a href="README_rdoc.html#label-Chess">Chess</a>
33
- <li><a href="README_rdoc.html#label-Requirements">Requirements</a>
34
- <li><a href="README_rdoc.html#label-Installation">Installation</a>
35
- <li><a href="README_rdoc.html#label-Usage">Usage</a>
36
- <li><a href="README_rdoc.html#label-Questions+or+problems-3F">Questions or problems?</a>
37
- <li><a href="README_rdoc.html#label-Copyright">Copyright</a>
38
- </ul>
39
- </li>
40
-
41
- </ul>
42
-
43
- <h2 id="classes">Classes and Modules</h2>
44
- <ul>
45
- <li class="module">
46
- <a href="Chess.html">Chess</a>
47
- </li>
48
- <li class="class">
49
- <a href="Chess/BadNotationError.html">Chess::BadNotationError</a>
50
- </li>
51
- <li class="class">
52
- <a href="Chess/Board.html">Chess::Board</a>
53
- </li>
54
- <li class="class">
55
- <a href="Chess/CGame.html">Chess::CGame</a>
56
- </li>
57
- <li class="class">
58
- <a href="Chess/Game.html">Chess::Game</a>
59
- </li>
60
- <li class="module">
61
- <a href="Chess/Gnuchess.html">Chess::Gnuchess</a>
62
- </li>
63
- <li class="class">
64
- <a href="Chess/IllegalMoveError.html">Chess::IllegalMoveError</a>
65
- </li>
66
- <li class="class">
67
- <a href="Chess/InvalidFenFormatError.html">Chess::InvalidFenFormatError</a>
68
- </li>
69
- <li class="class">
70
- <a href="Chess/InvalidPgnFormatError.html">Chess::InvalidPgnFormatError</a>
71
- </li>
72
- <li class="class">
73
- <a href="Chess/Pgn.html">Chess::Pgn</a>
74
- </li>
75
- <li class="module">
76
- <a href="Chess/UTF8Notation.html">Chess::UTF8Notation</a>
77
- </li>
78
- </ul>
79
-
80
- <h2 id="methods">Methods</h2>
81
- <ul>
82
-
83
- <li class="method">
84
- <a href="Chess/Game.html#method-c-load_fen">::load_fen</a>
85
- &mdash;
86
- <span class="container">Chess::Game</span>
87
-
88
- <li class="method">
89
- <a href="Chess/Game.html#method-c-load_pgn">::load_pgn</a>
90
- &mdash;
91
- <span class="container">Chess::Game</span>
92
-
93
- <li class="method">
94
- <a href="Chess/Game.html#method-c-new">::new</a>
95
- &mdash;
96
- <span class="container">Chess::Game</span>
97
-
98
- <li class="method">
99
- <a href="Chess/Pgn.html#method-c-new">::new</a>
100
- &mdash;
101
- <span class="container">Chess::Pgn</span>
102
-
103
- <li class="method">
104
- <a href="Chess/Game.html#method-i-3C-3C">#&lt;&lt;</a>
105
- &mdash;
106
- <span class="container">Chess::Game</span>
107
-
108
- <li class="method">
109
- <a href="Chess/Board.html#method-i-5B-5D">#[]</a>
110
- &mdash;
111
- <span class="container">Chess::Board</span>
112
-
113
- <li class="method">
114
- <a href="Chess/CGame.html#method-i-5B-5D">#[]</a>
115
- &mdash;
116
- <span class="container">Chess::CGame</span>
117
-
118
- <li class="method">
119
- <a href="Chess/Board.html#method-i-active_color">#active_color</a>
120
- &mdash;
121
- <span class="container">Chess::Board</span>
122
-
123
- <li class="method">
124
- <a href="Chess/Game.html#method-i-active_player">#active_player</a>
125
- &mdash;
126
- <span class="container">Chess::Game</span>
127
-
128
- <li class="method">
129
- <a href="Chess/CGame.html#method-i-board">#board</a>
130
- &mdash;
131
- <span class="container">Chess::CGame</span>
132
-
133
- <li class="method">
134
- <a href="Chess/Board.html#method-i-check-3F">#check?</a>
135
- &mdash;
136
- <span class="container">Chess::Board</span>
137
-
138
- <li class="method">
139
- <a href="Chess/Board.html#method-i-checkmate-3F">#checkmate?</a>
140
- &mdash;
141
- <span class="container">Chess::Board</span>
142
-
143
- <li class="method">
144
- <a href="Chess/CGame.html#method-i-coord_moves">#coord_moves</a>
145
- &mdash;
146
- <span class="container">Chess::CGame</span>
147
-
148
- <li class="method">
149
- <a href="Chess/CGame.html#method-i-current">#current</a>
150
- &mdash;
151
- <span class="container">Chess::CGame</span>
152
-
153
- <li class="method">
154
- <a href="Chess/CGame.html#method-i-draw">#draw</a>
155
- &mdash;
156
- <span class="container">Chess::CGame</span>
157
-
158
- <li class="method">
159
- <a href="Chess/CGame.html#method-i-each">#each</a>
160
- &mdash;
161
- <span class="container">Chess::CGame</span>
162
-
163
- <li class="method">
164
- <a href="Chess/Board.html#method-i-fifty_rule_move-3F">#fifty_rule_move?</a>
165
- &mdash;
166
- <span class="container">Chess::Board</span>
167
-
168
- <li class="method">
169
- <a href="Chess/Board.html#method-i-fullmove_number">#fullmove_number</a>
170
- &mdash;
171
- <span class="container">Chess::Board</span>
172
-
173
- <li class="method">
174
- <a href="Chess/Gnuchess.html#method-i-gnuchess_move">#gnuchess_move</a>
175
- &mdash;
176
- <span class="container">Chess::Gnuchess</span>
177
-
178
- <li class="method">
179
- <a href="Chess/Gnuchess.html#method-i-gnuchess_move-21">#gnuchess_move!</a>
180
- &mdash;
181
- <span class="container">Chess::Gnuchess</span>
182
-
183
- <li class="method">
184
- <a href="Chess/Board.html#method-i-halfmove_clock">#halfmove_clock</a>
185
- &mdash;
186
- <span class="container">Chess::Board</span>
187
-
188
- <li class="method">
189
- <a href="Chess/Game.html#method-i-inactive_player">#inactive_player</a>
190
- &mdash;
191
- <span class="container">Chess::Game</span>
192
-
193
- <li class="method">
194
- <a href="Chess/Board.html#method-i-insufficient_material-3F">#insufficient_material?</a>
195
- &mdash;
196
- <span class="container">Chess::Board</span>
197
-
198
- <li class="method">
199
- <a href="Chess/Pgn.html#method-i-load">#load</a>
200
- &mdash;
201
- <span class="container">Chess::Pgn</span>
202
-
203
- <li class="method">
204
- <a href="Chess/Game.html#method-i-move">#move</a>
205
- &mdash;
206
- <span class="container">Chess::Game</span>
207
-
208
- <li class="method">
209
- <a href="Chess/CGame.html#method-i-move">#move</a>
210
- &mdash;
211
- <span class="container">Chess::CGame</span>
212
-
213
- <li class="method">
214
- <a href="Chess/CGame.html#method-i-move2">#move2</a>
215
- &mdash;
216
- <span class="container">Chess::CGame</span>
217
-
218
- <li class="method">
219
- <a href="Chess/CGame.html#method-i-move3">#move3</a>
220
- &mdash;
221
- <span class="container">Chess::CGame</span>
222
-
223
- <li class="method">
224
- <a href="Chess/Game.html#method-i-move-3D">#move=</a>
225
- &mdash;
226
- <span class="container">Chess::Game</span>
227
-
228
- <li class="method">
229
- <a href="Chess/CGame.html#method-i-moves">#moves</a>
230
- &mdash;
231
- <span class="container">Chess::CGame</span>
232
-
233
- <li class="method">
234
- <a href="Chess/Game.html#method-i-moves-3D">#moves=</a>
235
- &mdash;
236
- <span class="container">Chess::Game</span>
237
-
238
- <li class="method">
239
- <a href="Chess/Game.html#method-i-over-3F">#over?</a>
240
- &mdash;
241
- <span class="container">Chess::Game</span>
242
-
243
- <li class="method">
244
- <a href="Chess/Game.html#method-i-pgn">#pgn</a>
245
- &mdash;
246
- <span class="container">Chess::Game</span>
247
-
248
- <li class="method">
249
- <a href="Chess/Board.html#method-i-placement">#placement</a>
250
- &mdash;
251
- <span class="container">Chess::Board</span>
252
-
253
- <li class="method">
254
- <a href="Chess/CGame.html#method-i-resign">#resign</a>
255
- &mdash;
256
- <span class="container">Chess::CGame</span>
257
-
258
- <li class="method">
259
- <a href="Chess/CGame.html#method-i-result">#result</a>
260
- &mdash;
261
- <span class="container">Chess::CGame</span>
262
-
263
- <li class="method">
264
- <a href="Chess/CGame.html#method-i-rollback-21">#rollback!</a>
265
- &mdash;
266
- <span class="container">Chess::CGame</span>
267
-
268
- <li class="method">
269
- <a href="Chess/CGame.html#method-i-set_fen-21">#set_fen!</a>
270
- &mdash;
271
- <span class="container">Chess::CGame</span>
272
-
273
- <li class="method">
274
- <a href="Chess/CGame.html#method-i-size">#size</a>
275
- &mdash;
276
- <span class="container">Chess::CGame</span>
277
-
278
- <li class="method">
279
- <a href="Chess/Board.html#method-i-stalemate-3F">#stalemate?</a>
280
- &mdash;
281
- <span class="container">Chess::Board</span>
282
-
283
- <li class="method">
284
- <a href="Chess/Game.html#method-i-status">#status</a>
285
- &mdash;
286
- <span class="container">Chess::Game</span>
287
-
288
- <li class="method">
289
- <a href="Chess/CGame.html#method-i-threefold_repetition-3F">#threefold_repetition?</a>
290
- &mdash;
291
- <span class="container">Chess::CGame</span>
292
-
293
- <li class="method">
294
- <a href="Chess/Board.html#method-i-to_fen">#to_fen</a>
295
- &mdash;
296
- <span class="container">Chess::Board</span>
297
-
298
- <li class="method">
299
- <a href="Chess/Board.html#method-i-to_s">#to_s</a>
300
- &mdash;
301
- <span class="container">Chess::Board</span>
302
-
303
- <li class="method">
304
- <a href="Chess/CGame.html#method-i-to_s">#to_s</a>
305
- &mdash;
306
- <span class="container">Chess::CGame</span>
307
-
308
- <li class="method">
309
- <a href="Chess/Pgn.html#method-i-to_s">#to_s</a>
310
- &mdash;
311
- <span class="container">Chess::Pgn</span>
312
-
313
- <li class="method">
314
- <a href="Chess/UTF8Notation.html#method-i-to_utf8">#to_utf8</a>
315
- &mdash;
316
- <span class="container">Chess::UTF8Notation</span>
317
-
318
- <li class="method">
319
- <a href="Chess/Pgn.html#method-i-write">#write</a>
320
- &mdash;
321
- <span class="container">Chess::Pgn</span>
322
- </ul>
323
- </main>
324
-
325
-
326
- <footer id="validator-badges" role="contentinfo">
327
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
328
- <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
329
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
330
- </footer>
331
-