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: Thu Jan 21, 2021 2:04 am Can you write a small subroutine with endgame knowledge[/b] :?: https://levelup.gitconnected.com/build- ... fb23bb3ec1
There's no need to rely on such ugly brute force memory methods (basically tablebases) for forcing mate with R and K say. My TarraschToyEngine for example has no trouble forcing such mates, I just gave it a little bit of chess knowledge - use the rook to limit the opponent's king to a portion of the board, put your king a knights move away, then force it back further. Once it gets to the edge of the board mate looms up close enough for even the shallow search of a weak engine.

But it would be pointless injecting either type of code into Sargon 1978. It wouldn't be Sargon 1978 anymore. On the other hand introducing transposition tables as a code exo-skeleton would effectively just enable Sargon 1978 to run faster in the endgame (I hope anyway) and calculate all the way to mate. It would be an authentic approach sympathetic to the project as a whole.

But we are going around in circles, and it's no doubt very boring to other people on the forum. I think we should stop.

I'll post again if I do in fact try and do it, I don't know if I can justify putting more weeks of effort into Sargon 1978. I still need to get V1.01 properly released (basically add some timing code to get a better measurement of how much faster Sargon 1978 runs on modern machines).
Chessqueen
Posts: 5582
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: Thu Jan 21, 2021 3:00 am
Chessqueen wrote: Thu Jan 21, 2021 2:04 am Can you write a small subroutine with endgame knowledge[/b] :?: https://levelup.gitconnected.com/build- ... fb23bb3ec1
You do NOT have to work any harder on this project, Sargon Beta is still a great program as it is, and after you add some timing code Sargon will definitively reach an above 1600 ratings. but antway here is where it stand now. I am having a match against Casper rated 1575 by CCRL and so far the score is almost even , but of course it does NOT mean anything unless I run a 1000 games match :roll:

[pgn][Event "Computer chess game"]
[Date "2021.01.21"]
[Round "1"]
[White "Sargon-1978-V1.01Beta"]
[Black "Casper rated 1575"]
[Result "0-1"]
[BlackElo "1575"]
[ECO "A29"]
[Opening "English"]
[Time "09:17:01"]
[Variation "Four Knights, 4.g3 d5 5.cxd5 Nxd5 6.Bg2 Nb6 7.O-O Be7 8.a3"]
[WhiteElo "1600"]
[TimeControl "600+5"]
[Termination "normal"]
[PlyCount "82"]


1. c4 e5 2. Nc3 Nf6 3. Nf3 Nc6 4. g3 d5 5. cxd5 Nxd5 6. Bg2 Nb6 7. O-O Be7
8. a3 O-O 9. d3 Bg4 10. Bd2 f5 11. Qb3+ Rf7 12. Be3 Qf8 13. h3 Bxf3 14.
Bxf3 Bc5 15. Bxc6 bxc6 16. Kg2 Bd4 17. Qe6 c5 18. Qb3 Nd7 19. Qe6 Rb8 20.
Rfb1 Rxb2 21. Bxd4 Rxb1 22. Rxb1 cxd4 23. Nd5 Qa8 24. f3 Qd8 25. f4 Qa8 26.
Kf2 exf4 27. Nxc7 fxg3+ 28. Kxg3 Qd8 29. Nb5 Qg5+ 30. Kf2 Qh4+ 31. Kg2 Qg5+
32. Kf3 f4 33. Kf2 Nc5 34. Qc8+ Rf8 35. Qc6 Qg3+ 36. Kf1 f3 37. Qd5+ Kh8
38. exf3 Nxd3 39. Qxd4 Rxf3+ 40. Ke2 Qg2+ 41. Kd1 Rf1# 0-1[/pgn]
Last edited by Chessqueen on Thu Jan 21, 2021 5:04 pm, edited 1 time in total.
Do NOT worry and be happy, we all live a short life :roll:
Chessqueen
Posts: 5582
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

[pgn][Event "Computer chess game"]
[Date "2021.01.21"]
[Round "2"]
[White "Sargon-1978-V1.01Beta"]
[Black "Casper rated 1575"]
[Result "1/2-1/2"]
[BlackElo "1575"]
[ECO "B12"]
[Opening "Caro-Kann"]
[Time "08:21:18"]
[Variation "Advance, 4.Nf3 e6 5.Be2"]
[WhiteElo "1600"]
[TimeControl "900+5"]
[Termination "normal"]
[PlyCount "107"]


