Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Computer chess

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
Computer chess
Kirr
Member #5,060
September 2004
avatar

Solving mate problems is counter-productive for improving engine strength, because mate solving depends on pure tactics and discourages any positional knowledge. Although it's OK to solve mates just for fun.

Here is one much more interesting test suite: Strategic Test Suite.

Evert said:

Oh yes. The engine itself is just a few interface functions that manipulate a "game" or "board" object (one is everything to do with the current game, one is about the current position only). The interface (any interface) is deliberately decoupled from that.
Right now I have about 5 different "interfaces": the Allegro-based one, a console one I never really did anything with after making the Allegro-based one (I use it to solve individual test positions though), a "perftest" that counts the number of nodes from the starting position after a certain fixed depth and measures the time it takes to get there (useful for debugging the move generator, apparently, though it hasn't helped me there, I've mainly used it to measure the effect of optimisations on the move generator and make-move functions), a "test" driver that loads a collection of test positions and runs them through the engine for a given time-per-move and the UCI interface (to the extent that this currently supports the full UCI protocol). Only the Allegro-based interface depends on Allegro.

Excellent! Naturally I am only interested in a UCI version. :)

Evert said:

Hmm... ok, I'll bear that in mind. My code still doesn't have an opening book (although it doesn't bodge things up as badly as it used to anymore) but since it's a UCI engine, I've taken the cheap way out and let the interface handle the opening for now (since I'm playing it against xboard engines under xboard, that means I'm running it through polyglot).

With or without opening book code is both fine. Most chess interfaces provide book handling, as well as polyglot of course. If you'll decide to implement opening book, please provide a way to disable it, because many tournaments accept only engines that can play without own opening book.

Evert said:

Thanks! I'll have a look. My understanding of bitbases is that they only offer information on whether a position is "won", "lost" or "draw". While I'm sure that's useful information, I need to work out how to implement that in the alpha-beta framework of a chess engine, where I'd typically want to know more than simply "won"; for instance, won in how many moves.
On the other hand, the main advantage is probably that you get an accurate evaluation of the position in a leave node near the search horizon after exchanging into the end game, where you otherwise wouldn't be able to tell as accurately whether it's a good ending or not and so whether you should exchange into it or not.

Exactly. Yes, bitbases only have "win/loss/draw" information, but it's often enough. On the upside, bitbases are small and fast, so you can probe them long before the exchange, to know which endgame to convert to. Although winning some won endings (like some kqpkq positions) with just bitbases may be tough or impossible.

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

ReyBrujo
Moderator
January 2001
avatar

Evert said:

In practice it doesn't really matter of course if you find a mate-in-N or a mate-in-N+a-bit, as long as you actually deliver the mate!

As long as your opponent doesn't have a mate-in-N-a-bit :P

Once I arrive home I will post the most beautiful game I have ever read about, to demonstrate machines can't yet reach a human's inventive ;)

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Evert
Member #794
November 2000
avatar

Kirr said:

Solving mate problems is counter-productive for improving engine strength, because mate solving depends on pure tactics and discourages any positional knowledge. Although it's OK to solve mates just for fun.

Yes, and it should play them out properly after finding them. It's also useful to check if the engine will correctly detect deep combinations that may show up outside of the principle variation that it builds up. I haven't tried to write an efficient mate-solver though, mainly for the reason you mentioned: it's a waste of time in terms of actual playing strength.
That said, I've probably seen better improvements on test scores from tuning based on actual games than from tuning based on test score results...

Quote:

If you'll decide to implement opening book, please provide a way to disable it, because many tournaments accept only engines that can play without own opening book.

I think the UCI specification demands that you do that.
Not that I believe all engines implement the UCI specification to the letter. ;)

ReyBrujo said:

As long as your opponent doesn't have a mate-in-N-a-bit :P

In that case the position will not be scored as mate-in-N+a-bit in your favour. ;)

Quote:

Once I arrive home I will post the most beautiful game I have ever read about, to demonstrate machines can't yet reach a human's inventive

