Sargon 1978 UCI Available

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Bill Forster
Posts: 76
Joined: Mon Sep 21, 2015 7:47 am
Location: New Zealand

Re: Sargon 1978 UCI Available

Post by Bill Forster »

Chessqueen wrote: Tue Jan 19, 2021 4:57 am I thought that the repetition bug was fixed but the Beta in a winning position repeated three times :?:
Do you ever read my posts? Or do you just assume I can perform magic feats? I have explained the limitations of my work around multiple times. In my testing sometimes the work around enables Sargon 1978 to overcome its problems finishing off winning positions. But often (as in this case) it doesn't.

All the work around does is prevent Sargon repeating the position if it thinks it is winning. As I have pointed out several times. Without the workaround Sargon 1978 unthinkingly repeats, even in overwhelming positions. Now it never does. But that doesn't mean it will find a way to make progress. And if the opponent finds a way of repeating the position (which is what happened in your example) the work around has no impact at all.

In my tests Sargon 1978 with the work around quickly finished me off from overwhelming positions it had previously conceded repetition draws in. But in less overwhelming positions it often just meandered and didn't eventually win. Although in one game I was pleased to see it win a two pawns up ending (with just mildly sloppy defence from me). This is the first time it had won a game like this against me (before the work around Sargon 1978's wins against me always involved some kind of devastating combination [or blunder by me] in the middlegame).
Uri Blass
Posts: 10297
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Sargon 1978 UCI Available

Post by Uri Blass »

If I understand correctly sargon now only know not to play a move that force a draw by repetition when it has a better alternative.

It does not have draw by repetition knowledge during the search(and note that you do not need hash tables for it but only to see that the line in the search leads to a draw by repetition so you evaluate it as a draw).
Bill Forster
Posts: 76
Joined: Mon Sep 21, 2015 7:47 am
Location: New Zealand

Re: Sargon 1978 UCI Available

Post by Bill Forster »

Uri Blass wrote: Tue Jan 19, 2021 7:29 am If I understand correctly sargon now only know not to play a move that force a draw by repetition when it has a better alternative.

It does not have draw by repetition knowledge during the search(and note that you do not need hash tables for it but only to see that the line in the search leads to a draw by repetition so you evaluate it as a draw).
This is exactly right.

In general my goal in this project was simply to convert the classic Z80 code to X86 with no emulation or simulation to see how quickly it would run on modern machines. Once I met that goal I started adding things on;
  • Allowing arbitrary depth instead of the original hardwired limit of depth 6
  • Give it a UCI interface so it can run as an engine in a GUI
  • Not just adding the most basic play a game UCI commands, but including arbitrary position setup, optional dynamic depth, time management and most importantly and a real bonus ....
  • Teasing out the PV and a centipawn evaluation! The original code makes no attempt to collect this information and provide it to the user in any way
  • Opening up the minimax and alpha-beta algorithms, demonstrating how they work with runtime ascii art "animation" (sort of).
  • Providing a faithful conversion of the original Z80 code to genuine Z80 mnemonics as a side effect. Retro hackers should prefer using this version to the extant Sargon code which uses odd non-standard third party mnemonics.
All of these extra things are just bonuses though. And none of them require any changes to the core Sargon 1978 chess code.

Similarly, the fact that the engine is perhaps a reasonably fun partner for weak to average players is just a happy accident (another bonus) not really a project goal.

When I realised I could work around the annoying habit of Sargon being too keen to repeat positions, by asking it to try again with the offending repeating move removed from its list of candidate moves - I thought why not? Although this is the closest I have come yet to changing the Sargon 1978 chess code itself. Arguably I may even have stepped over the line (because I had to write some external C code to peer into the implementation and pluck out the offending move).

I am now wondering about supercharging the Sargon 1978 code when there aren't too many pieces on the board. Again I want to leave the chess algorithm in tact - just have it produce the same results faster. In that case it would hopefully be able to calculate for example a 'seize the opposition' move in a simple pawn endgame in much less than 3 minutes. The idea is to add a transposition table cache around the outside, like a kind of code exo-skeleton. I don't yet know if this is even possible. I will have to revisit the tree building order etc. I don't know much about hash caches, I've only ever worked on primitive and retro engines without them. My intuition is that this would only be useful in the ending, when presumably Sargon 1978 is recalculating a comparitive handful of possible positions over and over again. But I can't really judge unless I actually go ahead and try to do it, at the moment I lack the requisite expertise. But it sounds like a potentially fun way of extending the Sargon 1978 project even further.
Rowen
Posts: 74
Joined: Tue Nov 15, 2016 1:19 pm
Location: Cheshire, England

