Molecule - new engine

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

fkdosilovic
Posts: 5
Joined: Mon Mar 13, 2017 11:25 am

Molecule - new engine

Post by fkdosilovic »

Hey guys,

during the last 2.5 months I've been working on a chess engine. The result of my work is Molecule (https://github.com/fkdosilovic/molecule) . Any feedback is welcome, but I'm most interested in somewhat of a legal advice.

As you'll probably read in README file, whenever I would get stuck, I would consult a "Chess engine in C" youtube series on developing a chess engine. The result of that is that search part is basically identical to VICE's. Even though I did say in README file that Molecule is derivative of VICE (because of search part) , is it legal to use the code from VICE?
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Molecule - new engine

Post by jdart »

As far as I can tell, Vice doesn't have an explicit license. The readme just says "You are welcome to use the code as you like to help with your projects!."

So creating a derivative of Vice shouldn't create any problems for you. I assume you'd add some text to your code or docs informing users that your engine is derived in this way.

If you wanted to license your engine in some other way, for example, GPL version 3 I think you could do that, but the parts that are from Vice would continue to be available under its more liberal terms.

--Jon
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Molecule - new engine

Post by AlvaroBegue »

I gave it a quick try and it looks like xboard (EDIT: More likely PolyGlot, actually) doesn't like the straneous output your engine produces.

Running your engine from the command line, I get this:

Code: Select all

$ ./molecule 
table size = 1398101
>>> uci
id name Molecule v1.0
id author Filip Karlo Dosilovic
uciok
>>> position startpos

8 r n b q k b n r 
7 p p p p p p p p 
6 . . . . . . . . 
5 . . . . . . . . 
4 . . . . . . . . 
3 . . . . . . . . 
2 P P P P P P P P 
1 R N B Q K B N R 

  A B C D E F G H 
Position key: 7034930846717630053
>>> go depth 8
info score cp 50 depth 1 nodes 21 time 1 pv b1c3 
info score cp 0 depth 2 nodes 93 time 5 pv b1c3 b8c6 
info score cp 50 depth 3 nodes 634 time 7 pv b1c3 b8c6 g1f3 
info score cp 0 depth 4 nodes 2680 time 12 pv b1c3 b8c6 g1f3 g8f6 
info score cp 40 depth 5 nodes 5273 time 17 pv b1c3 b8c6 g1f3 g8f6 d2d4 
info score cp 0 depth 6 nodes 37444 time 60 pv b1c3 b8c6 g1f3 g8f6 d2d4 d7d5 
info score cp 35 depth 7 nodes 133069 time 124 pv e2e4 b8c6 g1f3 g8f6 e4e5 f6e4 b1c3 
info score cp 0 depth 8 nodes 830893 time 435 pv e2e4 b8c6 
bestmove e2e4

You need to disable the displaying of the board, because as it is your program doesn't conform to the UCI protocol, I believe.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Molecule - new engine

Post by AlvaroBegue »

Oh, actually, it's something weirder. I got PolyGlot to produce a log, and this is what it produced:

Code: Select all

$ grep Engine polyglot.log 
1493306219.434 Adapter->Engine: uci
1493306219.453 Engine->Adapter: table size = 1398101
1493306219.453 Engine->Adapter: id name Molecule v1.0
1493306219.453 Engine->Adapter: id author Filip Karlo Dosilovic
1493306219.453 Engine->Adapter: uciok
1493306219.453 POLYGLOT [PolyGlot] EngineCommand="./molecule"
1493306219.453 POLYGLOT Setting PolyGlot option "EngineCommand=./molecule"
1493306219.455 Adapter->Engine: isready
1493306219.455 Engine->Adapter: readyok
1493306219.455 Adapter->Engine: ucinewgame
1493306221.850 Adapter->Engine: position startpos moves e2e4
1493306221.850 Adapter->Engine: go wtime 61000 btime 60000 winc 1000 binc 1000
1493306221.850 Engine->Adapter: 
1493306221.850 Engine->Adapter: 8 r n b q k b n r 
1493306221.850 Engine->Adapter: 7 p p p p p p p p 
1493306221.850 Engine->Adapter: 6 . . . . . . . . 
1493306221.850 Engine->Adapter: 5 . . . . . . . . 
1493306221.850 Engine->Adapter: 4 . . . . . . . . 
1493306221.850 Engine->Adapter: 3 . . . . . . . . 
1493306221.850 Engine->Adapter: 2 P P P P P P P P 
1493306221.850 Engine->Adapter: 1 R N B Q K B N R 
1493306221.850 Engine->Adapter: 
1493306221.850 Engine->Adapter:   A B C D E F G H 
1493306221.850 Engine->Adapter: Position key: 13922090321190050460
1493306221.850 Engine->Adapter: info score cp 50 depth 1 nodes 21 time 1 pv b1c3
1493306221.852 Engine->Adapter: info score cp 0 depth 2 nodes 93 time 2 pv b1c3
1493306221.852 Engine->Adapter: info score cp 50 depth 3 nodes 634 time 3 pv b1c3
1493306221.853 Engine->Adapter: info score cp 0 depth 4 nodes 2680 time 4 pv b1c3
1493306221.854 Engine->Adapter: info score cp 40 depth 5 nodes 5273 time 5 pv b1c3
1493306221.869 Engine->Adapter: info score cp 0 depth 6 nodes 37433 time 19 pv b1c3
1493306221.911 Engine->Adapter: info score cp 35 depth 7 nodes 131871 time 61 pv e2e4
1493306222.192 Engine->Adapter: info score cp 0 depth 8 nodes 800719 time 342 pv e2e4
1493306222.530 Engine->Adapter: info score cp 25 depth 9 nodes 1608495 time 680 pv e2e4
1493306224.858 Engine->Adapter: bestmove e2e4
1493306228.064 Adapter->Engine: quit
1493306228.064 Adapter->Engine: EOF
1493306228.064 POLYGLOT Engine does not reply. Sleeping 100ms.
1493306228.164 Engine->Adapter: EOF

So it's thinking for white, although it's black's turn. Running it from the command line I didn't get it to do that. No idea what's going on.

EDIT: I managed to reproduce it from the command line. It looks like your engine behaves OK if it doesn't get a ucinewgame , but it gets confused if it does.

Code: Select all

$ ./molecule                                                                                           
table size = 1398101
>>> uci
id name Molecule v1.0
id author Filip Karlo Dosilovic
uciok
>>> isready
readyok
>>> ucinewgame
>>> position startpos moves e2e4

8 r n b q k b n r 
7 p p p p p p p p 
6 . . . . . . . . 
5 . . . . . . . . 
4 . . . . . . . . 
3 . . . . . . . . 
2 P P P P P P P P 
1 R N B Q K B N R 

  A B C D E F G H 
Position key: 17435977803395984409
go wtime 61000 btime 60000 winc 1000 binc 1000
info score cp 50 depth 1 nodes 21 time 0 pv b1c3 
info score cp 0 depth 2 nodes 93 time 4 pv b1c3 b8c6 
info score cp 50 depth 3 nodes 634 time 6 pv b1c3 b8c6 g1f3 
info score cp 0 depth 4 nodes 2680 time 11 pv b1c3 b8c6 g1f3 g8f6 
info score cp 40 depth 5 nodes 5273 time 15 pv b1c3 b8c6 g1f3 g8f6 d2d4 
info score cp 0 depth 6 nodes 37436 time 59 pv b1c3 b8c6 g1f3 g8f6 d2d4 d7d5 
info score cp 35 depth 7 nodes 132904 time 125 pv e2e4 b8c6 g1f3 g8f6 e4e5 f6e4 b1c3 
info score cp 0 depth 8 nodes 809482 time 429 pv e2e4 
info score cp 25 depth 9 nodes 1622598 time 773 pv e2e4 b8c6 d2d4 d7d5 
bestmove e2e4
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Molecule - new engine

Post by hgm »

Indeed, it seems that the position-moves handling of the engine is broken. It ignores the move.
fkdosilovic
Posts: 5
Joined: Mon Mar 13, 2017 11:25 am

Re: Molecule - new engine

Post by fkdosilovic »

Thanks for the advice.
fkdosilovic
Posts: 5
Joined: Mon Mar 13, 2017 11:25 am

Re: Molecule - new engine

Post by fkdosilovic »

Thanks for bug find and reply about UCI proctol standard.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Molecule - new engine

Post by AlvaroBegue »

The way you are parsing input is problematic. Instead of `std::cin >> command', try reading your input one line at a time, with `std::getline(std::cin, command)', then parsing the whole line.

Your handling of "ucinewgame" is failing because you are trying to call UCI::parsePositionCommand pretending the user has typed "startpos", but you then try to read more strings from the input, which are not there.

Anyway, one line at a time is the way to go.

In my own program, I process the line like this:

Code: Select all

  std::istringstream iss(line);
  std::string command;
  iss >> command;
[...]
Then I pass `iss' around so other functions can read more fields if they need them.

I can show you the whole code of my UCI implementation if you want it. It's quite clean.
fkdosilovic
Posts: 5
Joined: Mon Mar 13, 2017 11:25 am

Re: Molecule - new engine

Post by fkdosilovic »

AlvaroBegue wrote:The way you are parsing input is problematic. Instead of `std::cin >> command', try reading your input one line at a time, with `std::getline(std::cin, command)', then parsing the whole line.

Your handling of "ucinewgame" is failing because you are trying to call UCI::parsePositionCommand pretending the user has typed "startpos", but you then try to read more strings from the input, which are not there.

Anyway, one line at a time is the way to go.

In my own program, I process the line like this:

Code: Select all

  std::istringstream iss(line);
  std::string command;
  iss >> command;
[...]
Then I pass `iss' around so other functions can read more fields if they need them.

I can show you the whole code of my UCI implementation if you want it. It's quite clean.
I fixed ucinewgame problem.

Thanks for the reply. Community here is awsome.
tttony
Posts: 268
Joined: Sun Apr 24, 2011 12:33 am

Re: Molecule - new engine

Post by tttony »

fkdosilovic wrote:Hey guys,

during the last 2.5 months I've been working on a chess engine. The result of my work is Molecule (https://github.com/fkdosilovic/molecule) . Any feedback is welcome, but I'm most interested in somewhat of a legal advice.

As you'll probably read in README file, whenever I would get stuck, I would consult a "Chess engine in C" youtube series on developing a chess engine. The result of that is that search part is basically identical to VICE's. Even though I did say in README file that Molecule is derivative of VICE (because of search part) , is it legal to use the code from VICE?
Cool! my engine it's also based on VICE, it's pure C99 :D but it's weaker, I wanted to start the search and eval from zero, the movegen it's bitboard and magic

I have windows and compiled your engine with g++ 6.1.0, but when

Code: Select all

uci
ucinewgame
go infinite 
the engine just crash