Oh, most computers play a horrible kind of chess, and perform very poorly in closed strategic positions. They've become a lot better and maybe the top engines these days can't be defeated by "anti-computer" tactics so easily anymore, but all of the weaker ones almost certainly can be.

EDIT: Latest source attached.
It should now compile cleanly on both OS X and Linux (I haven't tried Windows, but since I haven't done anything for Windows specifically, it's likely to be as hard to compile there as the previous version was; MinGW might work though).
There are various improvements and enhancements, and the engine should play a better game than the one I posted here earlier (but maybe not as good overall as some of my earlier builds; I've been adding new functionality to the evaluation function and I don't think everything has been properly tuned yet - and of course, there's still a lot missing there too).
To build the UCI engine (for running using a generic GUI rather than the build-in Allegro5 one), run "make ucijazz". The UCI implementation is a bit rough at the moment, but it works well enough to play a game.
The engine's time management isn't that great at the moment (again, something I would need to tune); I find it plays best when given a fixed time per move...

EDIT2: Oh, before I forget: to build the Allegro 5-based GUI, you'll need the latest (SVN) version of Allegro...

Kirr
Member #5,060
September 2004
avatar

It compiled fine here under Windows, and I started some test matches with it. I only compiled UCI version. Some comments so far:
1. I had to add qsort.o into makefile.
2. The engine does not print anything when it is thinking. When it moves, it sends no evaluation or ponder move.
3. An engine sais it's named "Jazz (i386)". It's better to specify its version there too. Releasing engine without version will result in a mess when people will try to run matches with it and report results.

More after some games are finished. :)

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Evert
Member #794
November 2000
avatar

Kirr said:

It compiled fine here under Windows,

Amazing!

Quote:

and I started some test matches with it.

Cool. It'll be interesting to know how things run.

Quote:

I only compiled UCI version.

Makes sense.

Quote:

1. I had to add qsort.o into makefile.

Right. At the moment, it's only added on Linux. I should probably add it for MinGW as well, but better would be to detect when it's needed and when it isn't.
Or just always use it, even if a native version is available...

Quote:

2. The engine does not print anything when it is thinking.

That's odd. It should, and does for me when I run it under a UCI interface here (but it doesn't when I run it through polyglot in XBoard).

Quote:

When it moves, it sends no evaluation or ponder move.

Right, as I said, the UCI implementation is somewhat incomplete. Not sending a ponder move is correct: at the moment, the engine cannot ponder. This is actually relatively easy to add using UCI (just make the next move from the principle variation and enter an infinite search), but I haven't got round to doing this.

Quote:

3. An engine sais it's named "Jazz (i386)". It's better to specify its version there too. Releasing engine without version will result in a mess when people will try to run matches with it and report results.

It'll have a proper version when it's properly released. ;)
I'll stick something temporary in there now, so you can always identify different versions (this being the only one not to report any version information).

Kirr
Member #5,060
September 2004
avatar

I compiled it using cygwin so I did not expect too much trouble. Although cygwin is 32-bit only. Does Jazz benefit from 64-bit?

Well the good news is that it works and did not crash or hang yet. The bad news: it's losing most of the games, probably because of broken time management. I use TC of 4 seconds for 40 moves, repeated. What Jazz does looks like this: at first all looks normal, then it starts thinking longer and longer on each move. Its time usage peaks at move 20, then the time is almost out, so it spends about a second on each move. On move 40 it receives another 4 minutes, so it starts thinking longer again. Then the time usage again peaks on move 60, and instant play after that.

It is playing with "Gk 0.90 64-bit JA" and "WJChess 1.64".

Evert said:

Right. At the moment, it's only added on Linux. I should probably add it for MinGW as well, but better would be to detect when it's needed and when it isn't.
Or just always use it, even if a native version is available...

I would just add it for all cases. :)

Evert said:
Kirr said:

2. The engine does not print anything when it is thinking.

That's odd. It should, and does for me when I run it under a UCI interface here (but it doesn't when I run it through polyglot in XBoard).

Not sure what's wrong there, I may look into it in more detail if I have time.

Evert said:
Kirr said:

When it moves, it sends no evaluation or ponder move.

Right, as I said, the UCI implementation is somewhat incomplete. Not sending a ponder move is correct: at the moment, the engine cannot ponder. This is actually relatively easy to add using UCI (just make the next move from the principle variation and enter an infinite search), but I haven't got round to doing this.

Usually UCI engines send a ponder move even in ponder off mode, and even when they can't ponder at all. This way an engine tells which move it expects from the opponent, which may be useful for things other than pondering. I don't mean you have to do it, but it's a good style. Anyway, it's just next move from the PV as you say.

Evert said:

It'll have a proper version when it's properly released. ;)
I'll stick something temporary in there now, so you can always identify different versions (this being the only one not to report any version information).

Yeah, anything is good as long as it's different from one version to another. :)

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Evert
Member #794
November 2000
avatar

Kirr said:

Although cygwin is 32-bit only. Does Jazz benefit from 64-bit?

Considerably. The 64 bit version is about twice as fast as the 32 bit version on my test machine. Note that I've done all of my development in 64 bit and haven't (yet) made any effort to speed up 32 bit.
On the other hand, a factor 2 is "only" one ply of search... which makes a difference, but the difference between 10 and 11 ply shouldn't be so shocking, especially considering that the principle variation will probably be searched deeper and that this excludes the quiescence search.

Quote:

Well the good news is that it works and did not crash or hang yet.

Good, it shouldn't. That's not saying it never will, of course, but I hope I've been careful about fixing things like that.

Quote:

The bad news: it's losing most of the games, probably because of broken time management. I use TC of 4 seconds for 40 moves, repeated. What Jazz does looks like this: at first all looks normal, then it starts thinking longer and longer on each move. Its time usage peaks at move 20, then the time is almost out, so it spends about a second on each move. On move 40 it receives another 4 minutes, so it starts thinking longer again. Then the time usage again peaks on move 60, and instant play after that.

That does sound similar to what I'm seeing. What it should do is divide the remaining time by the number of moves until the next time control and add half the increment (if there is one) and use that amount of time for each move. It's not particularly clever, but it should work nevertheless.
I suppose it's possible that I'm not checking the clock often enough during the search, but I wouldn't have thought it would cause that many problems. Certainly something I'll have to experiment with a bit. I keep a log of all UCI commands received by the engine, so I can at least look at that and try to reproduce what it's doing during the game (oh, you may want to remove that log, since it's appended to and never deleted. I'll make that a debug option so it doesn't get written by default).

I don't suppose you keep records of the individual games (PGN)? I'd be interested in checking some of them to work out where the problem lies. Major shortcomings I've noticed are in its idea of king safety (it'll castle and keep its pawn shield in tact after that, but it doesn't take much to have it wreck either before that, so it'll often either castle into a wide-open king side, or move the king on its own) and playing endgames. In particular rook endings, which is probably due to the very poorly tuned evaluation in the end game. And possibly the lack of bitbases for those cases as well.

Kirr
Member #5,060
September 2004
avatar

OK, then I guess I or someone will have to try and build a 64-bit Windows binary when it's ready for prime time. :) (Most of tournaments are run under Windows for historical reasons).

Of course I keep all the games. :) I'll post the PGN of the complete matches, should be sometime tomorrow. By the way, do you also need that log-file?

I just checked that log-file and it only contains what engine received, but not what engine printed, so it does not help to understand why no engine output is shown when it's thinking.

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Evert
Member #794
November 2000
avatar

Kirr said:

OK, then I guess I or someone will have to try and build a 64-bit Windows binary when it's ready for prime time. :)

Yup. The new 64-bit GCC released for Windows the other day[1] looks interesting for that.

Quote:

(Most of tournaments are run under Windows for historical reasons).

Interesting. I wonder what the main reason for that is, although I suppose most commercial engines being only available for Windows and most hobbyist programmers also (historically at least) using Windows has something to do with it. Crafty and GNUchess being obvious examples of engines that were born on different platforms.

Quote:

Of course I keep all the games. :) I'll post the PGN of the complete matches, should be sometime tomorrow.

Ok, great!

Quote:

By the way, do you also need that log-file?

Probably not; unless I know what I'm looking for exactly it's probably too large and unwieldy to work out which line in the file corresponds to which position in which game.

Quote:

I just checked that log-file and it only contains what engine received, but not what engine printed, so it does not help to understand why no engine output is shown when it's thinking.

That's actually just a matter of un-commenting one line in the source and commenting another, but what I'd do (probably will do, when I get round to it) is just start ucijazz in a terminal and send it position and go commands from the log. That's also how I plan to debug the time management.

EDIT
In fact, sending

Quote:

position startpos moves c2c4 g8f6 d2d4 b8c6 g1f3 d7d5 f3e5 c6e5 d4e5 f6g4 d1d5 d8d5 c4d5 g4e5 c1f4 f7f6 b1a3 c7c6 f4e5 f6e5 d5c6 b7c6 a3c4 e5e4 e2e3 c8e6 c4e5 e6d5 a1c1 a8b8 b2b3 b8b6 f1c4 b6b8 c4d5 c6d5 e1g1 b8a8
go wtime 46790 btime 72590 winc 2000 binc 2000

(The last two lines of the logfile on my machine) I get

Quote:

info depth 1 score cp 137 nodes 150 time 92
info currmove f1d1
info currmove c1c5
info currmove c1c7
info currmove f1e1
info currmove c1c6
info currmove c1c3
info currmove b3b4
info currmove c1c2
info currmove c1d1
info currmove a2a3
info currmove h2h3
info currmove e5g4
info currmove e5c6
info currmove h2h4
info currmove a2a4
info currmove g2g4
info currmove g2g3
info currmove g1h1
info currmove f2f3
info currmove f2f4
info currmove c1e1
info currmove c1a1
info currmove c1b1
info currmove e5c4
info currmove e5g6
info currmove e5f3
info currmove e5d7
info currmove e5f7
info currmove c1c4
info currmove e5d3
info currmove c1c8
info depth 3 score cp 102 nodes 330 time 98
[...]
etc.

which seems right to me.
However, it doesn't send a principle variation. I thought I made it do that, but maybe it only prints it in its "native" output (which is suppressed when using UCI). There are issues with it anyway, since now and then the principle variation will be truncated by the transposition table. I know how to fix that (if the new PV is shorter than the old one, but the moves that are there are the same, keep the old one - or alternatively and in addition, try to reconstruct the missing part from the transposition table) but I haven't got round to it yet...

References

  1. I did briefly look into what it is exactly; seems to be some sort of fork from MinGW, but it seems to carry some political baggage I din't feel like reading through...
Kirr
Member #5,060
September 2004
avatar

OK, here are some games (attached):

Jazz (i386) - WJChess 1.64: 4.5 - 27.5
Jazz (i386) - Gk 0.90 64-bit JA: 8.5 - 23.5

Not as bad as it looked from the beginning. Still it probably can do much better with fixed time allocation.

Evert said:

Interesting. I wonder what the main reason for that is, although I suppose most commercial engines being only available for Windows and most hobbyist programmers also (historically at least) using Windows has something to do with it. Crafty and GNUchess being obvious examples of engines that were born on different platforms.

Somewhere in late 90's, thanks to the activity of Chessbase and other vendors of commercial software, Windows became de-facto standard for any serious chess (or computer chess) hobbyist. Then it entered an infinite loop - new authors and companies target Windows because 99% of potential users use Windows. Users keep using Windows because it can run about 100% of chess software.

Evert said:

However, it doesn't send a principle variation. I thought I made it do that, but maybe it only prints it in its "native" output (which is suppressed when using UCI). There are issues with it anyway, since now and then the principle variation will be truncated by the transposition table. I know how to fix that (if the new PV is shorter than the old one, but the moves that are there are the same, keep the old one - or alternatively and in addition, try to reconstruct the missing part from the transposition table) but I haven't got round to it yet...

Sorry, yes, that's what I meant. It does not send the PV, so I can't see what move it preferring currently, when it is still thinking.

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Evert
Member #794
November 2000
avatar

Kirr said:

OK, here are some games (attached):

Jazz (i386) - WJChess 1.64: 4.5 - 27.5
Jazz (i386) - Gk 0.90 64-bit JA: 8.5 - 23.5

Thanks!
I had a quick look at four of the games (one win and one loss against each of the opponents); it's a bit confusing. For the most part, Jazz seems to play decently well in the middle game, although it doesn't quite centralise its pieces as efficiently as it could and it seems to like leaving a pawn vulnerable and then stepping in to defend it at the last moment, which isn't so good. The way it plays endings looks pretty bad, and I've seen it drop a piece in both the losses I looked at in a position where I wouldn't have thought it necessary to do so. That could be the broken time management ruining things; I should check whether these blunders correlate with move number.

Quote:

Users keep using Windows because it can run about 100% of chess software.

It's the same everywhere. :P
I neglected to mention Glaurung as another example of an engine that originated on another platform above.

Quote:

Sorry, yes, that's what I meant. It does not send the PV, so I can't see what move it preferring currently, when it is still thinking.

Right, I checked the code, and it indeed doesn't send the PV in UCI mode. I'll fix that once I have the code to "keep" the PV (what I described earlier) in place.

By the way, I fixed a rather nasty bug late last night: when generating check evasions, Jazz will only generate moves that can eliminate the check (as opposed to generating all moves and discard the ones that don't eliminate check afterwards). It will generate captures (of the checking piece, if there is only one), legal king moves and (finally) moves that interrupt the line of sight of the checking piece. However, there was a bug where it would not generate these if the check was across a file. By ill luck, this didn't show up in any of the test positions I tested the new code on, but I found it yesterday when I used the same lookup tables for something else.
At worst, this bug could have lead Jazz to see a mate where there wasn't one, but the most probably effect is that it miscalculated the best response to check, maybe dropping a piece or walking into a forced mate in the process. I'll check to what extent this may have damaged match results locally, then attach a new version later on.

S G
Member #10,564
January 2009

Hi Evert,

Great to see there's still people with enough enthusiasm to write chess playing programs. I dedicated a huge amount of time to writing an engine back in the 1990's.

It's a fun experience - as well as the programming side of things, I got to meet some interesting folk, and to travel around a bit to the world microcomputer chess championships.

I haven't developed my program for a few years, though - kinda got burned out on that front. If your engine runs under Winboard, give it a whirl against mine? She's called Francesca.

Anyhow, good luck and have fun with your computer chess developments :D

Alianix
Member #10,518
December 2008
avatar

It crashed on me Evert, I attached the console output so maybe you can figure out why.

Edit:

Just happened again in a similar way... ::)

Kirr
Member #5,060
September 2004
avatar

Evert said:

I should check whether these blunders correlate with move number.

The PGN includes thinking times, depth, evaluation and expected opponent's move (when it is different from the one played). BTW this is another downside of Jazz not sending a PV: there are no Jazz' evaluations or expected moves in the PGN. Sometimes they are very useful to see what happened in the game.

Evert said:

I'll check to what extent this may have damaged match results locally, then attach a new version later on.

Hopefully also with a time management fix. :)

S G said:

I haven't developed my program for a few years, though - kinda got burned out on that front. If your engine runs under Winboard, give it a whirl against mine? She's called Francesca.

Hi S G! Francesca is doing fine in my tourney[1], but unfortunately she can't use external book (because of missing support for setting a position). So she has to play without any opening book at all which probably handicaps her considerably.

References

  1. KCEC

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Evert
Member #794
November 2000
avatar

S G said:

Great to see there's still people with enough enthusiasm to write chess playing programs.

There seems to be a fairly active community for it, although I can't really judge how large the influx of new people is.
I guess writing a chess program is a fairly daunting task and requires some dedication and attention to details (in other words, you need to write reasonably bug-free code), so I can imagine people getting started on it and then abandoning the prject before it gets anywhere.

Quote:

I dedicated a huge amount of time to writing an engine back in the 1990's.

Cool. My first chess program was from 1996 or so. I can't run it now though, because it was written in Turbo Pascal mixed with assembly language (actually, almost everything was written in assembly). It played horrible though.

Quote:

It's a fun experience - as well as the programming side of things, I got to meet some interesting folk, and to travel around a bit to the world microcomputer chess championships.

That would be fun to do - but I'm afraid finding the time for something like that will be hard...

Quote:

I haven't developed my program for a few years, though - kinda got burned out on that front. If your engine runs under Winboard, give it a whirl against mine? She's called Francesca.

I'll give it ago! I decided to implement the UCI protocol (it's a bit simpler), but I can run through XBoard using a translator.

Alianix said:

It crashed on me Evert, I attached the console output so maybe you can figure out why.

Damn! Sorry about that... :-/
Any chance you could send me your moves so I can try to reproduce the sequence of moves here?
Alternatively (or perhaps even better), if you're willing to look into this, could you send me a gdb backtrace?

Kirr said:

Hopefully also with a time management fix.

Heh. I'll do my best.
:)

Alianix
Member #10,518
December 2008
avatar

You must be tired Evert, for you forgot to read my post completely...
;D

Also the flickering is related to the compositor...I ran it from gdb but it froze my machine...rare on Linux but it did happen... i had to press the power button... :-/

I think it has to do with allegro and specifically the opensource ati driver...it's buggy.
Edit:

I was able to beat jazz after a couple of games, I think it plays a pretty good game at 5secs. It's weakness is the early middle game i believe.

Evert
Member #794
November 2000
avatar

Alianix said:

You must be tired Evert, for you forgot to read my post completely...
;D

It was late, but I think I read everything: it crashed, you attached the console output, then it crashed again in the same (or a similar) way. In the log you showed, there is a segfault after a 7 ply search... but that knowledge alone isn't enough to debug the problem, I probably need at least the sequence of moves from the initial position if I'm going to try to reproduce it...

Quote:

Also the flickering is related to the compositor...

Hmm. Do you see the same thing with the A5 examples or demo?

Quote:

I ran it from gdb but it froze my machine...rare on Linux but it did happen... i had to press the power button... :-/

Woops! Again, sorry about that... it doesn't do that for me, but that doesn't help you. If you have the core dump, you should also be able to get a backtrace from that (gdb jazz core).

Quote:

I think it has to do with allegro and specifically the opensource ati driver...it's buggy.

Perhaps... still, would be good to sort out.

Quote:

I was able to beat jazz after a couple of games, I think it plays a pretty good game at 5secs. It's weakness is the early middle game i believe.

:)
Against humans, quite possibly. Against other computers, I'm not so sure... I've seen it play a pretty lousy end game as well.
The early middle game is probably where the search is shallowest (well, the opening will be worse, but it's not as important there) and where the lack of certain evaluation features (most notably, proper king safety) hurts most. If it gets through this stage without wrecking its king's position, it probably won't unless pressured, so it should do ok in that case and reach the end game ok. The end game evaluation is crude and inaccurate, but the search depth at least partly makes up for it. Again maybe not against other computers, but against humans it probably does.

S G
Member #10,564
January 2009

Kirr - I checked out your website, what a fantastic effort.

Evert - I look forward to some Jazz vs Francesca games. Have fun with your development!

Greetz

Alianix
Member #10,518
December 2008
avatar

I'm not able to save with F6, getting a zero length file.

Evert
Member #794
November 2000
avatar

Weird. Under which conditions? I'll see if I can reproduce it here.
To be clear, F6 is only supposed to save the position, not the entire game.

EDIT:
Interesting. I've been playing with the move ordering scheme, and there is a clear asymmetry between black and white in the order in which moves are searched and generated (not surprising, considering the way in which I generate the moves), which makes a big difference in the speed of the program: some test positions are solved almost twice as fast with white to move than the flipped positions with black to move.
That's nasty, and I'll need to fix that...

 1   2   3   4 


Go to: