![]() |
Forum Index : Microcontroller and PC projects : CMM2: TSCP Chess
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4912 |
Hi Kevin, Thank you . I already fixed the manual player entry not showing up in the score card, I think this weekend I will combine that with your fixes. Is your version robust against 2040 and 2350 versions from Peter ? Thank you for helping. I did not have much progress further since most of my time went into testing the new 6.00.0x releases. Regards, Harm Edited 2024-11-28 01:19 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10089 |
For those with a CMM2, a cmm2/RP2350/Harm's code/my code combo could work like this with a bit of effort https://youtu.be/Wc4nA636k4M Question for Harm: does your code support on-passant? This was the only bit I hadn't worked out. What is an example move sequence for en-passant Edited 2024-11-28 02:06 by matherp |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 596 |
Hi Harm, I have only tested on a 2040 talking to a 2040, I'm a bit 2350 light. I am using Peters latest TSCP executable on one, with the larger 'book' from a few posts earlier, & V6.00RC17 on the other. Regards Kevin |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4006 |
Any pawn making its first move, attempting to go 2 spaces and passing an enemy pawn if it does so, i.e. attempting to jump over a square being covered by (attacked by) an enemy pawn. Can then be taken "en passant", i.e. as if it had only moved forward one place. The other player has the option to take, it's not a forced take. John Edited 2024-11-28 05:37 by JohnS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10089 |
I understand the concept but what is the notation for the en-passant capture sequence say D2D4 then what? |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4006 |
Just as if it moved one space and was taken, so such as ... d5 (meaning black pawn from d7 to d5) exd6 (in effect meaning that the pawn didn't actually get to d5) Append ep (or e.p.) if you like. (If not taken the pawn would just be on d5.) John Edited 2024-11-28 06:17 by JohnS |
||||
EDNEDN Senior Member ![]() Joined: 18/02/2023 Location: United StatesPosts: 128 |
And... It is only possible to capture a pawn en-passant on the very next move following the 2 square move by the pawn. If the opposing player does not capture it immediately, he loses the right to capture it en-passant. |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 596 |
Hi Peter, I don't know the actual answer to your question & I have failed to be able to reproduce it using TSCP, (though I have just found some short opening sequences, which may be in the 'book' so in theory reproducible) I suspect it would go something like this. D2D4 E4D3 and the pawn, which was on square D4 would disappear (taken). But this would all be handled by TSCP, though Harm may have some move validity checking in the client. I suspect the only sure way of knowing is to get it to make such a move, I did try looking on the TSCP Community pages, but with a quick look couldn't find how it was done, which it must be capable of, as Tom K. states it obeys all the rules of chess. But what the actual syntax is I'm only guessing. Regards Kevin. Edited 2024-11-28 09:13 by Bleep |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4912 |
Peter, I have no idea how it is done (notation). But I did notice in playing with a terminal that the typical 4 character codes (i.e. D2D4) sometimes need an extension with a 5'th character before TSCP makes the correct move. I noticed this in an end game where the king would only move when I added a K after the 2 characters. Such as c3c4K. There are a few moves in Chess that may require special commands - casteling - en passant capture When the computer has to decide wether to caputure en passant, it is clear, but how does the player decide to capture yes-no ? Not enough experience on my side. Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10089 |
I've checked the source and can't see anything. The only 5th character is promotion and the code supports Nn, Rr, Bb or anything else = queen. It look like it is just the diagonal pawn move that signals en-passant and you can only make that diagonal move if you are taking the piece |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10089 |
Demo of the new png functionality on the RP2350 https://youtu.be/9PPSGVvt8xQ Pieces.zip Option explicit Option default integer Option console serial CLS Dim trans%=9,cutoff%=20 Sprite set transparent 9 drawboard Const a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8 Const movedistance=2 Const whiteking= 1 Const whitequeen= 2 Const whiterook= 3 Const whiterook2= 4 Const whitebishop= 5 Const whitebishop2= 6 Const whiteknight= 7 Const whiteknight2= 8 Const whitepawn= 9 Const whitepawn2= 10 Const whitepawn3= 11 Const whitepawn4= 12 Const whitepawn5= 13 Const whitepawn6= 14 Const whitepawn7= 15 Const whitepawn8= 16 Const blackking= 21 Const blackqueen= 22 Const blackrook= 23 Const blackrook2= 24 Const blackbishop= 25 Const blackbishop2= 26 Const blackknight= 27 Const blackknight2= 28 Const blackpawn= 29 Const blackpawn2= 30 Const blackpawn3= 31 Const blackpawn4= 32 Const blackpawn5= 33 Const blackpawn6= 34 Const blackpawn7= 35 Const blackpawn8= 36 Data whiterook,whiteknight,whitebishop,whitequeen,whiteking,whitebishop2,whiteknight2,whiterook2 Data whitepawn,whitepawn2,whitepawn3,whitepawn4,whitepawn5,whitepawn6,whitepawn7,whitepawn8 Data 0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0 Data blackpawn,blackpawn2,blackpawn3,blackpawn4,blackpawn5,blackpawn6,blackpawn7,blackpawn8 Data blackrook,blackknight,blackbishop,blackqueen,blackking,blackbishop2,blackknight2,blackrook2 Dim board(8,8) Dim x,y For y=1 To 8 For x=1 To 8 Read board(x,y) Next x Next y Const leftedge=(MM.HRes-MM.VRes)/2,square=48 'Load jpg "fpgJx",100,0 Sprite loadpng whitequeen,"whitequeen48",trans%,cutoff% Sprite loadpng whiteking,"whiteking48",trans%,cutoff% Sprite loadpng whitebishop,"whitebishop48",trans%,cutoff% Sprite copy whitebishop,whitebishop2,1 Sprite loadpng whiterook,"whiterook48",trans%,cutoff% Sprite copy whiterook, whiterook2,1 Sprite loadpng whiteknight,"whiteknight48",trans%,cutoff% Sprite copy whiteknight,whiteknight2,1 Sprite loadpng whitepawn,"whitepawn48",trans%,cutoff% Sprite copy whitepawn, whitepawn2,7 Sprite loadpng blackqueen,"blackqueen48",trans%,cutoff% Sprite loadpng blackking,"blackking48",trans%,cutoff% Sprite loadpng blackbishop,"blackbishop48",trans%,cutoff% Sprite copy blackbishop,blackbishop2,1 Sprite loadpng blackrook,"blackrook48",trans%,cutoff% Sprite copy blackrook,blackrook2,1 Sprite loadpng blackknight,"blackknight48",trans%,cutoff% Sprite copy blackknight,blackknight2,1 Sprite loadpng blackpawn,"blackpawn48",trans%,cutoff% Sprite copy blackpawn,blackpawn2,7 For y=1 To 8 For x=1 To 8 If board(x,y) Then place board(x,y),x,y Next x Next y movepiece e,2,e,4 movepiece c,7,c,5 movepiece g,1,f,3 movepiece d,7,d,6 movepiece d,2,d,4 movepiece c,5,d,4 movepiece f,3,d,4 movepiece g,8,f,6 movepiece b,1,c,3 movepiece b,8,c,6 movepiece c,1,g,5 movepiece e,7,e,6 movepiece d,1,d,2 movepiece a,7,a,6 movepiece e,1,c,1 movepiece h,7,h,6 movepiece g,5,f,6 movepiece d,8,f,6 movepiece f,1,c,4 movepiece f,8,e,7 movepiece d,4,c,6 movepiece b,7,c,6 movepiece f,2,f,4 movepiece e,8,g,8 movepiece c,4,d,3 movepiece c,8,b,7 movepiece d,3,c,4 movepiece b,7,c,8 movepiece d,2,d,3 End ' Sub movepiece(x1,y1,x2,y2) If board(x1,y1)=0 Then Exit Sub Local w=sprite(W,board(x1,y1)) Local xold=(x1-1)*square+leftedge+square\2-w\2 Local yold=(8-y1)*square-3 Local xnew=(x2-1)*square+leftedge+square\2-w\2 Local ynew=(8-y2)*square-3 Local float angle=Deg(Atan2(yold-ynew,xold-xnew))-90 vector 0,angle,0,xold,yold Local float distancetomove=Sqr((xold-xnew)^2 + (yold-ynew)^2) Do While distancetomove>movedistance vector 0,angle,movedistance,xold,yold If board(x2,y2)<>0 And distancetomove<square Then Sprite hide board(x2,y2) board(x2,y2)=0 EndIf FRAMEBUFFER wait Sprite show board(x1,y1),xold,yold,1 distancetomove=distancetomove-movedistance Loop If Abs(x1-x2)=2 And (board(x1,y1)=blackking Or board(x1,y1)=whiteking) Then 'castle If x2=c Then movepiece a,y1,d,y1 If x2=g Then movepiece h,y1,f,y1 EndIf board(x2,y2)=board(x1,y1) board(x1,y1)=0 place board(x2,y2),x2,y2 FRAMEBUFFER wait End Sub ' Sub place(n,x,y) Local w=sprite(W,n) Local xoff=(x-1)*square+leftedge+square\2-w\2 Local yoff=(8-y)*square-3 Sprite show n,xoff,yoff,1 End Sub ' Sub vector(obj As integer, angle As float, distance As float, x_new As integer, y_new As integer) Static float y_move(9), x_move(9) Static float x_last(9), y_last(9) Static float last_angle(9)=(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1) If distance=0 Then x_last(obj)=x_new y_last(obj)=y_new EndIf If angle<>last_angle(obj) Then y_move(obj)=-Cos(Rad(angle)) x_move(obj)=Sin(Rad(angle)) last_angle(obj)=angle EndIf x_last(obj) = x_last(obj) + distance * x_move(obj) y_last(obj) = y_last(obj) + distance * y_move(obj) x_new=Cint(x_last(obj)) y_new=Cint(y_last(obj)) End Sub Sub drawboard MODE 3 Map(14)=&HCFB095 Map(13)=&H7B3F00 Map set Local x%,y% Local left%=(MM.HRes-MM.VRes)/2 Local h%=MM.VRes\8 For x%=left%+h% To left%+h%*8-1 Step h%*2 For y%=0 To left%+h%*8-1 Step h%*2 Box x%,y%,h%,h%,0,Map(14),Map(14) Next y% Next x% For x%=left% To left%+h%*8-1 Step h%*2 For y%=h% To left%+h%*8-1 Step h%*2 Box x%,y%,h%,h%,0,Map(14),Map(14) Next y% Next x% For x%=left%+h% To left%+h%*8-1 Step h%*2 For y%=h% To left%+h%*8-1 Step h%*2 Box x%,y%,h%,h%,0,Map(13),Map(13) Next y% Next x% For x%=left% To left%+h%*8-1 Step h%*2 For y%=0 To left%+h%*8-1 Step h%*2 Box x%,y%,h%,h%,0,Map(13),Map(13) Next y% Next x% End Sub |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 596 |
Hi Harm, If you don't have any objections, I was going to have a further look at the chess client? Did you do any updates since I sent you my changes? If so could you zip up your latest client. Thanks Kevin. |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4912 |
Please go ahead. My effort went into testing pico No furter changes. PicomiteVGA PETSCII ROBOTS |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 596 |
Hi Harm, Attached are my efforts, I think it is all working, there is a problem with the 'bench' tscp chashes with "*** PANIC ***" "missing double function" so I have disabled that command. Otherwise I have tried to keep is roughly the same as yours, in look and layout. my file is called "chesskm.bas" and should be a drop in replacement for your V09, except for the Com port pins, which I'm sure you can work out. ;-) 2024-11-14_222213_chess2pico_v09.zip ![]() ![]() ![]() ![]() Regards, Kevin. |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4912 |
Hi Kevin, Have you removed the "auto play" function where TCSP plays against itself ? Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10089 |
I've tested bench on both rp2040 and rp2350 (genuine PICOs) and it works fine. The error you see will only arise on RP2040 with the very oldest b0 stepping. These chips are superseded so any boards that exhibit this are probably best for the bin #if !(PICO_DOUBLE_SUPPORT_ROM_V1 && PICO_RP2040_B0_SUPPORTED) static __attribute__((noreturn)) void missing_double_func_shim(void) { panic("missing double function"); } #endif I attach the latest binaries in case you are using an old version Chess.zip |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 596 |
Hi Peter, Yes I suspect that my Pico is positively Neolithic, I'm a bit of a Ludite, I don't like throwing away perfecly functional stuff, though if I was a Ludite, I'd still be using an Abacus and typewriter! I did't realise there were any hardware changes to the 2040, which would produce such an error? Thanks for the updated binaries, I was using the latest already, I'll just refrain from using the bench command, which I have re-instated in the client, below. Thanks for all of your work. Regards, Kevin. |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 596 |
Hi Harm, The auto play is still there, just set reply=1 in the code, though I have produced a new version, below, which has "auto" included, I've also put the "bench" back as well as it appears it's my ancient Pico causing the problem. Let me know how it goes. Regards, Kevin. chess2pico.zip |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10089 |
chesskm has a bug in that there is a subroutine board and a variable board$. With this fixed it runs on a RP2350 and both auto and bench work fine Edited 2025-01-07 23:13 by matherp |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 596 |
Hi Peter, Thanks for that, I'll correct it, interesting that that bug does not show up on the older 2040, I'm using 2040 for both client and server currently. There were a couple of other minor tweaks that I've included, so I'll do another zip later. Regards Kevin. |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |