|
Post by xxgeek on Feb 2, 2021 1:06:40 GMT
have them tremble a little ;-)) (just going too far with this idea). Oh man you had me laughing with "have them tremble" Maybe have sweat pouring off them as well ......lol Thanks for the morning laugh B+
|
|
|
Post by tsh73 on Feb 2, 2021 10:07:26 GMT
I just win it - and it hide my piece then checkmated But I cannot undo after checkmate And adter restart, *.und files seems to be cleared (may be it wasn't but got after I reloaded them) so I cannot show it to you.
Really, this ask for save/load/replay moves list.
But I'm busy adding saving your format to my 2d board (I did added compose mode to it already, but it saves in it's own format) I'm almost there... It just labels board backwards ;) I will update program and post here then I done.
|
|
|
Post by Rod on Feb 2, 2021 10:25:58 GMT
Yes printing to a graphicbox looks nice but isn't all that useful. I blame B+ for the undo, he got me to fix it! I will fix any bugs we find but what I am going to do next is to hack out the engine and try and make it stand alone. I also want to explore passing in a string rather than the array(level,x) technique. Passing in an string would mean I did not need to reverse play on the way back down the recursion.
At least we are all coding again!
|
|
|
Post by B+ on Feb 2, 2021 13:24:38 GMT
Yes, I've won several times last night and here is a normal checkmate (attached) and a resign (attached) even though NOT checkmated but soon to be after I figured out the 2 or 3 moves I had to make to do it, it knew before I and didn't make me play it out. Can you figure it out? It's around 3 moves out. No wait... he could block with Black Bishop and I (Black) would be stuck! Wait no, he moves only place he can, I move Q to only Black protected by my Black Bishop, King moves back to white square and checkmate from my Bishop on white squares. I would definitely make my opponent play it out from that screen shot position because the opponent could easily screw up and lose. Then there were a couple of checkmates where either my piece right next to the King or the King have been removed AFTER the message it has resigned. I think what is happening is that while checking moves it finally decides it's checkmate and message's that decision but does not put the pieces back just exits out of whatever branch of recursion it's in at message time. I think if you save the state of board and decide checkmate return the board to that state when deliver the checkmate message would fix the final view of the board. Attachments:
|
|
|
Post by tsh73 on Feb 2, 2021 14:05:56 GMT
If you load a Black game the computer plays White and will 'take the first move.
There is a problem then playing for black. I load black - it makes first move - I play for a while On my (black) move I save Then I load it make white move!
|
|
|
Post by Rod on Feb 2, 2021 14:33:27 GMT
Thanks, this is the fix for load game.
'see below
I should not have jumped out the sub, basically sit still till the player makes a move. So a change to the if AI=Black line
|
|
|
Post by Rod on Feb 2, 2021 14:40:19 GMT
I can see a bit of the ending bug. I can see that the code writes the log with the last pointless play before admitting its checkmate. BUT, it should not make any sprite disappear because it stops and waits. In B+ first game the log records the knights last pointless move. But it does not show it because showboard is never called. So I am puzzled why checkmate (flawed as it is) makes the queen disappear. More research needed.
I have to make the move for the incheck() function to know whether we are still in check. reversing it seems pointless if the game ends.
Edit : however looking at the second game I see that the white queen made a pointless capture of a black pawn that has disappeared. So if the last pointless move captures a piece it is removed by makemove()
Getting a bit closer, not sure how easy solution will be!
|
|
|
Post by B+ on Feb 2, 2021 15:11:49 GMT
Hmm... I haven't been watching the list of moves but something is off, 2nd screen shot, the White Q took pawn and is as shown, then Black Queen made the last move as shown, it seems to be listed in reverse. Are you always showing W B, W B sequence as if the two moves are on same line.
Oh it would be easier to list them going down, last moves at bottom of list.
The 2 screen shots I showed the final scene was undisturbed all pieces right where they were when Black made last move.
The screen shots not shown were disturbed with a piece removed when Checkmate message appears.
|
|
|
Post by Rod on Feb 2, 2021 15:50:09 GMT
Ok, tsh73 kinda hinted about this solution a while back. Now what I do is make the computer move on a temporary basis then see if we are still in check and so checkmate. It reverses the temporary move and plays on. So I am hoping nothing should disappear now and the message log will not list moves you can't see.
sub actioncomputermove result
'the results of evaluate are held in best() x=bestx(1) y=besty(1) x1=bestx1(1) y1=besty1(1)
'remove highlights of human players last move #w.g "spritevisible m off" if bsprite$(old(1),old(2))<>"" then #w.g "spriteimage ";bsprite$(old(1),old(2));" ";left$(bsprite$(old(1),old(2)),2)
'action computer move, take opponent, remove opponent, promote if at edge of board
'the computer will always return a move even if it is pointless 'so we need to see if the move avoids check 'store mover and target data so that it may be restored moversprite$=bsprite$(x,y) movervalue=bvalue(x,y) moverpiece=bpiece(x,y) moversign=bsign(x,y) targetsprite$=bsprite$(x1,y1) targetvalue=bvalue(x1,y1) targetpiece=bpiece(x1,y1) targetsign=bsign(x1,y1)
'fill square taken bsprite$(x1,y1)=bsprite$(x,y) bvalue(x1,y1)=bvalue(x,y) bpiece(x1,y1)=bpiece(x,y) bsign(x1,y1)=bsign(x,y)
'erase square vacated bsprite$(x,y)="" bvalue(x,y)=0 bpiece(x,y)=32 bsign(x,y)=0
'now see if we are still in check and so checkmate checkmate=incheck(AI)
'reset play bsprite$(x,y)=moversprite$ bvalue(x,y)=movervalue bpiece(x,y)=moverpiece bsign(x,y)=moversign bsprite$(x1,y1)=targetsprite$ bvalue(x1,y1)=targetvalue bpiece(x1,y1)=targetpiece bsign(x1,y1)=targetsign
if checkmate then if AI=Black then t$="Black resigns " else t$="White resigns " call text "" call text "Checkmate!" call text t$ call text "Game ends" wait else if AI=Black then t$="Black moves " else t$="White moves " call text t$;chr$(bpiece(x,y));bsquare$(x,y);"-";chr$(bpiece(x1,y1));bsquare$(x1,y1) if bvalue(x1,y1)<>0 then taken=showtaken(x1,y1,AI) #w.g "spritevisible ";bsprite$(x1,y1);" off" Spritetaken$=Spritetaken$+bsprite$(x1,y1)+"," end if call makemove x,y,x1,y1 end if
'add highlights of computers last move if bsprite$(x1,y1)<>"" then #w.g "spriteimage ";bsprite$(x1,y1);" ";left$(bsprite$(x1,y1),2);"1" #w.g "spritexy t ";bspritex(x,y);" ";bspritey(x,y) #w.g "spritescale t ";bspritez(x,y) #w.g "spritetoback t" #w.g "spritevisible t on" old(3)=x1 old(4)=y1
'did we put the opposition in check? if AI=Black then t$="White in check " else t$="Black in check" if incheck(0-AI) then call text t$ call showboard end sub
|
|
|
Post by B+ on Feb 2, 2021 18:07:24 GMT
OK so far looking good with that change, 3 mates and no missing pieces.
|
|
|
Post by Rod on Feb 2, 2021 18:15:36 GMT
This is how clever the AI is. Normal white game. White's three moves : Pawn D2 to D4, Pawn E2 to E3, Queen D1 to H5, Checkmate in three moves!
|
|
|
Post by Rod on Feb 2, 2021 18:44:03 GMT
Ok this is the real fix for load game.
'player clicked load game if xx>5 and xx<105 and yy>35 and yy<60 then playwave "click.wav",async filedialog "Open Chess Game ", "*.gam", f$ if f$<>"" then call loadgame f$ call showboard call text "Game loaded" if instr(f$,"NewBlack.gam",1) then Status=2 : exit sub if AI=Black then t$="White to move " else t$="Black to move " call text t$ end if
|
|
|
Post by Rod on Feb 2, 2021 18:57:29 GMT
|
|
|
Post by tsh73 on Feb 2, 2021 19:47:34 GMT
|
|
|
Post by B+ on Feb 2, 2021 20:15:05 GMT
tsh73 I had magnetic chess set all through High School with pieces that looked like that, band practice and study halls, lunch... you'd think I would have gotten better ;-)) And neat to see that last game setup from White's perspective, reverse is good if only for that!
|
|