Skip to content

Commit c83dfdd

Browse files
committed
first commit
0 parents  commit c83dfdd

File tree

11 files changed

+1022
-0
lines changed

11 files changed

+1022
-0
lines changed

BATCH.TXT

Lines changed: 483 additions & 0 deletions
Large diffs are not rendered by default.

BOOK.DAT

94.4 KB
Binary file not shown.

README.md

Whitespace-only changes.

eleeye.exe

86.3 KB
Binary file not shown.

engine.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
var ucci = require('./ucci').ucci,
2+
util = require('util');
3+
4+
function UCIEngine(path, options, uci) {
5+
var self = this;
6+
this.engine = new ucci(path, options || {
7+
usemillisec: false,
8+
batch: true,
9+
debug: true,
10+
ponder: false,}, uci);
11+
12+
this.serial = 0;
13+
this.queue = [];
14+
this.current = null;
15+
this.evaldone = null;
16+
17+
// hook up the events, print out on screen
18+
this.engine.on('engineError', function(err) {
19+
util.log(err);
20+
});
21+
22+
this.engine.on('engineState', function(newstate) {
23+
util.log(newstate);
24+
});
25+
26+
this.engine.on('commandSent', function(command) {
27+
util.log(command);
28+
});
29+
30+
this.engine.on('ucciok', function(data) {
31+
util.log(data);
32+
// print engine id
33+
util.log('engine id: \n' + util.inspect(self.engine.id, false, null));
34+
// print engine defaults
35+
util.log('engine defaults: \n' + util.inspect(self.engine.defaults, false, null));
36+
// trigger the readyok event.
37+
self.engine.isready();
38+
});
39+
40+
this.engine.on('bye', function(data) {
41+
util.log(data);
42+
});
43+
44+
this.engine.on('id', function(data) {
45+
util.log(data);
46+
});
47+
48+
this.engine.on('option', function(data) {
49+
util.log(data);
50+
});
51+
52+
this.engine.on('readyok', function(data) {
53+
if (self.queue.length > 0) {
54+
self.current = self.queue.shift();
55+
self.engine.position(self.current.p);
56+
self.engine.go('', 'depth 6');
57+
}
58+
});
59+
60+
this.engine.on('bestmove', function(data) {
61+
if (self.current && self.evaldone) {
62+
self.current.m = data;
63+
self.evaldone(self.current);
64+
}
65+
66+
if (self.queue.length > 0) {
67+
self.engine.isready();
68+
}
69+
});
70+
};
71+
72+
UCIEngine.prototype.launch = function() {
73+
this.engine.loadEngine();
74+
this.engine.boot();
75+
};
76+
77+
UCIEngine.prototype.quit = function() {
78+
this.engine.quit();
79+
};
80+
81+
UCIEngine.prototype.evaluate = function(pos, token) {
82+
this.serial = this.serial + 1;
83+
this.queue.push({'p': pos, 's': this.serial, 't': token });
84+
this.engine.isready();
85+
return this.serial;
86+
};
87+
88+
UCIEngine.prototype.evaluate_done = function(callback) {
89+
this.evaldone = callback;
90+
};
91+
92+
exports.UCIEngine = UCIEngine;

evaluate.dll

50.3 KB
Binary file not shown.

test_engine.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var UCIEngine = require('./engine').UCIEngine,
2+
util = require('util');
3+
4+
var START_POS = 'rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1';
5+
6+
var test_positions = [
7+
'4C4/4a4/b2ank2b/9/9/1RNR1crC1/3r1p3/3cKA3/4A4/4n4 w - - 0 1',
8+
'9/2Cca4/3k1C3/4P1p2/4N1b2/4R1r2/4c1n2/3p1n3/2rNK4/9 w - - 0 1',
9+
'9/4a4/3k1a3/2R3r2/1N5n1/C7c/1N5n1/2R3r2/3p1p3/4K4 w - - 0 1',
10+
'9/4P4/2NakaR2/3P1P3/2pP1cb2/3r1c3/1rPNppCn1/3K1A3/2p3n2/9 w - - 0 1',
11+
'9/9/4Nk3/3c2p2/3r2P2/3p2B2/3p2r2/4KC3/9/9 w - - 0 1',
12+
'9/9/3k1N3/9/1C5N1/9/1n5r1/9/3p1K3/9 w - - 0 1',
13+
'9/9/5k1N1/4p1P1p/3P1C1C1/2N1r1r2/9/3ABK3/2ncpp3/1pBAc4 w - - 0 1',
14+
'1nb1ka3/4a4/4c4/2p1C4/9/3Rcr3/P8/n3C4/4Apr2/4KA3 w - - 0 1',
15+
'9/3Rak3/3a1n3/1PpP1PPR1/1P5n1/1rBp1pcp1/3C1p3/3Kcr3/9/9 w - - 0 1',
16+
'1PP1kab2/1R2a4/4b3R/4C4/1C7/r8/9/2n6/3p1r3/4K4 w - - 0 1',
17+
'3k5/5P3/3a1r3/9/9/9/9/2R6/7p1/4K4 w - - 0 1',
18+
'3aka3/3P5/7R1/4r2C1/6C2/6R2/9/3p1n3/4p4/3K5 w - - 0 1',
19+
'4ka3/2R1a4/7N1/9/9/9/4p4/2C6/2p1p1r2/1R3K3 w - - 0 1'];
20+
21+
var eleeye = new UCIEngine('eleeye.exe', {
22+
usemillisec: false,
23+
batch: true,
24+
debug: true,
25+
ponder: false,});
26+
27+
eleeye.evaluate_done(function (pos) {
28+
util.log('result:' + pos.s + '\t' + pos.m);
29+
});
30+
31+
eleeye.launch();
32+
eleeye.evaluate(START_POS);
33+
34+
test_positions.forEach(function(pos) {
35+
eleeye.evaluate(pos);
36+
});
37+

test_ucci.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
var ucci = require('./ucci').ucci,
2+
util = require('util');
3+
4+
var START_POS = 'rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1';
5+
6+
7+
var eleeye = new ucci('eleeye.exe', {
8+
usemillisec: false,
9+
batch: true,
10+
debug: true,
11+
ponder: false,
12+
}, false);
13+
14+
eleeye.on('engineError', function(err) {
15+
util.log(err);
16+
});
17+
18+
eleeye.on('engineState', function(newstate) {
19+
util.log(newstate);
20+
});
21+
22+
eleeye.on('commandSent', function(command) {
23+
util.log(command);
24+
});
25+
26+
eleeye.on('ucciok', function(data) {
27+
util.log(data);
28+
// print engine id
29+
util.log('engine id: \n' + util.inspect(eleeye.id, false, null));
30+
// print engine defaults
31+
util.log('engine defaults: \n' + util.inspect(eleeye.defaults, false, null));
32+
// test thinking
33+
eleeye.position(START_POS);
34+
eleeye.go('ponder', 'depth 6');
35+
});
36+
37+
eleeye.on('bye', function(data) {
38+
util.log(data);
39+
});
40+
41+
eleeye.on('id', function(data) {
42+
util.log(data);
43+
});
44+
45+
eleeye.on('option', function(data) {
46+
util.log(data);
47+
});
48+
49+
eleeye.on('bestmove', function(data) {
50+
util.log(data);
51+
});
52+
53+
eleeye.loadEngine();
54+
eleeye.boot();
55+
56+

0 commit comments

Comments
 (0)