|
Post by B+ on Jan 29, 2021 19:06:16 GMT
I think I would much prefer a 2D chessboard at least while working out bugs, the angle of 3d makes diagonals and clicking squares a little less than easy. I never cared for games on the clock, though you do wish the other player would hurry up once and a while. My brother would think so long I'd lose interest in game and forget what I was doing ;-)) Oh hey checkout my first game with Rod's first post version I think (attached), it resigned with many ways to escape check! Maybe you guys already found this, I am sure the original 500 liner was playing better than that. Should I try a translation of what I have to JB? hmm... it will be 2D and might play a little better? RE: tsh73 last reply here Oh, I also think I'd prefer doing a team collaboration (is that the word you were looking for tsh73?) version here allowing tsh73 or Rod to decide the official version, you guys know JB better than I. BTW I was pleased that Rod's version worked in JB. Attachments:
|
|
|
Post by Rod on Jan 30, 2021 9:50:38 GMT
I have on my list, fix the clock, fix castling move to respect check and a simple 2d gamebuilder. I actually think the check/checkmate is fixed with the latest sub that I posted. I need the gamebuilder to prove that.
The code is of course in the public domain, anyone should feel free to extract or use or discard what they like. Just keep the reference to the old QB Code at the head of the program is all that's needed.
If you are thinking about building something the original code might be a better start since much of mine revolves round sprite management.
If anyone needs any help as always just shout out.
|
|
|
Post by Rod on Jan 30, 2021 15:17:40 GMT
This is a very quick fix. I am pretty sure the check/checkmate was fixed. I have used Anatoly's fix for the clock over midnight and put in incheck() for Castling. I have also cobbled together a very rudimentary gamebuilder. Its all in the .zip. In the .zip you will find Test.gam. Fire up the chess game, load in Test.gam and move the white queen to the position B+ was discussing. The queen is protected by the pawn, does it take the queen or does it protect itself? It protects itself. Bump the pawn forward till it gets promoted and then try and catch the King It bombs at the end because of the highlights not being correctly setbut it runs far enough to show it works. The gamebuilder has flaws. To make it work you need to key in the pieces in the positions you wish but use the nemonics wp1 wp2 wp3 etc and br1 bn1 br2 bn2 etc and wq1 bq1 color,name,number Press the button and it will save a game file as test.gam Actually the little grid program that I tweaked for the interface works better than the original code. I just made it save the content as it hopped from cell to cell. You do need to press the button to save the final cell. Liberty BASIC Chess Version2.1I will look at bugs but it might take a while to get fixed.
|
|
|
Post by tsh73 on Jan 30, 2021 16:19:28 GMT
Hello Rod It looks like it is same version 2 linked
|
|
|
Post by Rod on Jan 30, 2021 16:35:54 GMT
Thanks, try the link again.
|
|
|
Post by tsh73 on Jan 30, 2021 17:40:22 GMT
Ok I reloaded - now in has new version and a builder I run a builder - but I'd rather not to fiddle with it yet ;)
I run program - load test - moved the queen. King run away ;)
I run program - changed Windows Clock to 23:59 - after passing through 00:00 clock still tick.
New bug: you do have a check for oldX<>0 or the like Not going to work - 0 is first column, A. So highlight from A column stays.
Old reappearing bug: then checkmated, it hides my queen (I guess king just took it) Somehow then checkmated
|
|
|
Post by Rod on Jan 31, 2021 20:21:11 GMT
Fixed the highlight I hope. Just went for bsprite$(x,y)<>"" which I was using elsewhere.
Now the hiding queen. Is it possible to use this new gamebuilder to set out the end game that exhibits the fault? I have been playing at maxlevel3 but it takes ages to get to an end game and I often get beaten.
I have not had the queen disappears as yet and on the few games I win it just stops at checkmate. (edit to ask, do you mean black AI wins, white queen disappears?)
This will write a file Test.gam. It is just a text file, it should copy and paste to the forum.
edit: or use undo, then save and copy paste the save.gam file
nomainwin numCols=8 'x numRows=8 'y cellW=40 'cell width in pixels cellH=40 'cell height in pixels gridW=numCols*cellW 'total pixel width needed gridH=numRows*cellH 'total pixel height needed gridX=50 'location of data grid on window gridY=40 cellColor$="black" cellBackcolor$="white" dim cell$(numCols,numRows)
'set up a standard window to hold the graphicbox WindowWidth=800 WindowHeight=600 UpperLeftX=(DisplayWidth-WindowWidth)/2 UpperLeftY=(DisplayHeight-WindowHeight)/2 Margin=3 statictext #main.st1 "H", 20, 50, 20, 20 statictext #main.st1 "G", 20, 90, 20, 20 statictext #main.st1 "F", 20, 130, 20, 20 statictext #main.st1 "E", 20, 170, 20, 20 statictext #main.st1 "D", 20, 210, 20, 20 statictext #main.st1 "C", 20, 250, 20, 20 statictext #main.st1 "B", 20, 290, 20, 20 statictext #main.st1 "A", 20, 330, 20, 20 statictext #main.st1 "1", 70, 380, 20, 20 statictext #main.st1 "2", 110, 380, 20, 20 statictext #main.st1 "3", 150, 380, 20, 20 statictext #main.st1 "4", 190, 380, 20, 20 statictext #main.st1 "5", 230, 380, 20, 20 statictext #main.st1 "6", 270, 380, 20, 20 statictext #main.st1 "7", 310, 380, 20, 20 statictext #main.st1 "8", 350, 380, 20, 20
graphicbox #main.g,gridX,gridY,gridW+Margin,gridH+Margin
'set up a hidden textbox 'this will be relocated to intercept data input 'when a cell is clicked TextboxColor$="yellow" textbox #main.txt, -100, -100, cellW, cellH button #main.submit, "Submit", [okclicked],LR, 50,50 open "Data Grid" for window_nf as #main #main "trapclose [quit]"
'set up a fixed width font to align all text #main "font arial 8" #main.g "font arial 8" #main.g "down;fill buttonface;flush"
'set up button handler to know which cell we clicked in #main.g "when leftButtonUp [cellclicked]"
[cellclicked] 'save contents of current cell #main.txt "!contents? t$" cell$(curx,cury)=t$ gosub [draw]
'set an editing flag and capture new cell coordinates curx=int(MouseX/cellW)+1 cury=int(MouseY/cellH)+1
[editit] 'set x and y to locate the textbox at the cell location txtX=(curx-1)*cellW+1+gridX txtY=(cury-1)*cellH+1+gridY #main.txt "!locate ";txtX;" ";txtY;" ";cellW;" ";cellH #main "refresh" #main.txt cell$(curx,cury) #main.txt "!setfocus" wait
[okclicked] 'save contents of current cell #main.txt "!contents? t$" cell$(curx,cury)=t$ gosub [draw] sl$="br1,bn1,bb1,bq1,bk1,bb2,bn2,br2,bp1,bp2,bp3,bp4,bp5,bp6,bp7,bp8,wp1,wp2,wp3,wp4,wp5,wp6,wp7,wp8,wr1,wn1,wb1,wq1,wk1,wb2,wn2,wr2" open "Test.gam" for output as #1 #1, -1 #1, 0 #1, 0 for y=1 to 8 for x=1 to 8 p$=lower$(trim$(cell$(x,y))) if p$<>"" then p=instr(sl$,p$,1) sl$=left$(sl$,p-1)+right$(sl$,len(sl$)-(p+3)) if p$<>"" then if left$(p$,1)="w" then sgn=1 o1=x-1 o2=y-1 else sgn=-1 o3=x-1 o4=y-1 end if end if select case mid$(p$,2,1) case "p" v=100 case "r" v=500 case "n" v=270 case "b" v=300 case "q" v=900 case "k" v=5000 end select v=v*sgn if v=-5000 then v=-7500 #1,p$ #1,v #1,sgn #1,asc(upper$(mid$(p$,2,1))) #1,chr$(65+(x-1))+str$(8-(y-1)) else #1,"" #1,0 #1,0 #1,32 #1,chr$(65+(x-1))+str$(8-(y-1)) end if next next #1,"" #1,sl$ #1,o1 #1,o2 #1,o3 #1,o4 close #1
[quit] close #main end
[draw] 'delete the last segment, redraw all cells and flush #main.g "delsegment t" #main.g "color ";cellColor$;";backcolor ";cellBackcolor$ for C=1 to numCols for R=1 to numRows #main.g "place ";(C-1)*cellW;" ";(R-1)*cellH #main.g "boxfilled ";C*cellW+1;" ";R*cellH+1 #main.g "place ";(C-1)*cellW+8;" ";((R-1)*cellH)+17;";|";cell$(C,R) next R next C #main.g "flush t" return
|
|
|
Post by B+ on Jan 31, 2021 21:25:50 GMT
I was trying out version 2.1 and I was having good game until dang clock ran out on the AI, dang! It takes even more time than I to move!
I could probably dig through code to disable the clock but might be faster if someone could just point to the line...
I want to play some games to see what it does before digging into it. Yeah and clock does flip back to zeros at midnight.
OK and you are working on the highlighted piece too.
|
|
|
Post by B+ on Feb 1, 2021 7:36:07 GMT
Checkmate works (at least once) see attached, v2.1 from download top inits AI=Black 'the color played by the computer ClockQuit=1 'quit when 15 minutes are up?
'set out a normal white game and show the board call fillboard 'if we wish we can reverse the play, player plays black prompt "Do you want to play White? y/n"; white$ if white$ = "" or instr(lower$(white$), "n") then call reversegame prompt "End Game?" + chr$(13) + "When clock @15 mins? y/n";clock$ if instr(lower$(clock$), "n") or clock$ = "" then ClockQuit = 0 'call reversegame
reverses OK still to check castling. Clock sub #w.g "drawsprites" if wm>14 or bm>14 and ClockQuit then call text "Time limit!" call text "Game ends" wait end if
In Gamebuilder why not capitals for one color and lower case for the other? less typing. Oh yeah, had a surprise when I accidently clicked Undo at the start of a new game, the end of the last game came up. This was when I was testing switches from playing Black or White. Attachments:
|
|
|
Post by Rod on Feb 1, 2021 10:39:05 GMT
Ok, thanks for testing. I should make it a lot more obvious but you just LOAD a black game if you want a black game, or a white game and eventually any classic set play. Undo simply gets the last game position. I should do an undo save on startup to lose the old undo. Yes I agree the clock should be optional, perhaps just put a message on the log saying "time up, play on if you like".
When I spoke about reversing in an earlier post I was meaning reversing mid game. I'm not even sure folks would want that so I leave it for now. Because the black game is loaded from a .gam file it means the reverse sub is kinda redundant for now.
|
|
|
Post by xxgeek on Feb 1, 2021 12:25:27 GMT
Rod, That's a really nice looking board! I'll second that. Damn sweet looking. Best looking digital board I've ever seen actually.
I'm gonna have to practice on it...... At the beginner level.
|
|
|
Post by B+ on Feb 1, 2021 18:22:24 GMT
Ok, thanks for testing. I should make it a lot more obvious but you just LOAD a black game if you want a black game, or a white game and eventually any classic set play. Undo simply gets the last game position. I should do an undo save on startup to lose the old undo. Yes I agree the clock should be optional, perhaps just put a message on the log saying "time up, play on if you like". When I spoke about reversing in an earlier post I was meaning reversing mid game. I'm not even sure folks would want that so I leave it for now. Because the black game is loaded from a .gam file it means the reverse sub is kinda redundant for now. Did I accidently discover a way to choose Black or White at game start without having to load anything? I like reverse, it kept the squares labeled correctly and the AI did start playing when I reversed to play Black. Maybe you don't like using Prompt? I know some coders think using input boxes or message boxes "hacks" but I think there are appropriate times. I was very pleased to see the Checkmate acknowledged but have to say kinda silly to resign when you are in Checkmate, too late for that! ;-)) Optional clock is great and this plays so slow calling it "Speed Chess" is kinda silly too. I hope you don't take offense, just saying... or just being picky, sorry. The clock issue should be decided before start of play for proper game conduct; rules laid out at start and agreed upon before play begins but of course, that then blows up my argument for Reverse ;-))
|
|
|
Post by Rod on Feb 1, 2021 18:43:30 GMT
Ok, I have disabled the time limit, the clocks are simply for fun. I think UNDO is fixed. I have left it set so that the player LOADs the game of their choice. So the default game is human is white but you can LOAD a different game. Happy to hear that REVERSE seems to work. That probably needs an on screen button. Not sure if there is any real demand for it. I had also intended to have a suit of end games as .gam files but out of time right now. That just leaves the disappearing queen to sort out but so far I can't replicate that. One other thing that may catch folks out is that while the AI is thinking the game locks up. Right now that is deliberate. The only thing I could implement easily is red [X] shutdown. But breaking the recursive AI half way and rescuing program flow is a step too far for me. However all that said it plays a good game and can often catch me out! Just BASIC Chess v2.2 1st Feb 2021
|
|
|
Post by B+ on Feb 1, 2021 19:30:45 GMT
Rod do us a favor, when you update the version also please update the zip name with it to avoid confusion for us fans of your work who want to follow each step. You are doing this for the download link but the zip file in my Downloads folder is Chess2 same for last 2 updates.
|
|
|
Post by B+ on Feb 1, 2021 20:04:11 GMT
Just an idea, when a King is in check change color white to red, black to blue or make them more ashen grey and maybe further, have them tremble a little ;-)) (just going too far with this idea).
|
|