Myopic, a new Creative Commons chess program

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Myopic, a new Creative Commons chess program

Post by sje »

I have written a new chess program and have released the C++ source under a Creative Commons license. The name of the program is "Myopic" (I. e.; "short-sighted") and it has been designed for the Arduino Mega microcontroller platform (128 KB ROM / 8 KB RAM). The program is written entirely in ANSI C++ and will run not only on an Arduino Mega, but also under Mac OS/X or Linux.

The code still needs some work, particularly with positional evaluation.

See: http://public.me.com/chessnotation (directory: myopic)

-------

I've been battling some health issues recently, so I haven't produced much chess-wise. But I have set up a Facebook account; my fellow authors and enthusiasts are welcome to join as a friend:

http://www.facebook.com/profile.php?id=100001111380541
Dann Corbit
Posts: 12542
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Myopic, a new Creative Commons chess program

Post by Dann Corbit »

sje wrote:I have written a new chess program and have released the C++ source under a Creative Commons license. The name of the program is "Myopic" (I. e.; "short-sighted") and it has been designed for the Arduino Mega microcontroller platform (128 KB ROM / 8 KB RAM). The program is written entirely in ANSI C++ and will run not only on an Arduino Mega, but also under Mac OS/X or Linux.

The code still needs some work, particularly with positional evaluation.

See: http://public.me.com/chessnotation (directory: myopic)

-------

I've been battling some health issues recently, so I haven't produced much chess-wise. But I have set up a Facebook account; my fellow authors and enthusiasts are welcome to join as a friend:

http://www.facebook.com/profile.php?id=100001111380541
Here is a version that compiles and runs under Windows:
http://cap.connx.com/chess-engines/new- ... /myopic.7z

Note: a 64 bit binary is included along with the few changes to the source that were needed.

P.S.
Since it is neither a UCI nor Winboard engines, work will be needed to make it play under a familiar GUI.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Myopic, a new Creative Commons chess program

Post by sje »

Thanks, Dann. I don't have a Windows development environment; I hope you didn't have to make too many changes.

The Arduino Mega version and the desktop version of Myopic are pretty much the same except that the desktop version has a built-in PGN scanner and book compiler.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Sample output

Post by sje »

Myopic uses a simple serial text interface. (It can also use a truly nifty 8x8 color LED matrix board display from SparkFun Electronics when operating on the Arduino Mega.)

Here's a sample transcript:

Code: Select all

Myopic v2010.03.02 beta: A simple chess program for small systems
Copyright (C) 2010 by chessnotation@me.com   Some rights reserved.
License: Creative Commons Attribution-Share Alike 3.0
See: http://creativecommons.org/licenses/by-sa/3.0/

Caution: No warranty; use at your own risk.

Enter 'hm' for help, 'qp' to quit.

[] hm
Commands:
  bb  Build book <input-game-file> <output-code-file>
  db  Display board
  df  Display FEN
  dh  Display position hash
  dl  Display opening library moves
  dm  Display moves
  do  Display options
  ds  Display status
  em  Enumerate movepaths to depth <n> plies
  fm  Fast enumerate movepaths to depth <n> plies
  fp  Flip position
  gg  Go and play to end of game
  gp  Go and play
  gs  Go search
  hm  Help me
  id  Show program identification
  ng  New game
  pt  Program test
  qp  Quit program
  ro  Reset option&#40;s&#41; &#40;limit 7&#41;
  rp  Reset program
  sd  Set depth limit to <n> plies
  sf  Set FEN
  so  Set option&#40;s&#41; &#40;limit 7&#41;
  st  Set time limit to <n> seconds
  tb  Take back move

Options&#58;
  aa  Audible alert on move reply
  cb  Auto display chessboard
  ct  Trace command processing time
  cv  Trace current variation
  if  Trace input FEN
  ip  Trace input parameters
  it  Trace iteration announcements
  nl  No opening library book
  nr  No auto move reply
  ps  Trace preliminary scoring
  pv  Trace predicted variation updates
  pz  Trace ply zero move activity
  rb  Rotate board display &#40;White at top&#41;
  sr  Trace search result
  st  Trace search termination
  ts  Trace timing statistics

Moves&#58;
  Enter one or move moves &#40;limit 8&#41;; use 'dm' command for list.
&#91;&#93; ds
  a b c d e f g h 
8 bRbNbBbQbKbBbNbR 8
7 bPbPbPbPbPbPbPbP 7
6   &#58;&#58;  &#58;&#58;  &#58;&#58;  &#58;&#58; 6
5 &#58;&#58;  &#58;&#58;  &#58;&#58;  &#58;&#58;   5
4   &#58;&#58;  &#58;&#58;  &#58;&#58;  &#58;&#58; 4
3 &#58;&#58;  &#58;&#58;  &#58;&#58;  &#58;&#58;   3
2 wPwPwPwPwPwPwPwP 2
1 wRwNwBwQwKwBwNwR 1
  a b c d e f g h 
&#91;w KQkq - 0 1&#93;
Moves&#58; Na3 Nc3 Nf3 Nh3 a3 a4 b3 b4 c3 c4 d3 d4 e3 e4 f3 f4 g3 g4 h3 h4
Time limit&#58; 5.000   Depth limit&#58; 20
Options&#58; 
FEN&#58; rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Hash&#58; 9bbf11d452f40f1e
&#91;&#93; e4 e5 Nf3
Your move&#58; 1 e4
Your move&#58; 1... e5
Your move&#58; 2 Nf3
My move&#58; 2... Nc6
&#91;&#93; so ct it pv sr st ts
&#91;ct&#93; Seconds&#58; 0.000
&#91;&#93; ds
  a b c d e f g h 
8 bR&#58;&#58;bBbQbKbBbNbR 8
7 bPbPbPbP&#58;&#58;bPbPbP 7
6   &#58;&#58;bN&#58;&#58;  &#58;&#58;  &#58;&#58; 6
5 &#58;&#58;  &#58;&#58;  bP  &#58;&#58;   5
4   &#58;&#58;  &#58;&#58;wP&#58;&#58;  &#58;&#58; 4
3 &#58;&#58;  &#58;&#58;  &#58;&#58;wN&#58;&#58;   3
2 wPwPwPwP  wPwPwP 2
1 wRwNwBwQwKwB&#58;&#58;wR 1
  a b c d e f g h 
&#91;w KQkq - 2 3&#93;
Moves&#58; Ba6 Bb5 Bc4 Bd3 Be2 Ke2 Na3 Nc3 Nd4 Ng1 Ng5 Nh4 Nxe5 Qe2 Rg1 a3 a4 b3 b4 c3 c4 d3 d4 g3 g4 h3 h4
Time limit&#58; 5.000   Depth limit&#58; 20
Options&#58; ct it pv sr st ts
FEN&#58; r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3
Hash&#58; 635bee94c255f58c
&#91;ct&#93; Seconds&#58; 0.000
&#91;&#93; so nl
&#91;ct&#93; Seconds&#58; 0.000
&#91;&#93; gs
&#91;it&#93; Iteration&#58; 1
&#91;pv&#93; PV&#58; 3 Nc3   Score&#58; +0.34
&#91;it&#93; Iteration&#58; 2
&#91;pv&#93; PV&#58; 3 Nc3 d6   Score&#58; +0.10
&#91;it&#93; Iteration&#58; 3
&#91;pv&#93; PV&#58; 3 Nc3 d6 4 d3   Score&#58; +0.34
&#91;pv&#93; PV&#58; 3 d4 d6 4 d5   Score&#58; +0.39
&#91;it&#93; Iteration&#58; 4
&#91;pv&#93; PV&#58; 3 d4 exd4 4 Nxd4 d5   Score&#58; +0.22
&#91;it&#93; Iteration&#58; 5
&#91;pv&#93; PV&#58; 3 d4 exd4 4 Nxd4 d5 5 Nc3 dxe4 6 Nxc6   Score&#58; +0.39
&#91;pv&#93; PV&#58; 3 Nc3 Bc5 4 Bb5 Nge7 5 d3   Score&#58; +0.40
&#91;it&#93; Iteration&#58; 6
&#91;pv&#93; PV&#58; 3 Nc3 Nf6 4 d4 Bb4 5 dxe5 Nxe4   Score&#58; +0.48
&#91;it&#93; Iteration&#58; 7
&#91;pv&#93; PV&#58; 3 Nc3 Nf6 4 d4 exd4 5 Nxd4 Bb4 6 f3   Score&#58; +0.43
&#91;it&#93; Iteration&#58; 8
&#91;st&#93; Time limit reached
&#91;sr&#93; PV&#58; 3 Nc3 Nf6 4 d4 exd4 5 Nxd4 Bb4 6 f3   Score&#58; +0.43
&#91;ts&#93; Nodes&#58; 3342336   Seconds&#58; 5.085   Frequency&#58; 657293 Hz
Move&#58; 3 Nc3
&#91;ct&#93; Seconds&#58; 5.086
&#91;&#93; dl
3 Bb5 &#40;158/255&#41;
3 Bc4 &#40;49/255&#41;
3 Nc3 &#40;16/255&#41;
3 c3 &#40;4/255&#41;
3 d4 &#40;28/255&#41;
&#91;ct&#93; Seconds&#58; 0.000
&#91;&#93; qp
&#91;ct&#93; Seconds&#58; 0.000
Done
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Relative timing

Post by sje »

First, let me publicly give credit to Tom Boyle who provided very helpful beta testing of Myopic in the Arduino environment.


Second, for those interested in Arduino programming, see:

http://www.arduino.cc/


Third, for those interested in connecting a cool 8x8 color LED display via SPI to a microcontroller, see:

http://www.sparkfun.com/commerce/produc ... cts_id=760


Fourth, some perft movepath enumeration numbers for Myopic;

On a 2.66 GHz Xeon:

Code: Select all

&#91;&#93; fm 0
&#91;ts&#93; Nodes&#58; 1   Seconds&#58; 0.000
Nodes&#58; 1
&#91;&#93; fm 1
&#91;ts&#93; Nodes&#58; 20   Seconds&#58; 0.001   Frequency&#58; 20000 Hz
Nodes&#58; 20
&#91;&#93; fm 2
&#91;ts&#93; Nodes&#58; 400   Seconds&#58; 0.000
Nodes&#58; 400
&#91;&#93; fm 3
&#91;ts&#93; Nodes&#58; 8902   Seconds&#58; 0.000
Nodes&#58; 8902
&#91;&#93; fm 4
&#91;ts&#93; Nodes&#58; 197281   Seconds&#58; 0.009   Frequency&#58; 21920111 Hz
Nodes&#58; 197281
&#91;&#93; fm 5
&#91;ts&#93; Nodes&#58; 4865609   Seconds&#58; 0.211   Frequency&#58; 23059758 Hz
Nodes&#58; 4865609
&#91;&#93; fm 6
&#91;ts&#93; Nodes&#58; 119060324   Seconds&#58; 5.063   Frequency&#58; 23515766 Hz
Nodes&#58; 119060324
&#91;&#93; fm 7
&#91;ts&#93; Nodes&#58; 3195901860   Seconds&#58; 136.802   Frequency&#58; 23361514 Hz
Nodes&#58; 3195901860
&#91;&#93; fm 8
&#91;ts&#93; Nodes&#58; 84998978956   Seconds&#58; 3527.022   Frequency&#58; 24099361 Hz
Nodes&#58; 84998978956
And then on a 16 MHz Arduino Mega:

Code: Select all

&#91;&#93; fm 0
&#91;ts&#93; Nodes&#58; 1   Seconds&#58; 0.002   Frequency&#58; 499 Hz
Nodes&#58; 1
&#91;&#93; fm 1
&#91;ts&#93; Nodes&#58; 20   Seconds&#58; 0.028   Frequency&#58; 714 Hz
Nodes&#58; 20
&#91;&#93; fm 2
&#91;ts&#93; Nodes&#58; 400   Seconds&#58; 0.049   Frequency&#58; 8163 Hz
Nodes&#58; 400
&#91;&#93; fm 3
&#91;ts&#93; Nodes&#58; 8902   Seconds&#58; 0.687   Frequency&#58; 12957 Hz
Nodes&#58; 8902
&#91;&#93; fm 4
&#91;ts&#93; Nodes&#58; 197281   Seconds&#58; 16.256   Frequency&#58; 12135 Hz
Nodes&#58; 197281
&#91;&#93; fm 5
&#91;ts&#93; Nodes&#58; 4865609   Seconds&#58; 356.699   Frequency&#58; 13640 Hz
Nodes&#58; 4865609
The difference? About a factor of 1,700 slower for the Arduino. I suspect that the reason for much of this, other than the clock speed, is that the Arduino GCC C++ target environment is forcing all eight bit operations to 16 bits and back again.
User avatar
jshriver
Posts: 1342
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Re: Myopic, a new Creative Commons chess program

Post by jshriver »

sje wrote: I've been battling some health issues recently, so I haven't produced much chess-wise. But I have set up a Facebook account; my fellow authors and enthusiasts are welcome to join as a friend:

http://www.facebook.com/profile.php?id=100001111380541
Hope you feel better.
-Josh
Dann Corbit
Posts: 12542
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Myopic, a new Creative Commons chess program

Post by Dann Corbit »

sje wrote:Thanks, Dann. I don't have a Windows development environment; I hope you didn't have to make too many changes.

The Arduino Mega version and the desktop version of Myopic are pretty much the same except that the desktop version has a built-in PGN scanner and book compiler.
The changes were trivial. Took me less than 10 minutes. I did introduce a few tag names so that doxygen would draw pretty pictures for me.

I may write an xboard interface for it if someone else doesn't beat me to it.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Myopic, a new Creative Commons chess program

Post by sje »

jshriver wrote:Hope you feel better.
Thanks. I had a big decline some months ago about the time I was writing Myopic's positional evaluator have haven't yet been back coding. Now I'm having some difficulty just with walking, but maybe the upcoming cardiologist visit will offer some hope.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Myopic, a new Creative Commons chess program

Post by sje »

Dann Corbit wrote:
sje wrote:Thanks, Dann. I don't have a Windows development environment; I hope you didn't have to make too many changes.

The Arduino Mega version and the desktop version of Myopic are pretty much the same except that the desktop version has a built-in PGN scanner and book compiler.
The changes were trivial. Took me less than 10 minutes. I did introduce a few tag names so that doxygen would draw pretty pictures for me.

I may write an xboard interface for it if someone else doesn't beat me to it.
TEN MINUTES? Hell, at this point it would take me more like ten hours to make any improvements, and it was me who wrote the damn thing.

For those who might try their own modifications, you might want to know that Myopic uses target bitboards (class: TBV). These are like chessboard bitboards, but each one is only 32 bits long with one bit per each possible piece. There is also a 64 element square-to-target vector and its inverse, a 32 element target-to-square vector.

There's some other stuff in there that I thought was pretty good but I can't remember exactly what.
Dann Corbit
Posts: 12542
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Myopic, a new Creative Commons chess program

Post by Dann Corbit »

sje wrote:
jshriver wrote:Hope you feel better.
Thanks. I had a big decline some months ago about the time I was writing Myopic's positional evaluator have haven't yet been back coding. Now I'm having some difficulty just with walking, but maybe the upcoming cardiologist visit will offer some hope.
My wife is in a simlar sore strait. She has an enlarged heart, heart rhythm problems, diabetes, neuropathy, and various other ailments.

I do realize that it can make the simplest operations of every day life very difficult.

I hope that you can regain some measure of your health, and I would also like to thank you for your large measure of contributions to the chess community.