|
Post by Rod on Jan 21, 2021 19:31:56 GMT
I have changed the interface slightly and with tsh73's help I have made it play white or black. Now I would like to say it is bug free but it certainly wont be. One of my main problems is back and that is getting it to play out of check when it can. It appears just to give up as soon as it is in check. However there is a lot else to test. I have it set to maxlevel 3. That means it will play three moves ahead when valuing what move to play. You can make it smaller to speed play during debug. Making it play more moves ahead slows things down rapidly and given it has no hidden strategy it probably will not improve the gameplay much. If it cant find a good move in three plays it is unlikely the game will unfold as planned. Now the program will start with a new White game. You can load a new Black game if you wish. You can also save a game to come back to and undo will reverse the last move. I hope we have some chess players on the forum. Latest version is much faster than previously and also allows reversal mid game. Chess version v2.5 9th Feb 2021
|
|
|
Post by B+ on Jan 21, 2021 20:15:22 GMT
Rod, That's a really nice looking board!
|
|
|
Post by tsh73 on Jan 27, 2021 21:30:07 GMT
Playing with this.
Just found it allows to castle from under the check. It shouldn't.
Just found why it resigns on check. It should make his best move first, THEN if it still in check that means checkmate.
|
|
|
Post by Rod on Jan 27, 2021 21:47:39 GMT
Thanks, can fix castling easy enough. I had realised it needed to make the play and see if it was out of check but I was getting hung up on what move to show. It might be simpler than I was thinking.
|
|
|
Post by tsh73 on Jan 27, 2021 22:06:27 GMT
OOPS I realized I've been here before if I allow it to play best move King will eat up my Queen that checkmate him ;) So that's why now it resigns if checkmated. Alternative is to makeMove, see if still under check, if yes restore board and say checkmate.
But anyway it's better then resigning on the first check ;)
I was working with incheck() function - trying to mark moves that didn't move out of check as invalid - and found that it calls moveList - so if we call incheck() during FOR loop by moves, moves be spoiled (if we not set Level to say 0, just for check checking, and then restore back)
|
|
|
Post by B+ on Jan 27, 2021 22:17:20 GMT
Do you guys have pawn promotion to any piece worked out?
Not sure I want to get into this again but I recall getting that fixed up along with Castling with the same QB base sample program (according to Adrian) with about 500 LOC. That was a couple years ago when making a graphics interface to the program. As I recall it was the checks and no confession of checkmate when stuck that had us looking for other things to code. ;-))
|
|
|
Post by tsh73 on Jan 27, 2021 22:26:39 GMT
I see in code it always promotes to Q But I didn't played far enough for that ;)
|
|
|
Post by Rod on Jan 28, 2021 9:55:35 GMT
I changed the computer move sub. It seems to play out ok. One thing, it wont play out of check at lower maxlevels it needs to be set at two or more for it to start playing out of check.
Webs is down right now I will refresh the zip later.
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" #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 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
'are we still in check in which case checkmate! if incheck(AI) 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 end if
'add highlights of computers last move #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 Jan 28, 2021 18:43:40 GMT
I have recalled a little better the problem we could not overcome at the time.
The AI's King is in check say by a protected Queen, and it, the AI, insists on getting out of check by taking the Queen which was protected so basically a suicide move. Well we mortal humans just don't think that is kosher and the proper thing to do is find another way out of check (and there usually is) or admit checkmate. ;-))
|
|
|
Post by tsh73 on Jan 28, 2021 19:47:52 GMT
Don't see conceptual problem here.
Do a move - eat that darned queen - then test if you still under check. If it is then it means there are no way out, sorry Take that move back (visually) report CHECKMATE
|
|
|
Post by tsh73 on Jan 28, 2021 19:53:11 GMT
I really doubt "(and there usually is)". There are pieces cost, and cost of king is 5000 in this program. So AI really should try to keep his own king from taking - if it looks one move ahead, it will be taken by whatever piece protects the queen.
At least that's my thought.
Really we need way to store/replay games - to see if such things happen (and if happen, rewind to right turn and debug). and to share games and positions here.
|
|
|
Post by Rod on Jan 28, 2021 20:49:10 GMT
If there is a way out of check I see it doing so, it won't take the queen just because it is a high value. Moving left for zero value is much more worth than the loss it will see for taking the queen.
I had thought about a drag and drop game builder. There is a .gam file that is a simple text file that could be shared here. If you have a game position of interest you can do it now by pressing undo if needs be, then save game. Share the save.gam here.
I want a little break from it but I will think about a drag and drop gamebuilder.
Also be wary when testing, low values for maxlevel speed things up but completely change the behaviour.
|
|
|
Post by B+ on Jan 28, 2021 20:58:00 GMT
tsh73Your reply before sounds very sound, I am wondering why we didn't think of that 2 some years ago. I think it was difficulties of being in check, wasn't clear in code was there a Flag set or something? We did work out display and file storage of moves (for do overs or Undo Moves), it required a notation system we could agree on. Man this is bringing back memories I could zip you the QB64 code of what we came up with if interested. With you and or Rod looking in we might just get it going, oh Adrian might pop in then too? It'd be better if we were on the same code evolution and development page. I'm guessing you and or Rod came up with some significant helper sub(s)?
|
|
|
Post by tsh73 on Jan 28, 2021 22:25:24 GMT
funny thing first. I played it over midnight - then I found it stopped the clock! I thought it hang but no, it allow moves/made moves. But both clock stand still.
Now I look at code - no wonder Then clock passed midnight it starts counting from zero so condition
time$("seconds")>Timecounter holds no more!
NEXT DAY EDIT: it downed on me that using
secADay = 24*60*60 date$("days")*secADay+ time$("seconds")
instead of
time$("seconds") everythere (setting of Timecounter as well) will solve that little problem.
|
|
|
Post by tsh73 on Jan 28, 2021 22:48:27 GMT
How about starting *don-t know the word*, let it be project, on some version control site like github or source forge? With this one could pick a topic and work on it - be it game listing, replay, drag'n'drop constructor, whatever Then merge his changes with common code Without breaking thing up and with ability to roll anything back if it didn't work At least it is what they say (I only used Tortoise SVN in single person, but in theory they should work similar)
Of cource posting things here for general amusement :)
as for having some secret stuff - I'm afraid not ;) But I do have code from April 2019 - I see saved games in form of
'9:47 06.04.2019 'problem: does not recognised checkmate 'then in check, replied by checking ME 1. E2-E4 E7-E5 2. G1-F3 D8-F6 3. F3-E5 F6-E5 4. D1-F3 E5-D4 5. B1-C3 D4-E5 6. F1-C4 E5-D4 7. F3-F7 E8-D8 8. F7-F8 D4-E4
so obviously some code there. Also I had that 2d chessboard from long ago, might as well salvage something from there.
|
|