Re: Sargon 1978 UCI Available

Post by Rowen »

rcmaddox wrote: Wed May 27, 2020 4:58 am Bill Forster, author of the Tarrasch GUI, has released a UCI version of Sargon, the well known program from the Spracklens.

I had a copy of Sargon in the early 80's running on my Commodore VIC-20, using a black and white television for a monitor! It was my first chess software that wasn't in a dedicated chess computer.

So here ya go:

Main Tarrasch GUI Website ---->> http://www.triplehappy.com/
Link to Releveant Blog Post ---->> https://triplehappy.wordpress.com/
Hello Mr Forster
Thank you for your work on Sargon, I enjoy playing against it and it seems to play quite a solid game and from my perspective it makes a good training engine as it is approximately my strength. It is clearly an old program but that is why It is still playable from a strength perspective, so if it doesn't understand repetition etc, that's a function of its age. If you improve on it, great, but if you don't, thanks for your work in porting to UCI.

I also enjoy using your Tarrasch gui , it is a good minimalist program that I use solely to play against engines. I was wondering if it could be easier to change Engine options (parameters). I am aware that there are ways and workarounds,which I do implement, so it isn't that important, but I thought Id just ask.
Once again, Thank you for your work.
Chessqueen
Posts: 5588
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

Bill Forster wrote: Tue Jan 19, 2021 9:57 am
Uri Blass wrote: Tue Jan 19, 2021 7:29 am If I understand correctly sargon now only know not to play a move that force a draw by repetition when it has a better alternative.

It does not have draw by repetition knowledge during the search(and note that you do not need hash tables for it but only to see that the line in the search leads to a draw by repetition so you evaluate it as a draw).
This is exactly right.

In general my goal in this project was simply to convert the classic Z80 code to X86 with no emulation or simulation to see how quickly it would run on modern machines. Once I met that goal I started adding things on;
  • Allowing arbitrary depth instead of the original hardwired limit of depth 6
  • Give it a UCI interface so it can run as an engine in a GUI
  • Not just adding the most basic play a game UCI commands, but including arbitrary position setup, optional dynamic depth, time management and most importantly and a real bonus ....
  • Teasing out the PV and a centipawn evaluation! The original code makes no attempt to collect this information and provide it to the user in any way
  • Opening up the minimax and alpha-beta algorithms, demonstrating how they work with runtime ascii art "animation" (sort of).
  • Providing a faithful conversion of the original Z80 code to genuine Z80 mnemonics as a side effect. Retro hackers should prefer using this version to the extant Sargon code which uses odd non-standard third party mnemonics.
All of these extra things are just bonuses though. And none of them require any changes to the core Sargon 1978 chess code.

Similarly, the fact that the engine is perhaps a reasonably fun partner for weak to average players is just a happy accident (another bonus) not really a project goal.

When I realised I could work around the annoying habit of Sargon being too keen to repeat positions, by asking it to try again with the offending repeating move removed from its list of candidate moves - I thought why not? Although this is the closest I have come yet to changing the Sargon 1978 chess code itself. Arguably I may even have stepped over the line (because I had to write some external C code to peer into the implementation and pluck out the offending move).

I am now wondering about supercharging the Sargon 1978 code when there aren't too many pieces on the board. Again I want to leave the chess algorithm in tact - just have it produce the same results faster. In that case it would hopefully be able to calculate for example a 'seize the opposition' move in a simple pawn endgame in much less than 3 minutes. The idea is to add a transposition table cache around the outside, like a kind of code exo-skeleton. I don't yet know if this is even possible. I will have to revisit the tree building order etc. I don't know much about hash caches, I've only ever worked on primitive and retro engines without them. My intuition is that this would only be useful in the ending, when presumably Sargon 1978 is recalculating a comparitive handful of possible positions over and over again. But I can't really judge unless I actually go ahead and try to do it, at the moment I lack the requisite expertise. But it sounds like a potentially fun way of extending the Sargon 1978 project even further.

Mr. Forster, thanks very much for your explanation, and also thanks for making this project to convert Sargon 1978 into a fun challenger for human players rated between 1600 thru 1650. Today I wanted to know if a human rated between 1600 to 1650 could convert this overwhelming winning Black position from yesterday previous game between the two Sargons into a win, so I copied this position and emailed it to my friend in Puerto Rico Sanchez Martinez, Xavier rated only 1620 and asked him over the phone if he can take at look at this position that I emailed him after 37. Rh1 and in less than two minutes he can tell me how he would plan to beat Sargon-1978-V1.01Beta which I provided the download Link. After he looked at the position it took him about 1 minutes and 50 seconds, then he told me that because of the Black Bishop controlling the diagonal even if he did not have the White Bishop that he could convert this position into a win. So after he told me that I asked him to play it out in 10'+5" and to email me the game when he finished. I gave him the position after 37. Rh1 with Black to play and that is when i called him and told him to look at it and before he play to win with Black to discuss with me his plan, like that I knew that he was not going to use an engine to cheat. I usually talk with friends from other counties using Skype, just to check if they are cheating or NOT. :roll:

[pgn][Event "human rated 1620 Vs Sargon Beta"]
[Date "2021.01.18"]
[Round "?"]
[White "Sargon-1978-V1.01Beta"]
[Black "Sanchez Martinez, Xavier"]
[Result "0-1"]
[BlackElo "1665"]
[ECO "C47"]
[Opening "Four Knights"]
[Time "11:47:02"]
[Variation "Scotch, 4...exd4 5.Nxd4 Bb4"]
[WhiteElo "1660"]
[TimeControl "600+5"]
[Termination "normal"]
[PlyCount "81"]


1. e4 e5 2. Nf3 Nc6 3. Nc3 Nf6 4. d4 exd4 5. Nxd4 Bb4 6. Qd3 Qe7 7. Nxc6
dxc6 8. f3 O-O 9. Bg5 Rd8 10. Qe3 Qe5 11. a3 Bc5 12. Qf4 Qd4 13. Qh4 Be6
14. Rd1 Qe5 15. Rxd8+ Rxd8 16. Bf4 Qd4 17. Bd3 Bxa3 18. Bxc7 Bxb2 19. Bxd8
Bxc3+ 20. Ke2 Qxd8 21. e5 Bxe5 22. Bxh7+ Kf8 23. Rd1 Qc7 24. Be4 Nd5 25.
Bxd5 cxd5 26. Qa4 Bxh2 27. Rb1 a5 28. Qb3 d4 29. Qb2 Bd5 30. Kd1 Be5 31.
Qb6 Qxb6 32. Rxb6 Bc6 33. Kd2 Ke7 34. Rb1 a4 35. Re1 Kd6 36. Rb1 b5 37. Rh1 b4
38. Rb1 a3 39. Rh1 d3 40. cxd3 Bc3+ 41. Kc2 Ba4+ 42. Kb1 Bb3 43. g3 a2+ 44. Kc1
a1=Q# 0-1[/pgn]
Who is 17 years old GM Gukesh 2nd at the Candidate in Toronto?
https://indianexpress.com/article/sport ... t-9281394/
Chessqueen
Posts: 5588
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

My friend from Puerto Rico rated 1620 Martinez Xavier decided to play 10 game at 10'+5" and he just called me saying the he is losing 3 lost, 2 wins and 1 draws . Which is good news, but he noticed that Sargon is probably near 1700 tp 1715 in the middlegame stronger than him in tactics, but very weak in the endgame without EGTB. :roll:
Who is 17 years old GM Gukesh 2nd at the Candidate in Toronto?
https://indianexpress.com/article/sport ... t-9281394/
Chessqueen
Posts: 5588
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

My friend from Puerto Rico rated 1620 Sanchez Martinez Xavier decided to play 10 game at 10'+5" his final score was 4 lost, 3 wins and 3 draws . Which is good news, but he noticed that Sargon is probably near 1700 to 1730 in the middlegame stronger than him in tactics, but very weak in the endgame without EGTB.

Note: I forgot to mentioned since I just called him a few minutes ago that the computer that he used was a mere Intel i5 10600K Desktop with 6 cores at 4,8 GHZ which for Sargon Beta it can only use one core, but still a very decent computer. Again Final Score was 4 Lost, 3 wins and 3 draws. :roll:
Who is 17 years old GM Gukesh 2nd at the Candidate in Toronto?
https://indianexpress.com/article/sport ... t-9281394/
Bill Forster
Posts: 76
Joined: Mon Sep 21, 2015 7:47 am
Location: New Zealand

Re: Sargon 1978 UCI Available

Post by Bill Forster »

Rowen wrote: Tue Jan 19, 2021 1:20 pm
Hello Mr Forster
Thank you for your work on Sargon, I enjoy playing against it and it seems to play quite a solid game and from my perspective it makes a good training engine as it is approximately my strength. It is clearly an old program but that is why It is still playable from a strength perspective, so if it doesn't understand repetition etc, that's a function of its age. If you improve on it, great, but if you don't, thanks for your work in porting to UCI.

