chess 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +44 -0
- data/Rakefile +6 -7
- data/chess.gemspec +1 -1
- data/ext/bitboard.c +24 -0
- data/ext/board.c +78 -24
- data/ext/board.h +4 -2
- data/ext/chess.c +216 -196
- data/ext/chess.h +1 -0
- data/ext/common.c +10 -0
- data/ext/game.c +33 -16
- data/ext/special.c +14 -11
- data/ext/special.h +1 -2
- data/lib/chess/exceptions.rb +7 -10
- data/lib/chess/game.rb +66 -50
- data/lib/chess/gnuchess.rb +19 -25
- data/lib/chess/pgn.rb +49 -9
- data/lib/chess/utf8_notation.rb +11 -9
- data/lib/chess/version.rb +1 -1
- data/test/pgn_collection/illegal/0001.pgn +18 -0
- data/test/pgn_collection/illegal/0002.pgn +17 -0
- data/test/pgn_collection/illegal/0003.pgn +13 -0
- data/test/pgn_collection/illegal/0004.pgn +15 -0
- data/test/pgn_collection/illegal/0005.pgn +16 -0
- data/test/pgn_collection/invalid/0001.pgn +20 -0
- data/test/pgn_collection/invalid/0002.pgn +16 -0
- data/test/pgn_collection/invalid/0003.pgn +13 -0
- data/test/pgn_collection/invalid/0004.pgn +15 -0
- data/test/pgn_collection/valid/0001.pgn +6 -7
- data/test/pgn_collection/valid/0002.pgn +8 -9
- data/test/pgn_collection/valid/0005.pgn +7 -8
- data/test/pgn_collection/valid/0009.pgn +14 -15
- data/test/pgn_collection/valid/0010.pgn +6 -7
- data/test/pgn_collection/valid/0011.pgn +5 -6
- data/test/pgn_collection/valid/0012.pgn +0 -1
- data/test/pgn_collection/valid/0013.pgn +5 -6
- data/test/pgn_collection/valid/0014.pgn +6 -7
- data/test/pgn_collection/valid/0020.pgn +6 -7
- data/test/pgn_collection/valid/0021.pgn +15 -16
- data/test/pgn_collection/valid/0971.pgn +22 -14
- data/test/test_big_pgn_collection.rb +12 -5
- data/test/test_helper.rb +1 -1
- data/test/test_illegal_moves.rb +14 -0
- data/test/test_insufficient_material.rb +13 -1
- data/test/test_particular_situations.rb +14 -0
- data/test/test_pgn.rb +24 -0
- data/test/test_pgn_collection.rb +1 -4
- metadata +30 -63
- data/README.rdoc +0 -44
- data/doc/Chess.html +0 -112
- data/doc/Chess/BadNotationError.html +0 -107
- data/doc/Chess/Board.html +0 -700
- data/doc/Chess/CGame.html +0 -1004
- data/doc/Chess/Game.html +0 -684
- data/doc/Chess/Gnuchess.html +0 -215
- data/doc/Chess/IllegalMoveError.html +0 -105
- data/doc/Chess/InvalidFenFormatError.html +0 -105
- data/doc/Chess/InvalidPgnFormatError.html +0 -105
- data/doc/Chess/Pgn.html +0 -309
- data/doc/Chess/UTF8Notation.html +0 -174
- data/doc/README_rdoc.html +0 -143
- data/doc/created.rid +0 -15
- data/doc/css/fonts.css +0 -167
- data/doc/css/rdoc.css +0 -590
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -160
- data/doc/js/darkfish.js +0 -161
- data/doc/js/jquery.js +0 -4
- data/doc/js/navigation.js +0 -142
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +0 -109
- data/doc/js/search_index.js +0 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +0 -229
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +0 -331
data/README.rdoc
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
= Chess
|
2
|
-
|
3
|
-
A fast Ruby library to play chess with Ruby.
|
4
|
-
This library is quite fast because rappresent
|
5
|
-
the game situations with bitboards. In addition, the
|
6
|
-
move generator is written in C as a Ruby extension.
|
7
|
-
|
8
|
-
== Requirements
|
9
|
-
|
10
|
-
* Ruby 1.9 or higher
|
11
|
-
|
12
|
-
== Installation
|
13
|
-
|
14
|
-
gem install chess
|
15
|
-
|
16
|
-
== Usage
|
17
|
-
|
18
|
-
require 'chess'
|
19
|
-
g = Chess::Game.new
|
20
|
-
until g.over?
|
21
|
-
begin
|
22
|
-
print "Give me a #{g.active_player} move: "
|
23
|
-
input = gets.chop
|
24
|
-
break if input == 'quit'
|
25
|
-
g << input
|
26
|
-
puts g
|
27
|
-
puts g.moves.last
|
28
|
-
rescue Chess::IllegalMoveError => e
|
29
|
-
puts 'Illegal move!'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
puts g.status
|
33
|
-
|
34
|
-
Documentation is available {here}[http://pioz.github.com/chess].
|
35
|
-
|
36
|
-
== Questions or problems?
|
37
|
-
|
38
|
-
If you have any issues please add an {issue on GitHub}[https://github.com/pioz/chess/issues]
|
39
|
-
or fork the project and send a pull request.
|
40
|
-
|
41
|
-
== Copyright
|
42
|
-
|
43
|
-
Copyright (c) 2017 {Enrico Pilotto (@pioz)}[https://github.com/pioz].
|
44
|
-
See {LICENSE}[https://github.com/pioz/chess/blob/master/LICENSE] for details.
|
data/doc/Chess.html
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>module Chess - 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" role="document" class="module">
|
23
|
-
<nav role="navigation">
|
24
|
-
<div id="project-navigation">
|
25
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
-
<h2>
|
27
|
-
<a href="./index.html" rel="home">Home</a>
|
28
|
-
</h2>
|
29
|
-
|
30
|
-
<div id="table-of-contents-navigation">
|
31
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
32
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
33
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
|
37
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
-
<form action="#" method="get" accept-charset="utf-8">
|
39
|
-
<div id="search-field-wrapper">
|
40
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
-
aria-autocomplete="list" aria-controls="search-results"
|
42
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<ul id="search-results" aria-label="Search Results"
|
47
|
-
aria-busy="false" aria-expanded="false"
|
48
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
-
</form>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
</div>
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<div id="class-metadata">
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
</div>
|
63
|
-
</nav>
|
64
|
-
|
65
|
-
<main role="main" aria-labelledby="module-Chess">
|
66
|
-
<h1 id="module-Chess" class="module">
|
67
|
-
module Chess
|
68
|
-
</h1>
|
69
|
-
|
70
|
-
<section class="description">
|
71
|
-
|
72
|
-
<p>The <a href="Chess.html">Chess</a> library module.</p>
|
73
|
-
|
74
|
-
</section>
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
<section class="constants-list">
|
86
|
-
<header>
|
87
|
-
<h3>Constants</h3>
|
88
|
-
</header>
|
89
|
-
<dl>
|
90
|
-
|
91
|
-
<dt id="VERSION">VERSION
|
92
|
-
|
93
|
-
<dd><p>The library version.</p>
|
94
|
-
|
95
|
-
|
96
|
-
</dl>
|
97
|
-
</section>
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
</section>
|
104
|
-
</main>
|
105
|
-
|
106
|
-
|
107
|
-
<footer id="validator-badges" role="contentinfo">
|
108
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
109
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
110
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
111
|
-
</footer>
|
112
|
-
|
@@ -1,107 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Chess::BadNotationError - 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" role="document" class="class">
|
23
|
-
<nav role="navigation">
|
24
|
-
<div id="project-navigation">
|
25
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
-
<h2>
|
27
|
-
<a href="../index.html" rel="home">Home</a>
|
28
|
-
</h2>
|
29
|
-
|
30
|
-
<div id="table-of-contents-navigation">
|
31
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
32
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
33
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
|
37
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
-
<form action="#" method="get" accept-charset="utf-8">
|
39
|
-
<div id="search-field-wrapper">
|
40
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
-
aria-autocomplete="list" aria-controls="search-results"
|
42
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<ul id="search-results" aria-label="Search Results"
|
47
|
-
aria-busy="false" aria-expanded="false"
|
48
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
-
</form>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
</div>
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<div id="class-metadata">
|
57
|
-
|
58
|
-
<div id="parent-class-section" class="nav-section">
|
59
|
-
<h3>Parent</h3>
|
60
|
-
|
61
|
-
|
62
|
-
<p class="link">StandardError
|
63
|
-
|
64
|
-
</div>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
</div>
|
70
|
-
</nav>
|
71
|
-
|
72
|
-
<main role="main" aria-labelledby="class-Chess::BadNotationError">
|
73
|
-
<h1 id="class-Chess::BadNotationError" class="class">
|
74
|
-
class Chess::BadNotationError
|
75
|
-
</h1>
|
76
|
-
|
77
|
-
<section class="description">
|
78
|
-
|
79
|
-
<p>This exception will be raised when an invalid short algebraic chess
|
80
|
-
notation string is passed to the <a
|
81
|
-
href="Game.html#method-i-move">Chess::Game#move</a> function.</p>
|
82
|
-
|
83
|
-
</section>
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
</section>
|
99
|
-
</main>
|
100
|
-
|
101
|
-
|
102
|
-
<footer id="validator-badges" role="contentinfo">
|
103
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
104
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
105
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
106
|
-
</footer>
|
107
|
-
|
data/doc/Chess/Board.html
DELETED
@@ -1,700 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Chess::Board - 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" role="document" class="class">
|
23
|
-
<nav role="navigation">
|
24
|
-
<div id="project-navigation">
|
25
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
-
<h2>
|
27
|
-
<a href="../index.html" rel="home">Home</a>
|
28
|
-
</h2>
|
29
|
-
|
30
|
-
<div id="table-of-contents-navigation">
|
31
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
32
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
33
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
|
37
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
-
<form action="#" method="get" accept-charset="utf-8">
|
39
|
-
<div id="search-field-wrapper">
|
40
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
-
aria-autocomplete="list" aria-controls="search-results"
|
42
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<ul id="search-results" aria-label="Search Results"
|
47
|
-
aria-busy="false" aria-expanded="false"
|
48
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
-
</form>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
</div>
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<div id="class-metadata">
|
57
|
-
|
58
|
-
<div id="parent-class-section" class="nav-section">
|
59
|
-
<h3>Parent</h3>
|
60
|
-
|
61
|
-
|
62
|
-
<p class="link">Object
|
63
|
-
|
64
|
-
</div>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
<!-- Method Quickref -->
|
69
|
-
<div id="method-list-section" class="nav-section">
|
70
|
-
<h3>Methods</h3>
|
71
|
-
|
72
|
-
<ul class="link-list" role="directory">
|
73
|
-
|
74
|
-
<li ><a href="#method-i-5B-5D">#[]</a>
|
75
|
-
|
76
|
-
<li ><a href="#method-i-active_color">#active_color</a>
|
77
|
-
|
78
|
-
<li ><a href="#method-i-check-3F">#check?</a>
|
79
|
-
|
80
|
-
<li ><a href="#method-i-checkmate-3F">#checkmate?</a>
|
81
|
-
|
82
|
-
<li ><a href="#method-i-fifty_rule_move-3F">#fifty_rule_move?</a>
|
83
|
-
|
84
|
-
<li ><a href="#method-i-fullmove_number">#fullmove_number</a>
|
85
|
-
|
86
|
-
<li ><a href="#method-i-halfmove_clock">#halfmove_clock</a>
|
87
|
-
|
88
|
-
<li ><a href="#method-i-insufficient_material-3F">#insufficient_material?</a>
|
89
|
-
|
90
|
-
<li ><a href="#method-i-placement">#placement</a>
|
91
|
-
|
92
|
-
<li ><a href="#method-i-stalemate-3F">#stalemate?</a>
|
93
|
-
|
94
|
-
<li ><a href="#method-i-to_fen">#to_fen</a>
|
95
|
-
|
96
|
-
<li ><a href="#method-i-to_s">#to_s</a>
|
97
|
-
|
98
|
-
</ul>
|
99
|
-
</div>
|
100
|
-
|
101
|
-
</div>
|
102
|
-
</nav>
|
103
|
-
|
104
|
-
<main role="main" aria-labelledby="class-Chess::Board">
|
105
|
-
<h1 id="class-Chess::Board" class="class">
|
106
|
-
class Chess::Board
|
107
|
-
</h1>
|
108
|
-
|
109
|
-
<section class="description">
|
110
|
-
|
111
|
-
<p>This class rappresents a chess board. The rappresentation of the board use
|
112
|
-
<em>bitboards</em> where each bit represents a game position or state,
|
113
|
-
designed for optimization of speed and/or memory or disk use in mass
|
114
|
-
calculations. This ensures a fast library.</p>
|
115
|
-
|
116
|
-
</section>
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
132
|
-
<header>
|
133
|
-
<h3>Public Instance Methods</h3>
|
134
|
-
</header>
|
135
|
-
|
136
|
-
|
137
|
-
<div id="method-i-5B-5D" class="method-detail ">
|
138
|
-
|
139
|
-
|
140
|
-
<div class="method-heading">
|
141
|
-
<span class="method-callseq">
|
142
|
-
[square]
|
143
|
-
</span>
|
144
|
-
|
145
|
-
<span class="method-click-advice">click to toggle source</span>
|
146
|
-
|
147
|
-
</div>
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
<div class="method-description">
|
152
|
-
|
153
|
-
<p>Returns the piece on the <code>square</code> of the chessboard. If there is
|
154
|
-
no piece or the square is not valid return <code>nil</code>.</p>
|
155
|
-
|
156
|
-
<p>Each square on the chessboard is represented by an integer according to the
|
157
|
-
following scheme:</p>
|
158
|
-
|
159
|
-
<pre>8 | 56 57 58 59 60 61 62 63
|
160
|
-
7 | 48 49 50 51 52 53 54 55
|
161
|
-
6 | 40 41 42 43 44 45 46 47
|
162
|
-
5 | 32 33 34 35 36 37 38 39
|
163
|
-
4 | 24 25 26 27 28 29 30 31
|
164
|
-
3 | 16 17 18 19 20 21 22 23
|
165
|
-
2 | 8 9 10 11 12 13 14 15
|
166
|
-
1 | 0 1 2 3 4 5 6 7
|
167
|
-
+-------------------------
|
168
|
-
a b c d e f g h</pre>
|
169
|
-
|
170
|
-
<p>Parameters are:</p>
|
171
|
-
<dl class="rdoc-list note-list"><dt><code>square</code>
|
172
|
-
<dd>
|
173
|
-
<p>the square of the board. Can be an integer between 0 and 63 or a string
|
174
|
-
like 'a2', 'c5'…</p>
|
175
|
-
</dd></dl>
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
<div class="method-source-code" id="5B-5D-source">
|
181
|
-
<pre>VALUE
|
182
|
-
board_get_piece (VALUE self, VALUE square)
|
183
|
-
{
|
184
|
-
Board *board;
|
185
|
-
Data_Get_Struct (self, Board, board);
|
186
|
-
int i;
|
187
|
-
if (TYPE (square) == T_STRING)
|
188
|
-
i = coord_to_square (StringValuePtr (square));
|
189
|
-
else
|
190
|
-
i = FIX2INT (square);
|
191
|
-
char piece = board->placement[i];
|
192
|
-
if (i < 0 || i > 63 || !piece)
|
193
|
-
return Qnil;
|
194
|
-
else
|
195
|
-
return rb_str_new (&piece, 1);
|
196
|
-
}</pre>
|
197
|
-
</div>
|
198
|
-
|
199
|
-
</div>
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
</div>
|
205
|
-
|
206
|
-
|
207
|
-
<div id="method-i-active_color" class="method-detail ">
|
208
|
-
|
209
|
-
|
210
|
-
<div class="method-heading">
|
211
|
-
<span class="method-callseq">
|
212
|
-
active_color
|
213
|
-
</span>
|
214
|
-
|
215
|
-
<span class="method-click-advice">click to toggle source</span>
|
216
|
-
|
217
|
-
</div>
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
<div class="method-description">
|
222
|
-
|
223
|
-
<p>Returns the active color: <code>false</code> means white turn,
|
224
|
-
<code>true</code> means black turn.</p>
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
<div class="method-source-code" id="active_color-source">
|
230
|
-
<pre>VALUE
|
231
|
-
board_active_color (VALUE self)
|
232
|
-
{
|
233
|
-
Board *board;
|
234
|
-
Data_Get_Struct (self, Board, board);
|
235
|
-
if (board->active_color)
|
236
|
-
return Qtrue;
|
237
|
-
else
|
238
|
-
return Qfalse;
|
239
|
-
}</pre>
|
240
|
-
</div>
|
241
|
-
|
242
|
-
</div>
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
</div>
|
248
|
-
|
249
|
-
|
250
|
-
<div id="method-i-check-3F" class="method-detail ">
|
251
|
-
|
252
|
-
|
253
|
-
<div class="method-heading">
|
254
|
-
<span class="method-callseq">
|
255
|
-
check?
|
256
|
-
</span>
|
257
|
-
|
258
|
-
<span class="method-click-advice">click to toggle source</span>
|
259
|
-
|
260
|
-
</div>
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
<div class="method-description">
|
265
|
-
|
266
|
-
<p>Returns <code>true</code> if the king of the color that has the turn is in
|
267
|
-
check, <code>false</code> otherwise.</p>
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
<div class="method-source-code" id="check-3F-source">
|
273
|
-
<pre>VALUE
|
274
|
-
board_king_in_check (VALUE self)
|
275
|
-
{
|
276
|
-
Board *board;
|
277
|
-
Data_Get_Struct (self, Board, board);
|
278
|
-
if (king_in_check (board, board->active_color))
|
279
|
-
return Qtrue;
|
280
|
-
else
|
281
|
-
return Qfalse;
|
282
|
-
}</pre>
|
283
|
-
</div>
|
284
|
-
|
285
|
-
</div>
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
</div>
|
291
|
-
|
292
|
-
|
293
|
-
<div id="method-i-checkmate-3F" class="method-detail ">
|
294
|
-
|
295
|
-
|
296
|
-
<div class="method-heading">
|
297
|
-
<span class="method-callseq">
|
298
|
-
checkmate?
|
299
|
-
</span>
|
300
|
-
|
301
|
-
<span class="method-click-advice">click to toggle source</span>
|
302
|
-
|
303
|
-
</div>
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
<div class="method-description">
|
308
|
-
|
309
|
-
<p>Returns <code>true</code> if the king of the color that has the turn is in
|
310
|
-
checkmate, <code>false</code> otherwise.</p>
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
<div class="method-source-code" id="checkmate-3F-source">
|
316
|
-
<pre>VALUE
|
317
|
-
board_king_in_checkmate (VALUE self)
|
318
|
-
{
|
319
|
-
Board *board;
|
320
|
-
Data_Get_Struct (self, Board, board);
|
321
|
-
if (king_in_checkmate (board, board->active_color))
|
322
|
-
return Qtrue;
|
323
|
-
else
|
324
|
-
return Qfalse;
|
325
|
-
}</pre>
|
326
|
-
</div>
|
327
|
-
|
328
|
-
</div>
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
</div>
|
334
|
-
|
335
|
-
|
336
|
-
<div id="method-i-fifty_rule_move-3F" class="method-detail ">
|
337
|
-
|
338
|
-
|
339
|
-
<div class="method-heading">
|
340
|
-
<span class="method-callseq">
|
341
|
-
fifty_move_rule?
|
342
|
-
</span>
|
343
|
-
|
344
|
-
<span class="method-click-advice">click to toggle source</span>
|
345
|
-
|
346
|
-
</div>
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
<div class="method-description">
|
351
|
-
|
352
|
-
<p>Returns <code>true</code> if a player can claim draw by the fifty-move
|
353
|
-
rule, <code>false</code> otherwise.</p>
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
<div class="method-source-code" id="fifty_rule_move-3F-source">
|
359
|
-
<pre>VALUE
|
360
|
-
board_fifty_move_rule (VALUE self)
|
361
|
-
{
|
362
|
-
Board *board;
|
363
|
-
Data_Get_Struct (self, Board, board);
|
364
|
-
if (fifty_move_rule (board))
|
365
|
-
return Qtrue;
|
366
|
-
else
|
367
|
-
return Qfalse;
|
368
|
-
}</pre>
|
369
|
-
</div>
|
370
|
-
|
371
|
-
</div>
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
</div>
|
377
|
-
|
378
|
-
|
379
|
-
<div id="method-i-fullmove_number" class="method-detail ">
|
380
|
-
|
381
|
-
|
382
|
-
<div class="method-heading">
|
383
|
-
<span class="method-callseq">
|
384
|
-
fullmove_number
|
385
|
-
</span>
|
386
|
-
|
387
|
-
<span class="method-click-advice">click to toggle source</span>
|
388
|
-
|
389
|
-
</div>
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
<div class="method-description">
|
394
|
-
|
395
|
-
<p>Returns the fullmove number: the number of the full move. It starts at 1,
|
396
|
-
and is incremented after black's move.</p>
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
<div class="method-source-code" id="fullmove_number-source">
|
402
|
-
<pre>VALUE
|
403
|
-
board_fullmove_number (VALUE self)
|
404
|
-
{
|
405
|
-
Board *board;
|
406
|
-
Data_Get_Struct (self, Board, board);
|
407
|
-
return INT2FIX (board->fullmove_number);
|
408
|
-
}</pre>
|
409
|
-
</div>
|
410
|
-
|
411
|
-
</div>
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
</div>
|
417
|
-
|
418
|
-
|
419
|
-
<div id="method-i-halfmove_clock" class="method-detail ">
|
420
|
-
|
421
|
-
|
422
|
-
<div class="method-heading">
|
423
|
-
<span class="method-callseq">
|
424
|
-
halfmove_clock
|
425
|
-
</span>
|
426
|
-
|
427
|
-
<span class="method-click-advice">click to toggle source</span>
|
428
|
-
|
429
|
-
</div>
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
<div class="method-description">
|
434
|
-
|
435
|
-
<p>Returns the halfmove clock that is the number of halfmoves since the last
|
436
|
-
pawn advance or capture. This is used to determine if a draw can be claimed
|
437
|
-
under the fifty-move rule.</p>
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
<div class="method-source-code" id="halfmove_clock-source">
|
443
|
-
<pre>VALUE
|
444
|
-
board_halfmove_clock (VALUE self)
|
445
|
-
{
|
446
|
-
Board *board;
|
447
|
-
Data_Get_Struct (self, Board, board);
|
448
|
-
return INT2FIX (board->halfmove_clock);
|
449
|
-
}</pre>
|
450
|
-
</div>
|
451
|
-
|
452
|
-
</div>
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
</div>
|
458
|
-
|
459
|
-
|
460
|
-
<div id="method-i-insufficient_material-3F" class="method-detail ">
|
461
|
-
|
462
|
-
|
463
|
-
<div class="method-heading">
|
464
|
-
<span class="method-callseq">
|
465
|
-
insufficient_material?
|
466
|
-
</span>
|
467
|
-
|
468
|
-
<span class="method-click-advice">click to toggle source</span>
|
469
|
-
|
470
|
-
</div>
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
<div class="method-description">
|
475
|
-
|
476
|
-
<p>Returns <code>true</code> if the board has insufficient material to
|
477
|
-
checkmate, <code>false</code> otherwise.</p>
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
<div class="method-source-code" id="insufficient_material-3F-source">
|
483
|
-
<pre>VALUE
|
484
|
-
board_insufficient_material (VALUE self)
|
485
|
-
{
|
486
|
-
Board *board;
|
487
|
-
Data_Get_Struct (self, Board, board);
|
488
|
-
if (insufficient_material (board))
|
489
|
-
return Qtrue;
|
490
|
-
else
|
491
|
-
return Qfalse;
|
492
|
-
}</pre>
|
493
|
-
</div>
|
494
|
-
|
495
|
-
</div>
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
</div>
|
501
|
-
|
502
|
-
|
503
|
-
<div id="method-i-placement" class="method-detail ">
|
504
|
-
|
505
|
-
|
506
|
-
<div class="method-heading">
|
507
|
-
<span class="method-callseq">
|
508
|
-
placement { |piece, index| block }
|
509
|
-
</span>
|
510
|
-
|
511
|
-
<span class="method-click-advice">click to toggle source</span>
|
512
|
-
|
513
|
-
</div>
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
<div class="method-description">
|
518
|
-
|
519
|
-
<p>Calls <code>block</code> once for each square in the board, passing the
|
520
|
-
<code>piece</code> in the square and the <code>index</code> as parameters.
|
521
|
-
Return self. If no block is given, the array of pieces is returned instead.</p>
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
<div class="method-source-code" id="placement-source">
|
527
|
-
<pre>VALUE
|
528
|
-
board_placement (VALUE self)
|
529
|
-
{
|
530
|
-
Board *board;
|
531
|
-
Data_Get_Struct (self, Board, board);
|
532
|
-
if (!rb_block_given_p ())
|
533
|
-
{
|
534
|
-
VALUE placement = rb_ary_new ();
|
535
|
-
for (int i = 0; i < 64; i++)
|
536
|
-
{
|
537
|
-
char piece = board->placement[i];
|
538
|
-
rb_ary_push (placement, rb_str_new (&piece, 1));
|
539
|
-
}
|
540
|
-
return placement;
|
541
|
-
}
|
542
|
-
else
|
543
|
-
{
|
544
|
-
for (int i = 0; i < 64; i++)
|
545
|
-
{
|
546
|
-
char piece = board->placement[i];
|
547
|
-
rb_yield_values (2, rb_str_new (&piece, 1), INT2FIX (i));
|
548
|
-
}
|
549
|
-
return self;
|
550
|
-
}
|
551
|
-
}</pre>
|
552
|
-
</div>
|
553
|
-
|
554
|
-
</div>
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
</div>
|
560
|
-
|
561
|
-
|
562
|
-
<div id="method-i-stalemate-3F" class="method-detail ">
|
563
|
-
|
564
|
-
|
565
|
-
<div class="method-heading">
|
566
|
-
<span class="method-callseq">
|
567
|
-
stalemate?
|
568
|
-
</span>
|
569
|
-
|
570
|
-
<span class="method-click-advice">click to toggle source</span>
|
571
|
-
|
572
|
-
</div>
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
<div class="method-description">
|
577
|
-
|
578
|
-
<p>Returns <code>true</code> if the pieces of the color that has the turn are
|
579
|
-
in stalemate, <code>false</code> otherwise.</p>
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
<div class="method-source-code" id="stalemate-3F-source">
|
585
|
-
<pre>VALUE
|
586
|
-
board_stalemate (VALUE self)
|
587
|
-
{
|
588
|
-
Board *board;
|
589
|
-
Data_Get_Struct (self, Board, board);
|
590
|
-
if (stalemate (board, board->active_color))
|
591
|
-
return Qtrue;
|
592
|
-
else
|
593
|
-
return Qfalse;
|
594
|
-
}</pre>
|
595
|
-
</div>
|
596
|
-
|
597
|
-
</div>
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
</div>
|
603
|
-
|
604
|
-
|
605
|
-
<div id="method-i-to_fen" class="method-detail ">
|
606
|
-
|
607
|
-
|
608
|
-
<div class="method-heading">
|
609
|
-
<span class="method-callseq">
|
610
|
-
to_fen
|
611
|
-
</span>
|
612
|
-
|
613
|
-
<span class="method-click-advice">click to toggle source</span>
|
614
|
-
|
615
|
-
</div>
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
<div class="method-description">
|
620
|
-
|
621
|
-
<p>Return the FEN string of the board.</p>
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
<div class="method-source-code" id="to_fen-source">
|
627
|
-
<pre>VALUE
|
628
|
-
board_to_fen (VALUE self)
|
629
|
-
{
|
630
|
-
Board *board;
|
631
|
-
Data_Get_Struct (self, Board, board);
|
632
|
-
char *fen = to_fen (board);
|
633
|
-
VALUE rb_fen = rb_str_new2 (fen);
|
634
|
-
free (fen);
|
635
|
-
return rb_fen;
|
636
|
-
}</pre>
|
637
|
-
</div>
|
638
|
-
|
639
|
-
</div>
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
</div>
|
645
|
-
|
646
|
-
|
647
|
-
<div id="method-i-to_s" class="method-detail ">
|
648
|
-
|
649
|
-
|
650
|
-
<div class="method-heading">
|
651
|
-
<span class="method-callseq">
|
652
|
-
to_s
|
653
|
-
</span>
|
654
|
-
|
655
|
-
<span class="method-click-advice">click to toggle source</span>
|
656
|
-
|
657
|
-
</div>
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
<div class="method-description">
|
662
|
-
|
663
|
-
<p><a href="Board.html">Board</a> to string.</p>
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
<div class="method-source-code" id="to_s-source">
|
669
|
-
<pre>VALUE
|
670
|
-
board_to_s (VALUE self)
|
671
|
-
{
|
672
|
-
Board *board;
|
673
|
-
Data_Get_Struct (self, Board, board);
|
674
|
-
char *s = print_board (board);
|
675
|
-
VALUE rb_s = rb_str_new2 (s);
|
676
|
-
free (s);
|
677
|
-
return rb_s;
|
678
|
-
}</pre>
|
679
|
-
</div>
|
680
|
-
|
681
|
-
</div>
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
</div>
|
687
|
-
|
688
|
-
|
689
|
-
</section>
|
690
|
-
|
691
|
-
</section>
|
692
|
-
</main>
|
693
|
-
|
694
|
-
|
695
|
-
<footer id="validator-badges" role="contentinfo">
|
696
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
697
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
698
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
699
|
-
</footer>
|
700
|
-
|