Permalink
Browse files

Adding documentation

  • Loading branch information...
imor committed Jun 6, 2014
1 parent 0162345 commit 3f09a7b0807ae7fb9e79d338bf54693144309f7f
Showing with 928 additions and 7 deletions.
  1. +1 −1 Gruntfile.js
  2. +2 −2 README.md
  3. +0 −4 docs/.gitignore
  4. +549 −0 docs/assets/behavior.js
  5. +1 −0 docs/assets/style.css
  6. +63 −0 docs/index.html
  7. +248 −0 docs/src/main.html
  8. +64 −0 docs/src/utilities.html
View
@@ -19,7 +19,7 @@ module.exports = function(grunt) {
},
groc: {
javascript: [
"src/*.js"
"src/*.js", "README.md"
],
options: {
"out": "docs/",
View
@@ -30,10 +30,10 @@ engine.runProcess().then(function () {
return engine.positionCommand('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
}).then(function () {
console.log('Starting position set');
console.log('Starting analysis');
return engine.goInfiniteCommand(function infoHandler(info) {
console.log(info);
});
console.log('Starting analysis');
}).delay(2000).then(function () {
console.log('Stopping analysis');
return engine.stopCommand();
@@ -50,7 +50,7 @@ engine.runProcess().then(function () {
```
## API
See [here]() for API reference.
See [here](http://imor.github.io/uci/docs/src/main.html) for API reference.
## Contributing
Fork, pick an issue to fix from [issues](https://github.com/imor/uci/issues) or
View

This file was deleted.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,63 @@
<!DOCTYPE html><html lang="en"><head><title>index</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="index"><meta name="groc-project-path" content="README.md"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">README.md</div></div><div id="document"><div class="segment"><div class="comments "><div class="wrapper"><h1 id="uci">UCI</h1>
<p>NOTE:This version is not backwards compatible with 0.2.x series of releases.</p>
<p>UCI is a thin wrapper on a <a href="http://en.wikipedia.org/wiki/Universal_Chess_Interface">uci
interface</a> chess engine.</p>
<h2 id="installation">Installation</h2>
<p>Make sure you have <a href="http://nodejs.org/">node.js</a> installed. Then do:</p>
<pre><code>$ npm install uci
</code></pre>
<h2 id="example">Example</h2>
<pre><code class="js">var Engine = require('uci');
var engine = new Engine('&lt;path to engine executable&gt;');
engine.runProcess().then(function () {
console.log('Started');
return engine.uciCommand();
}).then(function (idAndOptions) {
console.log('Engine name - ' + idAndOptions.id.name);
return engine.isReadyCommand();
}).then(function () {
console.log('Ready');
return engine.uciNewGameCommand();
}).then(function () {
console.log('New game started');
return engine.positionCommand('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
}).then(function () {
console.log('Starting position set');
console.log('Starting analysis');
return engine.goInfiniteCommand(function infoHandler(info) {
console.log(info);
});
}).delay(2000).then(function () {
console.log('Stopping analysis');
return engine.stopCommand();
}).then(function (bestmove) {
console.log('Bestmove: ');
console.log(bestmove);
return engine.quitCommand();
}).then(function () {
console.log('Stopped');
}).fail(function (error) {
console.log(error);
process.exit();
}).done();
</code></pre>
<h2 id="api">API</h2>
<p>See <a href="http://imor.github.io/uci/docs/src/main.html">here</a> for API reference.</p>
<h2 id="contributing">Contributing</h2>
<p>Fork, pick an issue to fix from <a href="https://github.com/imor/uci/issues">issues</a> or
add a missing feature and send a pull request.</p>
<h2 id="license">License</h2>
<p>UCI is released under the MIT License. See the bundled LICENSE file for details.</p></div></div></div></div></body></html>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,64 @@
<!DOCTYPE html><html lang="en"><head><title>src\utilities</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="src\utilities"><meta name="groc-project-path" content="src\utilities.js"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">src\utilities.js</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="kd">var</span> <span class="nx">isRunning</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;is-running&#39;</span><span class="p">);</span></div></div></div><div class="segment"><div class="comments doc-section doc-section-public"><div class="wrapper"><p><span class='doc-section-header'>Public method convertToMoveObject</span></p>
<p>Converts a move string to a move object. For the format of the move string and
structure of the move object see
<a href="https://github.com/jhlywa/chess.js#movemove">this</a>.</p>
<p>Parameters:</p>
<ul>
<li><strong>move must be a String.</strong><br/>(The move string)</li>
</ul>
<p><strong>Returns an Object</strong><br/>(The move object)</p></div></div><div class="code"><div class="wrapper"><span class="kd">function</span> <span class="nx">convertToMoveObject</span><span class="p">(</span><span class="nx">move</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">move</span> <span class="o">===</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">move</span><span class="p">;</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">result</span><span class="p">.</span><span class="nx">from</span> <span class="o">=</span> <span class="nx">move</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
<span class="nx">result</span><span class="p">.</span><span class="nx">to</span> <span class="o">=</span> <span class="nx">move</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">move</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">4</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">result</span><span class="p">.</span><span class="nx">promotion</span> <span class="o">=</span> <span class="nx">move</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">4</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
<span class="p">}</span></div></div></div><div class="segment"><div class="comments doc-section doc-section-public"><div class="wrapper"><p><span class='doc-section-header'>Public method convertToMoveString</span></p>
<p>Converts a move object to a move string. For the format of the move string and
structure of the move object see
<a href="https://github.com/jhlywa/chess.js#movemove">this</a>.</p>
<p>Parameters:</p>
<ul>
<li><strong>move must be an Object.</strong><br/>(The move object)</li>
</ul>
<p><strong>Returns a String</strong><br/>(The move string)</p></div></div><div class="code"><div class="wrapper"><span class="kd">function</span> <span class="nx">convertToMoveString</span><span class="p">(</span><span class="nx">move</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">move</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">move</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">move</span> <span class="o">||</span> <span class="o">!</span><span class="nx">move</span><span class="p">.</span><span class="nx">from</span> <span class="o">||</span> <span class="o">!</span><span class="nx">move</span><span class="p">.</span><span class="nx">to</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">move</span><span class="p">.</span><span class="nx">from</span> <span class="o">+</span> <span class="nx">move</span><span class="p">.</span><span class="nx">to</span> <span class="o">+</span> <span class="p">(</span><span class="nx">move</span><span class="p">.</span><span class="nx">promotion</span> <span class="o">?</span> <span class="nx">move</span><span class="p">.</span><span class="nx">promotion</span> <span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="p">);</span>
<span class="p">}</span></div></div></div><div class="segment"><div class="comments doc-section doc-section-public"><div class="wrapper"><p><span class='doc-section-header'>Public method isProcessRunning</span></p>
<p>Takes a nodejs <a href="http://nodejs.org/api/child_process.html">ChildProcess</a> and
returns true if it is running.</p>
<p>Parameters:</p>
<ul>
<li><strong>proc must be an Object.</strong><br/>(A nodejs ChildProcess.)</li>
</ul>
<p><strong>Returns a Boolean</strong><br/>(true if the process is running, false otherwise.)</p></div></div><div class="code"><div class="wrapper"><span class="kd">function</span> <span class="nx">isProcessRunning</span><span class="p">(</span><span class="nx">proc</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">isRunning</span><span class="p">(</span><span class="nx">proc</span><span class="p">.</span><span class="nx">pid</span><span class="p">)</span> <span class="o">&amp;&amp;</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This is a hack because the isRunning module incorrectly detects
non-running processes as running. See
<a href="https://github.com/nisaacson/is-running/issues/4">this issue</a>.</p></div></div><div class="code"><div class="wrapper"> <span class="nx">proc</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="nx">_readableState</span><span class="p">.</span><span class="nx">length</span> <span class="o">!==</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
<span class="nx">exports</span><span class="p">.</span><span class="nx">convertToMoveObject</span> <span class="o">=</span> <span class="nx">convertToMoveObject</span><span class="p">;</span>
<span class="nx">exports</span><span class="p">.</span><span class="nx">convertToMoveString</span> <span class="o">=</span> <span class="nx">convertToMoveString</span><span class="p">;</span>
<span class="nx">exports</span><span class="p">.</span><span class="nx">isProcessRunning</span> <span class="o">=</span> <span class="nx">isProcessRunning</span><span class="p">;</span></div></div></div></div></body></html>

0 comments on commit 3f09a7b

Please sign in to comment.