I also enjoy using your Tarrasch gui , it is a good minimalist program that I use solely to play against engines. I was wondering if it could be easier to change Engine options (parameters). I am aware that there are ways and workarounds,which I do implement, so it isn't that important, but I thought Id just ask.
Once again, Thank you for your work.
Thanks for your support. The engine options in Tarrasch are embarrassing. I hope to address it one day. My priority is to improve the code base in the hope of attracting other programmers to help. In the years I've been working on it C++ has changed dramatically. I have used C++11 features to improve some aspects of the code, but there's a lot more technical debt to be worked through before it would be comfortable for others to work with I think.

Sometimes (often) I think I should just let it go and only fix bugs. The danger with making improvements is that you introduce new bugs, I don't have the resources to re-test the whole thing before every release. Today for example I am scrambling to put out a maintenance release because it turns out I introduced a new (and very embarrassing - a whole minor feature doesn't work at all) bug with my last release in November. Because the program remains a niche one, even quite significant bugs like this can go unreported for two months.

I am surprised you use it to play against engines. That was my original application too, but I've hardly touched that for years and years. When I came to play my little match against Sargon 1978 I found it wasn't ideal any more - things have moved on. I missed being able to "pre-move" as I am used to on Lichess for example. At least I am pleased that a few years ago someone convinced me to allow the option of making a noise (even if it's only the system bell) when the engine moves. I quickly realised the importance of this in blitz in particular and turned it on for my personal use for the first time.
Chessqueen wrote: Wed Jan 20, 2021 6:55 pm My friend from Puerto Rico rated 1620 Sanchez Martinez Xavier decided to play 10 game at 10'+5" his final score was 4 lost, 3 wins and 3 draws . Which is good news, but he noticed that Sargon is probably near 1700 to 1730 in the middlegame stronger than him in tactics, but very weak in the endgame without EGTB.
Yes Sargon 1978 is very weak in endgames because of its broad shallow search and its lack of chess knowledge. It doesn't realise pawns are potential new queens and doesn't bother advancing them in the endgame (except more or less by accident). Sometimes (more luck than anything) one of its pawns gets close enough to the end zone that a new queen might appear in the next handful of moves, only then does Sargon get the message.

In general there are (at least) two ways for weak players to beat Sargon;
1) Don't do anything, be patient, swap at every opportunity, wait for the endgame.
2) Build a massive attack, sacrificing if necessary, Sargon won't see deep enough to understand the point.

Of course 2) is a lot more fun than 1) and in my match I was yielding to the temptation to take that approach, when 1) is more cold-blooded and would have yielded better results. The fact that the opening book I was using led to exciting positions made 1) doubly hard to indulge.
Bill Forster
Posts: 76
Joined: Mon Sep 21, 2015 7:47 am
Location: New Zealand

Re: Sargon 1978 UCI Available

Post by Bill Forster »

Oh and incidentally, if you for some reason care about your results against Sargon 1978 never resign. Go for an ending of K v K+Q say. Sargon 1978 has no chess knowledge and shrinking the box around the king with your queen (or rook) to force mate is chess knowledge. It's not winning material or controlling extra squares through this phase so Sargon 1978 has no reason to do it (to shrink the box). It will only mate you if the mate is available in the next handful of moves. This is one of the reasons I'd like to implement the transposition tables code exo-skeleton I was talking about earlier, to bring the eventual mate into Sargon 1978's view.
Chessqueen
Posts: 5588
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

Bill Forster wrote: Wed Jan 20, 2021 11:40 pm Oh and incidentally, if you for some reason care about your results against Sargon 1978 never resign. Go for an ending of K v K+Q say. Sargon 1978 has no chess knowledge and shrinking the box around the king with your queen (or rook) to force mate is chess knowledge. It's not winning material or controlling extra squares through this phase so Sargon 1978 has no reason to do it (to shrink the box). It will only mate you if the mate is available in the next handful of moves. This is one of the reasons I'd like to implement the transposition tables code exo-skeleton I was talking about earlier, to bring the eventual mate into Sargon 1978's view.
In general there are (at least) two ways for weak players to beat Sargon;
1) Don't do anything, be patient, swap at every opportunity, wait for the endgame.
2) Build a massive attack, sacrificing if necessary, Sargon won't see deep enough to understand the point.

You are correct Mr. Forster, when I played those 20 games versus Sargon and Sargon 1978 BETA, I used your first technique which is to be patient even if I was losing by 1 pawn or if Sargon got the best of me in the middlegame using its tactics, and most of the time I waited for the endgame to beat it. Mr. Forster, Can you write a small subroutine with endgame knowledge :?: https://levelup.gitconnected.com/build- ... fb23bb3ec1
Who is 17 years old GM Gukesh 2nd at the Candidate in Toronto?
https://indianexpress.com/article/sport ... t-9281394/