1. e4 c6 2. d4 d5 3. e5 Bf5 4. Nf3 e6 5. Be2 Ne7 6. O-O Nd7 7. c3 h6 8.
Nbd2 g5 9. Qb3 Qc8 10. c4 c5 11. h3 cxd4 12. g4 Bh7 13. Nxd4 Nxe5 14. f4
gxf4 15. Rxf4 Bg7 16. cxd5 Nxd5 17. Rf2 Bf6 18. Nf1 a6 19. Bxh6 Be4 20. Nd2
Bg6 21. g5 Nd7 22. Nc4 Qc5 23. Nf3 Nf4 24. Bf1 Be4 25. Ncd2 Bd5 26. Qa4 Qc7
27. Ne4 Be7 28. Rc2 Qb6+ 29. Kh2 Bc6 30. Nf6+ Bxf6 31. Qxf4 Bxb2 32. Rb1
Be5 33. Qxe5 Nxe5 34. Rxb6 Nxf3+ 35. Kg3 Nd4 36. Rc3 O-O-O 37. Bd3 e5 38.
Bg7 Rhg8 39. Bf6 Rd6 40. Kf2 Re8 41. Rb1 Rd5 42. Rbc1 Kc7 43. a3 Rd7 44.
Be4 Kb8 45. Bxc6 Nxc6 46. Rb1 Kc7 47. Re1 Rd2+ 48. Ke3 Rh2 49. Ke4 Rd2 50.
Rb1 Kc8 51. Rbb3 Kc7 52. Rb1 Rd4+ 53. Kf3 Rd2 54. Ke4 {3-fold repetition}
1/2-1/2[/pgn]
Do NOT worry and be happy, we all live a short life :roll:
Chessqueen
Posts: 5582
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

Here is the last game where Casper showed Sargon the importance of knowing how to play the opposition.
Anyway the final score was 4 win 3 lost 3 draw in favor of Casper where most of the wins by Casper was due to having
more chess endgame knowledge than Sargon Beta


[pgn][Event "Computer chess game"]
[Date "2021.01.21"]
[Round "10"]
[White "Casper rated 1575"]
[Black "Sargon-1978-V1.01Beta"]
[Result "1-0"]
[BlackElo "1560"]
[ECO "D43"]
[Opening "Semi-Slav"]
[Time "15:48:36"]
[Variation "Moscow, Hastings Variation"]
[WhiteElo "1575"]
[TimeContro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f6 84. Rg1 Rf5 85. Re1+ Kf6 86.
Rd1 Kf7 87. Ke4 Rf6 88. Rd7+ Ke8 89. Rh7 Rf7 90. Rxf7 Kxf7 91. Ke5 Ke7 92.
f5 Kf7 93. f6 Ke8 94. Ke6 Kf8 95. f7 Kg7 96. Ke7 Kg6 97. f8=Q Kg5 98. Qf3
Kg6 99. Qg4+ Kh7 100. Kf6 Kh6 101. Qg6# *[/pgn]
Do NOT worry and be happy, we all live a short life :roll:
Chessqueen
Posts: 5582
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

Mr. Bill Forster even a Master level program without EGTB does NOT know how to use the opposition principle. This position was taken from the previous game of Sargon 1978 Beta playing the Black side posted here from move 81 ...Rg7. Sorry but 81...Rh7 should NOT change the outcome either, and any program rated above 1600 with this basic pawn opposition endgame knowledge should hold any top level engine . If you remove the Roos from both sides this position is a basic pawn opposition endgame.

[pgn][Event "Computer chess game"]
[Date "2021.01.23"]
[Round "1"]
[White "RubiChess-1.9"]
[Black "Bikjump"]
[Result "1-0"]
[BlackElo "2120"]
[Time "13:21:39"]
[WhiteElo "3294"]
[TimeControl "600+3"]
[SetUp "1"]
[FEN "5r2/7R/2k5/8/5P2/4K3/8/8 b - - 0 1"]
[Termination "normal"]
[PlyCount "143"]


1. ... Kd6 2. Ke4 Re8+ 3. Kf5 Re1 4. Kg5 Rg1+ 5. Kf6 Rf1 6. f5 Re1 7. Kg6
Re2 8. f6 Rf2 9. Ra7 Ke6 10. Ra6+ Ke5 11. Kg7 Rg2+ 12. Kf8 Rf2 13. f7 Kd4
14. Re6 Rb2 15. Re7 Kd5 16. Re8 Kc4 17. Ke7 Re2+ 18. Kd7 Rd2+ 19. Kc7 Rf2
20. f8=Q Rxf8 21. Rxf8 Kd4 22. Kd6 Ke4 {Black resigns} *[/pgn]
Do NOT worry and be happy, we all live a short life :roll:
Chessqueen
Posts: 5582
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.
I believe that Sargon 1978 should be left as is was and any changes such as making it faster or to search deeper, and to give
it more chess knowledge is fine and great idea, but the name should be changed to Sargon 2021 :roll:
Do NOT worry and be happy, we all live a short life :roll:
tmokonen
Posts: 1296
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: Sargon 1978 UCI Available

Post by tmokonen »

I wonder if Dan and Kathe are aware of how much interest people still have in their old program. It would be cool to see the source of a later version, though who knows if they would even have the rights to that. I had a lot of fun playing Sargon II on the VIC-20.
Chessqueen
Posts: 5582
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

tmokonen wrote: Wed Jan 27, 2021 2:30 am I wonder if Dan and Kathe are aware of how much interest people still have in their old program. It would be cool to see the source of a later version, though who knows if they would even have the rights to that. I had a lot of fun playing Sargon II on the VIC-20.
I wanted to find out what Percentile of Chess players fall between 1450 to 1550 in the World rated similar to Sargon 1978, and it surprised me to find out that 14.54% percent of the World chess players or close to 40,000 players are among this range, which could be satisfied by playing against Sargon 1978, and I would say that at least 50 % of the people who post here on this forum fall under this category :roll:
Do NOT worry and be happy, we all live a short life :roll:
Chessqueen
Posts: 5582
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Sargon 1978 UCI Available

Post by Chessqueen »

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).
I also realized by watching this game between two similar rated engines that when there is only one move, Sargon took 2 minutes to take back the Queen 26. Kxe2. Sargon should be given instructions that when there is only one legal move to execute it immediately and this will save Sargon time for future use. I immediately stopped watching this game since I felt like watching two 7 years old Kids who learned a year or two how to play Chess.

[pgn][Event "Computer chess game"]
[Site "DESKTOP-OFQ3C0P"]
[Date "2021.01.28"]
[Round "?"]
[White "Sargon Depth7 "]
[Black "TarraschToyEngineV0.906 "]
[Result "*"]
[BlackElo "1480"]
[ECO "B00"]
[Opening "Nimzowitsch Defence"]
[Time "08:56:17"]
[Variation "Bogoljubow, 3...Nf6"]
[WhiteElo "1480"]
[TimeControl "900+5"]
[Termination "unterminated"]
[PlyCount "63"]


1. d4 d5 2. Nc3 Nc6 3. e4 Nf6 4. exd5 Nxd5 5. Nf3 Be6 6. Bb5 Nxc3 7. bxc3
Qd5 8. Qe2 a6 9. c4 Qf5 10. Bxc6+ bxc6 11. Ne5 Bd7 12. Be3 g6 13. g4 Qe6
14. f4 f6 15. Nxd7 Kxd7 16. O-O h5 17. f5 gxf5 18. gxf5 Qe4 19. Rf3 Rg8+
20. Kf1 e6 21. fxe6+ Qxe6 22. Rb1 Bd6 23. Rb3 a5 24. c5 Be7 25. Bf2 Qxe2+[/pgn]
Do NOT worry and be happy, we all live a short life :roll:
Chessqueen
Posts: 5582
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 Jun 03, 2020 2:20 am
Tibono wrote: Tue Jun 02, 2020 4:14 pm

Finally, I tried out the Jupiter emulation you linked to. I played quick a FixedDepth=4 game against Sargon with my Tarrasch GUI (below - Sargon almost demonstrates that my previous assertion that it could never beat me is wrong), then tried to reproduce with the Jupiter Emulator. Everything seems great for a while. As expected the emulator is about one order of magnitude slower than the native code (10 secs v 1 sec at level 4, approx). But sadly, the emulator (reliably/repeatedly) crashes after 14. g3, failing to produce 14... O-O-O. The provenance of the Jupiter code is the same as my code, I used Andre Adrian's transcription as one of my inputs. I might see if I can check my Git logs to see if there's a fix I made somewhere that could account for this.

[pgn]
[Event "Test game, Sargon FixedDepth=4"]
[Site "?"]
[Date "2020.06.03"]
[Round "?"]
[White "Bill"]
[Black "Sargon 1978 V1.00"]
[Result "1-0"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 Nf6 4. O-O Nxe4 5. d4 Nxd4 6. Nxd4 exd4 7. Re1 f5 8.
f3 c6 9. Bf1 d5 10. fxe4 dxe4 11. c3 Be6 12. Qxd4 Qxd4+ 13. cxd4 Bd6 14. g3
O-O-O 15. Be3 Kc7 16. Nc3 Rhf8 17. Rac1 f4 18. Nb5+ Kb6 19. Nxd6 fxe3 20. Nxe4
Rxd4 21. Rxe3 Bxa2 22. Bg2 h6 23. Rce1 Bc4 24. Nc3 Rd2 25. b4 Rd4 26. Rd1 Rxd1+
27. Nxd1 Rd8 28. Nb2 Kb5 29. Nxc4 Kxc4 30. Re7 Rd1+ 31. Kf2 Rd2+ 32. Kf3 g5 33.
Rxb7 g4+ 34. Kxg4 Rxg2 35. h4 Ra2 36. Rh7 Kxb4 37. Rxh6 Ra4 38. Rf6 Kc5+ 39.
Kg5 Ra2 40. h5 Rd2 41. h6 Rd5+ 42. Kg6 Rd6 43. Rxd6 Kxd6 44. h7 Kc7 45. h8=Q a6
46. Qa1 Kb6 47. Kf6 a5 48. g4 Kb5 49. g5 a4 50. g6 Kb4 51. g7 a3 52. g8=Q c5
53. Qga2 c4 54. Qxa3+ Kb5 55. Qe5+ Kc6 56. Qa6+ Kd7 57. Qe7# 1-0
[/pgn]
Hi Bill I was wondering if you can post a game at time control of 120 Minutes using a fixed depth of 7, I would lije to know how many moves Sargon FixedDepth=7 can survive against you, I will also try it and post it here later on. :?: :roll:
Do NOT worry and be happy, we all live a short life :roll: