Sargon 1978 UCI Available

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

Moderators: hgm, Rebel, chrisw

Phillip Eaton
Posts: 5
Joined: Sun Apr 04, 2021 2:00 am
Full name: Phillip Eaton

Re: Sargon 1978 UCI Available

Post by Phillip Eaton »

Steady on, Bill, you make it sound like I knew what I was doing! To be clear, I did have a decent-looking (non-working) partial source and having compared it with the Sargon book, it was clear it was based on that. So, I just plugged away referencing between the raw disassembled code and the book and - eventually - using the recreated source code, I could fix the bug that was apparent on the SWTPC binary.

As you've mentioned somewhere in your previous text, it's a lot of groping around in the dark and just having faith in your will to succeed even though nothing is working at all, until suddenly everything fits into place and it's done.
Phillip Eaton
Posts: 5
Joined: Sun Apr 04, 2021 2:00 am
Full name: Phillip Eaton

Re: Sargon 1978 UCI Available

Post by Phillip Eaton »

"It indicates that the book the Spracklens published in 1978 did not just capture a random snapshot of work in progress, rather is was a well-defined milestone that they believed in enough to port unchanged to other microprocessors."

Honestly, I think my only 'discovery' is that the TRS-80 version seems to be the same code as the book. The 6809 version was, by the look of it, performed by someone who decided he liked a challenge and translated what was in the book to 6809 by himself, sometime later. I don't know if there was a Sargon 1978 for any other CPUs, maybe that came about with Sargon II?
Bill Forster
Posts: 76
Joined: Mon Sep 21, 2015 7:47 am
Location: New Zealand

Re: Sargon 1978 UCI Available

Post by Bill Forster »

Phillip Eaton wrote: Thu Apr 08, 2021 1:57 am "It indicates that the book the Spracklens published in 1978 did not just capture a random snapshot of work in progress, rather is was a well-defined milestone that they believed in enough to port unchanged to other microprocessors."

Honestly, I think my only 'discovery' is that the TRS-80 version seems to be the same code as the book. The 6809 version was, by the look of it, performed by someone who decided he liked a challenge and translated what was in the book to 6809 by himself, sometime later. I don't know if there was a Sargon 1978 for any other CPUs, maybe that came about with Sargon II?
Okay, fair enough I misinterpreted your situation. I assumed the 6809 version was a product, not a hobby project from a third party. I'm still impressed though :D
User avatar
AdminX
Posts: 6340
Joined: Mon Mar 13, 2006 2:34 pm
Location: Acworth, GA

Re: Sargon 1978 UCI Available

Post by AdminX »

Hello Bill,

I was wondering if this might be a bug. I noticed that when playing with black if white opens with 1.Nf3 Sargon v1.01 has responded 1.e5. This has happened twice now this morning playing some test games with Zeta 0.99m.

PS: LV 6

[pgn][Event "banksia game"]
[Date "2021.05.04"]
[White "Zeta 0.99m"]
[Black "Sargon V1.01"]
[Result "1-0"]
[TimeControl "40/300+1"]
[Time "11:20:23"]
[Termination "mate"]

1. Nf3 {+0.10/11 4117 41260299} e5 2. Nxe5 {+1.10/11 10467 30235350} Nc6 {+1.25/6 6514 198106}
3. Nxc6 {+1.32/12 8227 101641979} dxc6 {+0.50/6 4996 146437} 4. Nc3 {+1.30/11 3742 46244829} Be6 {+0.75/6 9270 269287}
5. d4 {+1.41/11 7238 90353598} Nf6 {+0.50/6 15967 460103} 6. e4 {+1.49/10 10290 23727737} Bb4 {+0.75/6 10331 296124}
7. Qd3 {+1.41/11 9956 126588721} Qd7 {+0.75/6 20450 572330} 8. f3 {+1.56/10 5438 68931409} O-O-O {+0.25/6 23374 655115}
9. Be3 {+1.57/10 4719 60788913} Ne8 {+0.25/6 25390 722487} 10. a3 {+1.96/10 4488 56700750} Bxc3+ {+0.25/6 5511 160162}
11. Qxc3 {+2.01/10 3073 38620237} Nf6 {+1.50/6 12844 376717} 12. Qa5 {+2.86/10 10427 133655056} a6 {+0.75/6 21097 625146}
13. Bxa6 {+3.10/11 9113 114902835} bxa6 {-0.25/6 10569 307715} 14. Qxa6+ {+3.70/10 3889 48453287} Kb8 {+2.25/6 8541 249314}
15. d5 {+3.64/10 5944 75007020} cxd5 {-1.75/3 59837 2527} 16. Qa7+ {+1000.03/3 40 192272} Kc8 {M-3/6 4777 137165
17. Qa8# {+1000.01/1 10 7736} 1-0[/pgn]

On a side note, I hope work on this project continues as there looks to be allot of potential.

[pgn][Event "banksia game"]
[Date "2021.05.04"]
[White "Sargon V1.01"]
[Black "Zeta 0.99m"]
[Result "1/2-1/2"]
[TimeControl "40/300+1"]
[Time "11:30:26"]
[Termination "repetition"]
[ECO "A45"]
[Opening "Queen's pawn game"]

1. d4 Nf6 {+0.04/11 4876 40146519; A45: Queen's pawn game} 2. Nc3 {+0.25/6 5140 159530} e6 {+0.08/11 3146 38724837}
3. Bg5 {+0.00/6 9722 286493} h6 {-0.05/11 4521 56787303} 4. Bxf6 {+0.75/6 4490 138190} Qxf6 {-0.01/12 7108 88994187}
5. Nf3 {+0.00/6 6763 197993} Nc6 {+0.01/11 7033 87843803} 6. Qd3 {+0.00/6 15056 454345} g5 {-0.20/10 6660 83486902}
7. Ne4 {+0.25/6 16757 496562} Qf5 {-0.49/11 8252 103819140} 8. Nc3 {-0.50/6 21891 662237} Qxd3 {-0.66/11 11834 35249877}
9. cxd3 {-0.25/6 4423 140953} g4 {-0.64/11 4624 59428080} 10. Ne5 {-0.75/6 3702 117585} Nxd4 {-1.14/11 4615 59009215}
11. O-O-O {-0.75/6 3501 105483} h5 {-1.00/11 4120 52757400} 12. e3 {-0.25/6 4194 131869} Nf5 {-1.09/11 3412 43840347}
13. d4 {-1.00/6 10147 315843} Bg7 {-1.22/11 6253 80347774} 14. Nb5 {-0.75/6 16757 515777} Bxe5 {-1.24/11 3730 48060921}
15. dxe5 {-0.75/6 3014 85614} Kd8 {-1.23/11 3749 47713820} 16. Bd3 {-0.75/6 6861 208046} Ne7 {-1.22/12 12918 162887856}
17. Kd2 {-1.25/6 8212 249477} Nc6 {-2.19/11 4161 52375173} 18. Rc1 {-1.25/6 7867 234913} a6 {-2.35/11 3759 46815206}
19. Nd4 {-1.75/6 7467 228499} Nxe5 {-2.37/11 5602 70869152} 20. h3 {-1.25/6 12863 400723} Nxd3 {-2.58/11 4583 59721625}
21. Kxd3 {-1.75/6 7014 217183} e5 {-2.59/11 5176 67774418} 22. Nf5 {-1.25/6 5608 168758} gxh3 {-2.78/11 4646 60225991}
23. gxh3 {-1.62/6 4993 156004} d5 {-2.77/11 4015 52159528} 24. e4 {-1.25/6 2463 77418} Bxf5 {-3.12/12 12639 165417438}
25. exf5 {-2.12/6 1425 45729} c6 {-3.06/12 11440 150189559} 26. Rhe1 {-2.12/6 2886 90295} f6 {-3.04/12 7804 101928316}
27. Rg1 {-2.25/6 2820 86485} Rb8 {-3.00/11 5529 71426785} 28. Rg7 {-1.25/6 4030 120871} Ke8 {-2.96/12 8812 114786775}
29. Rcg1 {-0.87/6 5376 167186} c5 {-2.21/11 9543 123090027} 30. Kc2 {-0.25/6 4957 150719} d4 {-1.91/12 13763 177154667}
31. R1g3 {-0.25/6 10062 313086} Rf8 {-2.18/11 17541 41056105} 32. Kd2 {-0.25/6 6268 198659} a5 {-2.18/11 16831 40215575}
33. a3 {-0.25/6 4601 141397} h4 {-1.83/12 7091 92706760} 34. R3g4 {-1.25/6 2351 72000} b5 {-0.73/12 9131 119463004}
35. Rxh4 {-1.62/6 4344 135326} c4 {-0.46/12 9269 121134209} 36. Rhh7 {-0.25/6 4301 131670} Rb6 {+0.00/12 13800 180664614}
37. Ra7 {+0.75/6 4473 140027} Rb8 {+0.00/12 14823 197458749} 38. Rhe7+ {+0.75/6 3713 112199} Kd8 {+0.00/11 5984 79679587}
39. Red7+ {+0.75/6 2421 73167} Ke8 {+0.00/12 24228 322738575} 40. Re7+ {+0.75/6 5494 74208} Kd8 {+0.00/63 61 10080}
41. Red7+ {+0.75/6 5623 73167} Ke8 {+0.00/12 6187 3840} 42. Re7+ {+0.75/6 5433 74208} 1/2-1/2[/pgn]
"Good decisions come from experience, and experience comes from bad decisions."
__________________________________________________________________
Ted Summers
Bill Forster
Posts: 76
Joined: Mon Sep 21, 2015 7:47 am
Location: New Zealand

Re: Sargon 1978 UCI Available

Post by Bill Forster »

AdminX wrote: Tue May 04, 2021 5:26 pm Hello Bill,

I was wondering if this might be a bug. I noticed that when playing with black if white opens with 1.Nf3 Sargon v1.01 has responded 1.e5. This has happened twice now this morning playing some test games with Zeta 0.99m.
(Sorry, I don't often look at the forum and just saw this)

This is indeed a bug, well spotted! Sargon 1978 has a very simple one move deep "book" comprising 1.e4 or 1.d4 (random choice) as White and either 1...d4 or 1...e5 as Black. It is supposed to play 1...e5 if White starts with an 'a', 'b', 'c' or 'e' pawn move (so 8 possible moves) and 1...d5 to the other 12 possible moves.

I had not paid sufficient attention to the Black 'book'. I had two test cases 1.d4 and 1.c4 which generated the right responses 1...d5 and 1...e5 respectively. It turns out that my code is correct only for the 8 initial double pawn advances. When the most recent move is a double pawn advance, I actually fabricate the previous position within Sargon 1978 and get Sargon 1978's logic to play the double pawn advance. That was the only way I could get en-passant to work properly. It turns out en-passant is not the only place in the Sargon 1978 code where the most recent move is important - the special case of the Black book move also relies on knowing the previous move played. I hadn't noticed that, and my test cases were insufficient to catch the problem because they both happened to be double pawn advances.

The solution will be to extend the en-passant "recreate the previous move" logic to all 20 possible positions where Sargon 1978 is supposed to play a Black book move. It is nice that FEN notation is sufficient to deduce the previous move every time Sargon needs it (either after a double pawn advance or on Black's first move from the initial position).

I should go ahead and do this because I was always going for a model project. (Naturally I have failed in various [small] ways, but this is perhaps the worst one I know about).
User avatar
towforce
Posts: 11572
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: Sargon 1978 UCI Available

Post by towforce »

This probably falls into the "asking for the moon" category - but Chrilly has translated Sargon into C#, and C# can be transpiled into JavaScript - so... how about... a web page version of Sargon?

:mrgreen:
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
User avatar
towforce
Posts: 11572
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: Sargon 1978 UCI Available

Post by towforce »

towforce wrote: Wed May 19, 2021 9:57 am This probably falls into the "asking for the moon" category - but Chrilly has translated Sargon into C#, and C# can be transpiled into JavaScript - so... how about... a web page version of Sargon?

:mrgreen:

Now I've read the whole thread, I think that transpiling/rewriting from the LUA version would be the fastest route to a JavaScript version for a Sargon web page.

Link to source from this thread: http://www.talkchess.com/forum3/viewtop ... 7&start=17

Sargon LUA move generation source: https://github.com/tosca07/Lua4chess/bl ... on_uci.lua
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
User avatar
towforce
Posts: 11572
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: Sargon 1978 UCI Available

Post by towforce »

Sargon in JavaScript already exists - and has done since 2012! Who knew!

Fun to play against: never seen a computer play this way before!

Two words: tactical pest!

https://chessforeva.gitlab.io/C0_JsSargon.htm
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
Phillip Eaton
Posts: 5
Joined: Sun Apr 04, 2021 2:00 am
Full name: Phillip Eaton

Re: Sargon 1978 UCI Available

Post by Phillip Eaton »

towforce wrote: Wed May 19, 2021 11:57 am Now I've read the whole thread, I think that transpiling/rewriting from the LUA version would be the fastest route to a JavaScript version for a Sargon web page.
I scripted the LUA version with the L2 test game from earlier in this thread and it plays different moves to the TRS-80 Sargon, which I believe is the same as the book. (Because my 6809 Sargon was a translation from the book and it plays the same as the TRS-80 version.)

I think the LUA version needs debugging.
mephisto
Posts: 430
Joined: Mon Apr 03, 2006 10:10 am
Location: England

Re: Sargon 1978 UCI Available

Post by mephisto »

This is what the creator of the JavaScript Sargon said and this is why it is not the same.

So, I've decided to find interesting things in this old assembler code and recreate some parts of it sort of modern way. Here is the result - jsSargon that runs in browser's canvas. Of course, it's kinda fake and nothing more.
What's my next move? - to the fridge for another beer !!