├── castling1.txt ├── castling2.txt ├── castling3.txt ├── castling4.txt ├── main.py ├── README.md ├── configuration.txt ├── moves.txt └── chessnewsudip.py /castling1.txt: -------------------------------------------------------------------------------- 1 | True__True 2 | -------------------------------------------------------------------------------- /castling2.txt: -------------------------------------------------------------------------------- 1 | True__True 2 | -------------------------------------------------------------------------------- /castling3.txt: -------------------------------------------------------------------------------- 1 | True__True 2 | -------------------------------------------------------------------------------- /castling4.txt: -------------------------------------------------------------------------------- 1 | True__True 2 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from chessnewsudip import * 2 | main_fun() 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chessgame 2 | # get the whole repository and play chess 3 | # this is made on tkinter 4 | -------------------------------------------------------------------------------- /configuration.txt: -------------------------------------------------------------------------------- 1 | #ffffff 2 | #3e3e3e 3 | #ffff1a 4 | #000000 5 | #fe421b 6 | #43fee7 7 | #7857ea 8 | -------------------------------------------------------------------------------- /moves.txt: -------------------------------------------------------------------------------- 1 | Rhbqkbhrpppppppp ppppppppRhbqkbhr 2 | ggggggggggggggggppppppppppppppppppppppppppppwpppwwwwwwwwwwwwwwww 3 | -------------------------------------------------------------------------------- /chessnewsudip.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter.messagebox import * 3 | from tkinter.scrolledtext import * 4 | from tkinter.colorchooser import * 5 | from datetime import * 6 | from time import * 7 | def rules(): 8 | temp=Tk() 9 | stext = ScrolledText(temp,bg='white', height=10) 10 | stext.insert('end', '''Pawns only move forward. On the first move a pawn can move one or two spaces, every subsequent move can only be one space. Pawns move diagonally to take opponents. 11 | Pawn Promotion: 12 | If a pawn reaches the opposite side of the board, it is promoted to a higher piece (except king). There is no limit to how many pawns can be promoted. 13 | 14 | Rooks move in a continuous line forwards, backwards and side-to-side. 15 | 16 | Knights are the only pieces that "jump" off the board. Unlike other pieces they are not blocked if there are pieces between them and their destination square. To make it easier to remember how a knight moves think of an L. Two spaces in a direction forward, backward or side-to-side, and one space at a right or left turn. 17 | 18 | Bishops move in continuous diagonal lines in any direction. 19 | 20 | The queen moves in continuous diagonal and straight lines. Forward, backward and side-to-side. 21 | 22 | The king can move in any direction, one square at a time. A king cannot move to a square that is under attack by the opponent. 23 | Castling is the only move that allows two pieces to move during the same turn. 24 | 25 | CASTLING:During castling a king moves two spaces towards the rook that it will castle with, and the rook jumps to the other side. The king can castle to either side as long as: 26 | 27 | 1. The king has not moved. 28 | 2. The king is not in check. 29 | 3. The king does not move through or into check. 30 | 4. There are no pieces between the king and castling-side rook. 31 | 5. The castling-side rook has not moved. 32 | 33 | It does not matter: 34 | 35 | A. If the king was in check, but is no longer. 36 | B. If the rook can be attacked by an opponent's piece before castling.''') 37 | stext.grid(row=1,column=1) 38 | stext.focus_set() 39 | stext.mainloop() 40 | def colorerrorremover(): 41 | global bwbw 42 | if bwbw==color3: 43 | bwbw=color4 44 | else: 45 | bwbw=color3 46 | def pass_(): 47 | pass 48 | def castlingperm(b): 49 | if b['text']=='♚' and b['fg']==color3 and (b in posmoves): 50 | file=open('castling1.txt','a') 51 | file.write('False__False\n') 52 | file.close() 53 | file=open('castling2.txt','a') 54 | file.write('False__False\n') 55 | file.close() 56 | else: 57 | if b['text']=='♜'and b['fg']==color3 and (b in posmoves): 58 | file=open('castling1.txt','a') 59 | file.write('False__False\n') 60 | file.close() 61 | elif castlingtest1()==True: 62 | file=open('castling1.txt','a') 63 | file.write('True__True\n') 64 | file.close() 65 | else: 66 | file=open('castling1.txt','a') 67 | file.write('False__False\n') 68 | file.close() 69 | if b['text']=='♖'and b['fg']==color3 and (b in posmoves): 70 | file=open('castling2.txt','a') 71 | file.write('False__False\n') 72 | file.close() 73 | elif castlingtest2()==True: 74 | file=open('castling2.txt','a') 75 | file.write('True__True\n') 76 | file.close() 77 | else: 78 | file=open('castling2.txt','a') 79 | file.write('False__False\n') 80 | file.close() 81 | if b['text']=='♚' and b['fg']==color4 and (b in posmoves): 82 | file=open('castling3.txt','a') 83 | file.write('False__False\n') 84 | file.close() 85 | file=open('castling4.txt','a') 86 | file.write('False__False\n') 87 | file.close() 88 | else: 89 | if b['text']=='♜'and b['fg']==color4 and (b['bg']==color5 or b['bg']==color6): 90 | file=open('castling3.txt','a') 91 | file.write('False__False\n') 92 | file.close() 93 | elif castlingtest3()==True: 94 | file=open('castling3.txt','a') 95 | file.write('True__True\n') 96 | file.close() 97 | else: 98 | file=open('castling3.txt','a') 99 | file.write('False__False\n') 100 | file.close() 101 | if b['text']=='♖'and b['fg']==color4 and (b['bg']==color5 or b['bg']==color6): 102 | file=open('castling4.txt','a') 103 | file.write('False__False\n') 104 | file.close() 105 | elif castlingtest4()==True: 106 | file=open('castling4.txt','a') 107 | file.write('True__True\n') 108 | file.close() 109 | else: 110 | file=open('castling4.txt','a') 111 | file.write('False__False\n') 112 | file.close() 113 | def castlingtest1(): 114 | a=open('castling1.txt','r') 115 | t=a.readlines() 116 | a.close() 117 | t.reverse() 118 | t=t[0] 119 | if t=='True__True\n': 120 | return True 121 | else: 122 | return False 123 | def castlingtest2(): 124 | a=open('castling2.txt','r') 125 | t=a.readlines() 126 | a.close() 127 | t.reverse() 128 | t=t[0] 129 | if t=='True__True\n': 130 | return True 131 | else: 132 | return False 133 | def castlingtest3(): 134 | a=open('castling3.txt','r') 135 | t=a.readlines() 136 | a.close() 137 | t.reverse() 138 | t=t[0] 139 | if t=='True__True\n': 140 | return True 141 | else: 142 | return False 143 | def castlingtest4(): 144 | a=open('castling4.txt','r') 145 | t=a.readlines() 146 | a.close() 147 | t.reverse() 148 | t=t[0] 149 | if t=='True__True\n': 150 | return True 151 | else: 152 | return False 153 | def colorname(a): 154 | x=list(a) 155 | x.reverse() 156 | x.pop(0) 157 | x.reverse() 158 | s='' 159 | for i in x: 160 | s=s+i 161 | return s 162 | def new(button,button__,tkk): 163 | button__['fg']=KEY 164 | a=button['text'] 165 | b=a[0] 166 | button__['text']=b 167 | def king(b1): 168 | if b1['fg']==color3 and castlingtest1()==True and pos1[(7,2)]['text']==' ' and pos1[(7,3)]['text']==' ' and pos1[(7,4)]['text']==' ': 169 | if showcolor==True: 170 | pos1[(7,3)]['bg']=color6 171 | special.append(pos1[(7,3)]) 172 | if b1['fg']==color3 and castlingtest2()==True and pos1[(7,6)]['text']==' ' and pos1[(7,7)]['text']==' ' : 173 | if showcolor==True: 174 | pos1[(7,7)]['bg']=color6 175 | special.append(pos1[(7,7)]) 176 | if b1['fg']==color4 and castlingtest4()==True and pos1[(0,6)]['text']==' ' and pos1[(0,7)]['text']==' ': 177 | if showcolor==True: 178 | pos1[(0,7)]['bg']=color6 179 | special.append(pos1[(0,7)]) 180 | if b1['fg']==color4 and castlingtest3()==True and pos1[(0,2)]['text']==' ' and pos1[(0,3)]['text']==' ' and pos1[(0,4)]['text']==' ': 181 | if showcolor==True: 182 | pos1[(0,3)]['bg']=color6 183 | special.append(pos1[(0,3)]) 184 | bpos=pos[b1] 185 | b=bpos[0] 186 | c=bpos[1] 187 | try: 188 | n=b+1 189 | l=c 190 | m=0 191 | if n<=8 and n>=0 and l<=8 and l>=1: 192 | m=(n,l) 193 | b2=pos1[m] 194 | if b2['text']==' ': 195 | if showcolor==True: 196 | b2['bg']=color6 197 | posmoves.append(b2) 198 | elif b2['fg']!=b1['fg']: 199 | if showcolor==True: 200 | b2['bg']=color5 201 | posmoves.append(b2) 202 | except: 203 | pass 204 | b=bpos[0] 205 | c=bpos[1] 206 | try: 207 | n=b-1 208 | l=c 209 | m=0 210 | if n<=8 and n>=0 and l<=8 and l>=1: 211 | m=(n,l) 212 | b2=pos1[m] 213 | if b2['text']==' ': 214 | if showcolor==True: 215 | b2['bg']=color6 216 | posmoves.append(b2) 217 | elif b2['fg']!=b1['fg']: 218 | if showcolor==True: 219 | b2['bg']=color5 220 | posmoves.append(b2) 221 | except: 222 | pass 223 | b=bpos[0] 224 | c=bpos[1] 225 | try: 226 | n=b 227 | l=c+1 228 | m=0 229 | if n<=8 and n>=0 and l<=8 and l>=1: 230 | m=(n,l) 231 | b2=pos1[m] 232 | if b2['text']==' ': 233 | if showcolor==True: 234 | b2['bg']=color6 235 | posmoves.append(b2) 236 | elif b2['fg']!=b1['fg']: 237 | if showcolor==True: 238 | b2['bg']=color5 239 | posmoves.append(b2) 240 | except: 241 | pass 242 | b=bpos[0] 243 | c=bpos[1] 244 | try: 245 | n=b 246 | l=c-1 247 | m=0 248 | if n<=8 and n>=0 and l<=8 and l>=1: 249 | m=(n,l) 250 | b2=pos1[m] 251 | if b2['text']==' ': 252 | if showcolor==True: 253 | b2['bg']=color6 254 | posmoves.append(b2) 255 | elif b2['fg']!=b1['fg']: 256 | if showcolor==True: 257 | b2['bg']=color5 258 | posmoves.append(b2) 259 | except: 260 | pass 261 | b=bpos[0] 262 | c=bpos[1] 263 | try: 264 | n=b+1 265 | l=c+1 266 | m=0 267 | if n<=8 and n>=0 and l<=8 and l>=1: 268 | m=(n,l) 269 | b2=pos1[m] 270 | if b2['text']==' ': 271 | if showcolor==True: 272 | b2['bg']=color6 273 | posmoves.append(b2) 274 | elif b2['fg']!=b1['fg']: 275 | if showcolor==True: 276 | b2['bg']=color5 277 | posmoves.append(b2) 278 | except: 279 | pass 280 | b=bpos[0] 281 | c=bpos[1] 282 | try: 283 | n=b+1 284 | l=c-1 285 | m=0 286 | if n<=8 and n>=0 and l<=8 and l>=1: 287 | m=(n,l) 288 | b2=pos1[m] 289 | if b2['text']==' ': 290 | if showcolor==True: 291 | b2['bg']=color6 292 | posmoves.append(b2) 293 | elif b2['fg']!=b1['fg']: 294 | if showcolor==True: 295 | b2['bg']=color5 296 | posmoves.append(b2) 297 | except: 298 | pass 299 | b=bpos[0] 300 | c=bpos[1] 301 | try: 302 | n=b-1 303 | l=c+1 304 | m=0 305 | if n<=8 and n>=0 and l<=8 and l>=1: 306 | m=(n,l) 307 | b2=pos1[m] 308 | if b2['text']==' ': 309 | if showcolor==True: 310 | b2['bg']=color6 311 | posmoves.append(b2) 312 | elif b2['fg']!=b1['fg']: 313 | if showcolor==True: 314 | b2['bg']=color5 315 | posmoves.append(b2) 316 | except: 317 | pass 318 | b=bpos[0] 319 | c=bpos[1] 320 | try: 321 | n=b-1 322 | l=c-1 323 | m=0 324 | if n<=8 and n>=0 and l<=8 and l>=1: 325 | m=(n,l) 326 | b2=pos1[m] 327 | if b2['text']==' ': 328 | if showcolor==True: 329 | b2['bg']=color6 330 | posmoves.append(b2) 331 | elif b2['fg']!=b1['fg']: 332 | if showcolor==True: 333 | b2['bg']=color5 334 | posmoves.append(b2) 335 | except: 336 | pass 337 | def knight(b1): 338 | bpos=pos[b1] 339 | k=bpos[0]+2 340 | l=bpos[1]+1 341 | n=(k,l) 342 | try: 343 | b2=pos1[n] 344 | if b2['fg']!=b1['fg']: 345 | if showcolor==True: 346 | b2['bg']=color5 347 | posmoves.append(b2) 348 | if b2['fg']==color1: 349 | if showcolor==True: 350 | b2['bg']=color6 351 | posmoves.append(b2) 352 | except: 353 | pass 354 | k=bpos[0]-2 355 | l=bpos[1]+1 356 | n=(k,l) 357 | try: 358 | b2=pos1[n] 359 | if b2['fg']!=b1['fg']: 360 | if showcolor==True: 361 | b2['bg']=color5 362 | posmoves.append(b2) 363 | if b2['fg']==color1: 364 | if showcolor==True: 365 | b2['bg']=color6 366 | posmoves.append(b2) 367 | except: 368 | pass 369 | k=bpos[0]+2 370 | l=bpos[1]-1 371 | n=(k,l) 372 | try: 373 | b2=pos1[n] 374 | if b2['fg']!=b1['fg']: 375 | if showcolor==True: 376 | b2['bg']=color5 377 | posmoves.append(b2) 378 | if b2['fg']==color1: 379 | if showcolor==True: 380 | b2['bg']=color6 381 | posmoves.append(b2) 382 | except: 383 | pass 384 | k=bpos[0]-2 385 | l=bpos[1]-1 386 | n=(k,l) 387 | try: 388 | b2=pos1[n] 389 | if b2['fg']!=b1['fg']: 390 | if showcolor==True: 391 | b2['bg']=color5 392 | posmoves.append(b2) 393 | if b2['fg']==color1: 394 | if showcolor==True: 395 | b2['bg']=color6 396 | posmoves.append(b2) 397 | except: 398 | pass 399 | k=bpos[0]+1 400 | l=bpos[1]+2 401 | n=(k,l) 402 | try: 403 | b2=pos1[n] 404 | if b2['fg']!=b1['fg']: 405 | if showcolor==True: 406 | b2['bg']=color5 407 | posmoves.append(b2) 408 | if b2['fg']==color1: 409 | if showcolor==True: 410 | b2['bg']=color6 411 | posmoves.append(b2) 412 | except: 413 | pass 414 | k=bpos[0]+1 415 | l=bpos[1]-2 416 | n=(k,l) 417 | try: 418 | b2=pos1[n] 419 | if b2['fg']!=b1['fg']: 420 | if showcolor==True: 421 | b2['bg']=color5 422 | posmoves.append(b2) 423 | if b2['fg']==color1: 424 | if showcolor==True: 425 | b2['bg']=color6 426 | posmoves.append(b2) 427 | except: 428 | pass 429 | k=bpos[0]-1 430 | l=bpos[1]+2 431 | n=(k,l) 432 | try: 433 | b2=pos1[n] 434 | if b2['fg']!=b1['fg']: 435 | if showcolor==True: 436 | b2['bg']=color5 437 | posmoves.append(b2) 438 | if b2['fg']==color1: 439 | if showcolor==True: 440 | b2['bg']=color6 441 | posmoves.append(b2) 442 | except: 443 | pass 444 | k=bpos[0]-1 445 | l=bpos[1]-2 446 | n=(k,l) 447 | try: 448 | b2=pos1[n] 449 | if b2['fg']!=b1['fg']: 450 | if showcolor==True: 451 | b2['bg']=color5 452 | posmoves.append(b2) 453 | if b2['fg']==color1: 454 | if showcolor==True: 455 | b2['bg']=color6 456 | posmoves.append(b2) 457 | except: 458 | pass 459 | def rook(b1): 460 | bpos=pos[b1] 461 | b=bpos[0] 462 | c=bpos[1] 463 | try: 464 | while b<=9: 465 | b+=1 466 | l=(b,c) 467 | b2=pos1[l] 468 | if b2['text']==' ': 469 | if showcolor==True: 470 | b2['bg']=color6 471 | posmoves.append(b2) 472 | elif b2['fg']!=b1['fg']: 473 | if showcolor==True: 474 | b2['bg']=color5 475 | posmoves.append(b2) 476 | break 477 | else: 478 | break 479 | except: 480 | pass 481 | b2='' 482 | b=bpos[0] 483 | c=bpos[1] 484 | try: 485 | while b>=0: 486 | b=b-1 487 | l=(b,c) 488 | b2=pos1[l] 489 | if b2['text']==' ': 490 | if showcolor==True: 491 | b2['bg']=color6 492 | posmoves.append(b2) 493 | elif b2['fg']!=b1['fg']: 494 | if showcolor==True: 495 | b2['bg']=color5 496 | posmoves.append(b2) 497 | break 498 | else: 499 | break 500 | except: 501 | pass 502 | b2='' 503 | b=bpos[0] 504 | c=bpos[1] 505 | try: 506 | while c<=9: 507 | c+=1 508 | l=(b,c) 509 | b2=pos1[l] 510 | if b2['text']==' ': 511 | if showcolor==True: 512 | b2['bg']=color6 513 | posmoves.append(b2) 514 | elif b2['fg']!=b1['fg']: 515 | if showcolor==True: 516 | b2['bg']=color5 517 | posmoves.append(b2) 518 | break 519 | else: 520 | break 521 | except: 522 | pass 523 | b=bpos[0] 524 | c=bpos[1] 525 | b2='' 526 | try: 527 | while c>=0: 528 | c=c-1 529 | l=(b,c) 530 | b2=pos1[l] 531 | if b2['text']==' ': 532 | if showcolor==True: 533 | b2['bg']=color6 534 | posmoves.append(b2) 535 | elif b2['fg']!=b1['fg']: 536 | if showcolor==True: 537 | b2['bg']=color5 538 | posmoves.append(b2) 539 | break 540 | else: 541 | break 542 | except: 543 | pass 544 | def bishop(b1): 545 | bpos=pos[b1] 546 | b=bpos[0] 547 | c=bpos[1] 548 | try: 549 | while b<=8 and c<=7: 550 | b+=1 551 | c+=1 552 | l=(b,c) 553 | b2=pos1[l] 554 | if b2['text']==' ': 555 | if showcolor==True: 556 | b2['bg']=color6 557 | posmoves.append(b2) 558 | elif b2['fg']!=b1['fg']: 559 | if showcolor==True: 560 | b2['bg']=color5 561 | posmoves.append(b2) 562 | break 563 | else: 564 | break 565 | except: 566 | pass 567 | b=bpos[0] 568 | c=bpos[1] 569 | try: 570 | while b<=8 and c>=2: 571 | b+=1 572 | c-=1 573 | l=(b,c) 574 | b2=pos1[l] 575 | if b2['text']==' ': 576 | if showcolor==True: 577 | b2['bg']=color6 578 | posmoves.append(b2) 579 | elif b2['fg']!=b1['fg']: 580 | if showcolor==True: 581 | b2['bg']=color5 582 | posmoves.append(b2) 583 | break 584 | else: 585 | break 586 | except: 587 | pass 588 | b=bpos[0] 589 | c=bpos[1] 590 | try: 591 | while b>=0 and c<=7: 592 | b-=1 593 | c+=1 594 | l=(b,c) 595 | b2=pos1[l] 596 | if b2['text']==' ': 597 | if showcolor==True: 598 | b2['bg']=color6 599 | posmoves.append(b2) 600 | elif b2['fg']!=b1['fg']: 601 | if showcolor==True: 602 | b2['bg']=color5 603 | posmoves.append(b2) 604 | break 605 | else: 606 | break 607 | except: 608 | pass 609 | b=bpos[0] 610 | c=bpos[1] 611 | try: 612 | while b>=0 and c>=2: 613 | b=b-1 614 | c=c-1 615 | l=(b,c) 616 | b2=pos1[l] 617 | if b2['text']==' ': 618 | if showcolor==True: 619 | b2['bg']=color6 620 | posmoves.append(b2) 621 | elif b2['fg']!=b1['fg']: 622 | if showcolor==True: 623 | b2['bg']=color5 624 | posmoves.append(b2) 625 | break 626 | else: 627 | break 628 | except: 629 | pass 630 | def queen(b1): 631 | rook(b1) 632 | bishop(b1) 633 | def pawn(b1): 634 | b2,b3,b4,b5='','','','' 635 | bpos=pos[b1] 636 | if b1['fg']==color3: 637 | k=bpos[0]-1 638 | l=bpos[1] 639 | n=(k,l) 640 | try: 641 | b2=pos1[n] 642 | except: 643 | del(b2) 644 | k=bpos[0]-2 645 | l=bpos[1] 646 | n=(k,l) 647 | try: 648 | b3=pos1[n] 649 | except: 650 | del(b3) 651 | k=bpos[0]-1 652 | l=bpos[1]-1 653 | n=(k,l) 654 | try: 655 | b4=pos1[n] 656 | except: 657 | del(b4) 658 | k=bpos[0]-1 659 | l=bpos[1]+1 660 | n=(k,l) 661 | try: 662 | b5=pos1[n] 663 | except: 664 | del(b5) 665 | if b1['fg']==color4: 666 | k=bpos[0]+1 667 | l=bpos[1] 668 | n=(k,l) 669 | try: 670 | b2=pos1[n] 671 | except: 672 | del(b2) 673 | k=bpos[0]+2 674 | l=bpos[1] 675 | n=(k,l) 676 | try: 677 | b3=pos1[n] 678 | except: 679 | del(b3) 680 | k=bpos[0]+1 681 | l=bpos[1]-1 682 | n=(k,l) 683 | try: 684 | b4=pos1[n] 685 | except: 686 | del(b4) 687 | k=bpos[0]+1 688 | l=bpos[1]+1 689 | n=(k,l) 690 | try: 691 | b5=pos1[n] 692 | except: 693 | del(b5) 694 | ppaw={color3:6,color4:1} 695 | colour=b1['fg'] 696 | pos__1=ppaw[colour] 697 | try: 698 | if b2['text']==' ': 699 | if showcolor==True: 700 | b2['bg']=color6 701 | posmoves.append(b2) 702 | if b3['text']==' ' and pos[b1][0]==pos__1: 703 | if showcolor==True: 704 | b3['bg']=color6 705 | posmoves.append(b3) 706 | except: 707 | pass 708 | try: 709 | if b4['fg']!=color1 and b1['fg']!=b4['fg']: 710 | if showcolor==True: 711 | b4['bg']=color5 712 | posmoves.append(b4) 713 | except: 714 | pass 715 | try: 716 | if b5['fg']!=color1 and b1['fg']!=b5['fg']: 717 | if showcolor==True: 718 | b5['bg']=color5 719 | posmoves.append(b5) 720 | except: 721 | pass 722 | def moves(t,b1): 723 | global posmoves 724 | posmoves=[] 725 | special=[] 726 | if t=='♟': 727 | pawn(b1) 728 | if t=='♖' or t=='♜': 729 | rook(b1) 730 | if t=='♝': 731 | bishop(b1) 732 | if t=='♚': 733 | king(b1) 734 | if t=='♛': 735 | queen(b1) 736 | if t=='♞': 737 | knight(b1) 738 | b1['bg']=color7 739 | def returntocolor(): 740 | for i in range(1,65): 741 | p=aa[i] 742 | if (i %8)==0: 743 | if (i//8)%2==1: 744 | p['bg']=color2 745 | else: 746 | p['bg']=color1 747 | elif (i//8)%2==0: 748 | if i%2==0: 749 | p['bg']=color2 750 | else: 751 | p['bg']=color1 752 | else: 753 | if i%2==1: 754 | p['bg']=color2 755 | else: 756 | p['bg']=color1 757 | if p['text']==' ': 758 | p['fg']=color1 759 | def undo(): 760 | global bwbw 761 | try: 762 | undo_() 763 | except: 764 | if bwbw==color3: 765 | bwbw=color4 766 | else: 767 | bwbw=color3 768 | def undo_() : 769 | global bwbw 770 | if bwbw==color4: 771 | bwbw=color3 772 | else: 773 | bwbw=color4 774 | files=open('moves.txt','r') 775 | b=files.read() 776 | b=b.split('\n') 777 | b.reverse() 778 | b.pop(0) 779 | b.pop(0) 780 | b.pop(0) 781 | m=b[0] 782 | n=b[1] 783 | for i in range(1,65): 784 | p=aa[i] 785 | q=n[i-1] 786 | q=x1[q] 787 | r=m[i-1] 788 | r=y1[r] 789 | p['fg']=r 790 | p['text']=q 791 | files.close() 792 | b.reverse() 793 | xx=[] 794 | for i in b: 795 | cc=i+'\n' 796 | xx.append(cc) 797 | b=xx 798 | files=open('moves.txt','w') 799 | files.writelines(b) 800 | files.close() 801 | 802 | file=open('castling1.txt','r') 803 | a=file.readlines() 804 | file.close() 805 | a.reverse() 806 | a.pop(0) 807 | a.reverse() 808 | file=open('castling1.txt','w') 809 | file.writelines(a) 810 | file.close() 811 | file=open('castling2.txt','r') 812 | a=file.readlines() 813 | file.close() 814 | a.reverse() 815 | a.pop(0) 816 | a.reverse() 817 | file=open('castling2.txt','w') 818 | file.writelines(a) 819 | file.close() 820 | file=open('castling3.txt','r') 821 | a=file.readlines() 822 | file.close() 823 | a.reverse() 824 | a.pop(0) 825 | a.reverse() 826 | file=open('castling3.txt','w') 827 | file.writelines(a) 828 | file.close() 829 | file=open('castling4.txt','r') 830 | a=file.readlines() 831 | file.close() 832 | a.reverse() 833 | a.pop(0) 834 | a.reverse() 835 | file=open('castling4.txt','w') 836 | file.writelines(a) 837 | file.close() 838 | def check(p): 839 | global showcolor,posmoves,xxxxx 840 | posmoves=[] 841 | for i in range(1,65): 842 | butt=aa[i] 843 | x=showcolor 844 | showcolor=False 845 | if butt['text']!='♚': 846 | moves(butt['text'],butt) 847 | returntocolor() 848 | for j in posmoves: 849 | if j['text']=='♚': 850 | if j['fg']!=p['fg']: 851 | showwarning('warning','Check') 852 | if j['fg']==color3: 853 | file=open('castling1.txt','w') 854 | file.write('False__False\n') 855 | file.close() 856 | file=open('castling2.txt','w') 857 | file.write('False__False\n') 858 | file.close() 859 | if j['fg']==color4: 860 | file=open('castling3.txt','w') 861 | file.write('False__False\n') 862 | file.close() 863 | file=open('castling4.txt','w') 864 | file.write('False__False\n') 865 | file.close() 866 | elif j['fg']==p['fg'] and xxxxx==False: 867 | showwarning('warning','Check invalid move') 868 | undo() 869 | posmoves=[] 870 | special=[] 871 | showcolor=x 872 | xxxxx=False 873 | def write(): 874 | files=open('moves.txt','a') 875 | m='' 876 | n='' 877 | for i in range(1,65): 878 | p=aa[i] 879 | q=p['text'] 880 | q=x[q] 881 | r=p['fg']; 882 | r=y[r] 883 | m+=q 884 | n+=r 885 | m+='\n' 886 | n+='\n' 887 | files.write(m) 888 | files.write(n) 889 | files.close() 890 | def invalidcheck(bbb,bgg,tk=None): 891 | global bwbw,xxxxx 892 | if bbb in posmoves : 893 | if bwbw==color3: 894 | bwbw=color4 895 | else: 896 | bwbw=color3 897 | elif bbb in special: 898 | if bwbw==color3: 899 | bwbw=color4 900 | else: 901 | bwbw=color3 902 | if bbb==button63: 903 | button62['text']='♖' 904 | button62['fg']=color3 905 | button64['text']=' ' 906 | xxxxx=True 907 | if bbb==button59: 908 | button60['text']='♖' 909 | button60['fg']=color3 910 | button57['text']=' ' 911 | xxxxx=True 912 | if bbb==button3: 913 | button4['text']='♖' 914 | button4['fg']=color4 915 | button1['text']=' ' 916 | xxxxx=True 917 | if bbb==button7: 918 | button6['text']='♖' 919 | button6['fg']=color4 920 | button8['text']=' ' 921 | xxxxx=True 922 | elif bgg!=color7: 923 | if bwbw==color3: 924 | bwbw=color4 925 | else: 926 | bwbw=color3 927 | showwarning('spam','invalid move') 928 | try: 929 | tk.destroy() 930 | except: 931 | pass 932 | undo() 933 | def showonoff(buttons): 934 | global showcolor 935 | dicta={'Red':'Green','Green':'Red'} 936 | buttons['fg']=dicta[buttons['fg']] 937 | showcolor=not showcolor 938 | def concolor(listt,buttons,dict1): 939 | global color1,color2,color3,color4,color5,color6,color7 940 | x=askcolor() 941 | buttons['bg']=x[1] 942 | lll=[dict1[1]['bg']+'\n',dict1[2]['bg']+'\n',dict1[3]['bg']+'\n',dict1[4]['bg']+'\n',dict1[5]['bg']+'\n',dict1[6]['bg']+'\n',dict1[7]['bg']+'\n'] 943 | files=open('configuration.txt','w') 944 | files.writelines(lll) 945 | files.close() 946 | def okexecute(dict1,a): 947 | lll=[dict1[1]['bg']+'\n',dict1[2]['bg']+'\n',dict1[3]['bg']+'\n',dict1[4]['bg']+'\n',dict1[5]['bg']+'\n',dict1[6]['bg']+'\n',dict1[7]['bg']+'\n'] 948 | files=open('configuration.txt','w') 949 | files.writelines(lll) 950 | files.close() 951 | showinfo('info','OPEN THE GAME AGAIN TO GET THE CONFIGURATION') 952 | a.destroy() 953 | def cancelexecute(a): 954 | a.destroy() 955 | def configure(): 956 | global color1,color2,color3,color4,color5,color6,color7 957 | files=open('configuration.txt','r') 958 | l=files.readlines() 959 | files.close() 960 | tk=Tk() 961 | tk.title('Configure') 962 | tk.config(bg='Powder Blue') 963 | label1=Label(tk,bg='Powder Blue',text='Board Color 1 ') 964 | label1.grid(row=1,column=1) 965 | label2=Label(tk,bg='Powder Blue',text='Board Color 2 ') 966 | label2.grid(row=2,column=1) 967 | label3=Label(tk,bg='Powder Blue',text='Player Color 1 ') 968 | label3.grid(row=3,column=1) 969 | label4=Label(tk,bg='Powder Blue',text='Player Color 2 ') 970 | label4.grid(row=4,column=1) 971 | label5=Label(tk,bg='Powder Blue',text='Moves Color 1 ') 972 | label5.grid(row=5,column=1) 973 | label6=Label(tk,bg='Powder Blue',text='Moves Color 2 ') 974 | label6.grid(row=6,column=1) 975 | label7=Label(tk,bg='Powder Blue',text='Moves Color 3 ') 976 | label7.grid(row=7,column=1) 977 | button1=Button(tk,height=1,width=2,bd=10,bg=color1,command=lambda:concolor(l,button1,dicty)) 978 | button2=Button(tk,height=1,width=2,bd=10,bg=color2,command=lambda:concolor(l,button2,dicty)) 979 | button3=Button(tk,height=1,width=2,bd=10,bg=color3,command=lambda:concolor(l,button3,dicty)) 980 | button4=Button(tk,height=1,width=2,bd=10,bg=color4,command=lambda:concolor(l,button4,dicty)) 981 | button5=Button(tk,height=1,width=2,bd=10,bg=color5,command=lambda:concolor(l,button5,dicty)) 982 | button6=Button(tk,height=1,width=2,bd=10,bg=color6,command=lambda:concolor(l,button6,dicty)) 983 | button7=Button(tk,height=1,width=2,bd=10,bg=color7,command=lambda:concolor(l,button7,dicty)) 984 | button1.grid(row=1,column=3) 985 | button2.grid(row=2,column=3) 986 | button3.grid(row=3,column=3) 987 | button4.grid(row=4,column=3) 988 | button5.grid(row=5,column=3) 989 | button6.grid(row=6,column=3) 990 | button7.grid(row=7,column=3) 991 | button8=Button(tk,text='ok',height=1,width=7,bd=10,bg='Powder blue',command=lambda:okexecute(dicty,tk)) 992 | button8.grid(row=8,column=1) 993 | button9=Button(tk,text='cancel',height=1,width=7,bd=10,bg='Powder blue',command=lambda:cancelexecute(tk)) 994 | button9.grid(row=8,column=3) 995 | dicty={1:button1,2:button2,3:button3,4:button4,5:button5,6:button6,7:button7} 996 | def gamesave(a,b,c,l,m): 997 | x=a.get() 998 | y=b.get() 999 | z=c.get() 1000 | t=x+y+z+'.txt' 1001 | files=open(t,'w') 1002 | files.writelines(l) 1003 | files.close() 1004 | m.destroy() 1005 | def gameopen(a,b,c,l,m): 1006 | x=a.get() 1007 | y=b.get() 1008 | z=c.get() 1009 | t=x+y+z+'.txt' 1010 | files=open(t,'r') 1011 | l=files.readlines() 1012 | files.close() 1013 | files=open('moves.txt','w') 1014 | files.write('''rhbqkbhrpppppppp pppppppprhbqkbhr 1015 | ggggggggggggggggppppppppppppppppppppppppppppwpppwwwwwwwwwwwwwwww\n''') 1016 | files.writelines(l) 1017 | files.write('''rhbqkbhrpppppppp pppppppprhbqkbhr 1018 | ggggggggggggggggppppppppppppppppppppppppppppwpppwwwwwwwwwwwwwwww\n''') 1019 | files.close() 1020 | m.destroy() 1021 | undo() 1022 | def save_open_game(buttons): 1023 | files=open('moves.txt','r') 1024 | l=files.readlines() 1025 | files.close() 1026 | tk=Tk() 1027 | tk.config(bg='Powder Blue') 1028 | a=Entry(tk) 1029 | a.grid(row=1,column=3) 1030 | b=Entry(tk) 1031 | b.grid(row=3,column=3) 1032 | c=Entry(tk) 1033 | c.grid(row=5,column=3) 1034 | Label(tk,text='pl1name',bg='Powder Blue').grid(row=1,column=1) 1035 | Label(tk,text='pl2name',bg='Powder Blue').grid(row=3,column=1) 1036 | Label(tk,text='''game number 1037 | (**to identify the 1038 | particular game)''',bg='Powder Blue').grid(row=5,column=1) 1039 | if buttons['text']=='SAVEGAME': 1040 | Button(tk,text='ok',bg='Powder Blue',command=lambda:(gamesave(a,b,c,l,tk))).grid(row=7,column=2) 1041 | if buttons['text']=='OPENGAME': 1042 | Button(tk,text='ok',bg='Powder Blue',command=lambda:(gameopen(a,b,c,l,tk))).grid(row=7,column=2) 1043 | def cheker(buttons,S): 1044 | try: 1045 | cheker_(buttons,S) 1046 | except: 1047 | pass 1048 | def cheker_(buttons,S): 1049 | global click,xxxxx,labeling1,labeling2,labeling3,labeling4,labeling5,labeling6,labeling7,labeling8 1050 | global SELECTED_KEY 1051 | global KEY,UNDO_1,UNDO_2,BUT1,BUT2,FG1,FG2 1052 | global aa,bwbw,posmoves,color3,color4,button65,button66,button67,button68,button69,button70,button71 1053 | pppp=buttons 1054 | aaa=pppp['text'] 1055 | bbb=pppp['bg'] 1056 | if S==' ' and click == True and buttons['text']!=' ': 1057 | aa[65]['command']=lambda:(pass_()) 1058 | if buttons['fg']==bwbw: 1059 | SELECTED_KEY=buttons['text'] 1060 | buttons['text'] = ' ' 1061 | KEY=buttons['fg'] 1062 | BUT1=buttons 1063 | FG1=KEY 1064 | moves(aaa,pppp) 1065 | labeling1=Label(main,text='rules',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13) 1066 | labeling2=Label(main,text='''REMOVE 1067 | COLOURERROR''',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13) 1068 | labeling3=Label(main,text='OPENGAME',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13) 1069 | labeling4=Label(main,text='UNDO',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13) 1070 | labeling5=Label(main,text='SHOWMOVES',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13) 1071 | labeling6=Label(main,text='CONFIGURE',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13) 1072 | labeling7=Label(main,text='SAVEGAME',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13) 1073 | labeling1.grid(row=1,column=9) 1074 | labeling2.grid(row=2,column=9) 1075 | labeling3.grid(row=3,column=9) 1076 | labeling4.grid(row=4,column=9) 1077 | labeling5.grid(row=5,column=9) 1078 | labelingeling6.grid(row=6,column=9) 1079 | labeling7.grid(row=7,column=9) 1080 | elif buttons['fg']!=bwbw : 1081 | showwarning('Warning','Others move') 1082 | 1083 | if S=='♟' and buttons['font']=='Arial 26 bold' and click==True: 1084 | labeling1['width']=0 1085 | labeling1['text']='' 1086 | labeling1.grid(row=1,column=10) 1087 | labeling2['width']=0 1088 | labeling2['text']='' 1089 | labeling2.grid(row=2,column=10) 1090 | labeling3['width']=0 1091 | labeling3['text']='' 1092 | labeling3.grid(row=3,column=10) 1093 | labeling4['width']=0 1094 | labeling4['text']='' 1095 | labeling4.grid(row=4,column=10) 1096 | labeling5['width']=0 1097 | labeling5['text']='' 1098 | labeling5.grid(row=5,column=10) 1099 | labeling6['width']=0 1100 | labeling6['text']='' 1101 | labeling6.grid(row=6,column=10) 1102 | labeling7['width']=0 1103 | labeling7['text']='' 1104 | labeling7.grid(row=7,column=10) 1105 | aa[65]['command']=lambda:(undo()) 1106 | SELECTED_KEY=' ' 1107 | a=buttons 1108 | opt=Tk() 1109 | button111 = Button(opt,text='♖ rook',fg= color5 ,font = ('Arial 15 bold'),bg= color1 ,height = 1 , width =10, command=lambda:new(button111,a,opt)) 1110 | button111 .grid(row= 0 , column= 1 ) 1111 | button211 = Button(opt,text='♞ knight',fg= color5 ,font = ('Arial 15 bold'),bg= color1 ,height = 1 , width =10, command=lambda:new(button211,a,opt)) 1112 | button211 .grid(row= 1 , column= 1 ) 1113 | button311 = Button(opt,text='♝ bishop',fg= color5 ,font = ('Arial 15 bold'),bg= color1 ,height = 1 , width =10, command=lambda:new(button311,a,opt)) 1114 | button311 .grid(row= 2 , column= 1) 1115 | button411 = Button(opt,text='♛ queen',fg= color5 ,font = ('Arial 15 bold'),bg= color1 ,height = 1 , width =10, command=lambda:new(button411,a,opt)) 1116 | button411 .grid(row= 3 , column= 1 ) 1117 | returntocolor() 1118 | opt.mainloop() 1119 | if click==True: 1120 | write() 1121 | invalidcheck(buttons,bbb,opt) 1122 | castlingperm(buttons) 1123 | returntocolor() 1124 | check(buttons) 1125 | elif S!=' ' and click ==True: 1126 | labeling1['width']=0 1127 | labeling1['text']='' 1128 | labeling1.grid(row=1,column=10) 1129 | labeling2['width']=0 1130 | labeling2['text']='' 1131 | labeling2.grid(row=2,column=10) 1132 | labeling3['width']=0 1133 | labeling3['text']='' 1134 | labeling3.grid(row=3,column=10) 1135 | labeling4['width']=0 1136 | labeling4['text']='' 1137 | labeling4.grid(row=4,column=10) 1138 | labeling5['width']=0 1139 | labeling5['text']='' 1140 | labeling5.grid(row=5,column=10) 1141 | labeling6['width']=0 1142 | labeling6['text']='' 1143 | labeling6.grid(row=6,column=10) 1144 | labeling7['width']=0 1145 | labeling7['text']='' 1146 | labeling7.grid(row=7,column=10) 1147 | aa[65]['command']=lambda:(undo()) 1148 | BUT2=buttons 1149 | FG2=buttons['fg'] 1150 | UNDO_1=SELECTED_KEY 1151 | UNDO_2=buttons['text'] 1152 | buttons['text']=SELECTED_KEY 1153 | SELECTED_KEY=' ' 1154 | buttons['fg']=KEY 1155 | files=open('moves.txt','a') 1156 | m='' 1157 | n='' 1158 | write() 1159 | invalidcheck(buttons,bbb) 1160 | castlingperm(buttons) 1161 | returntocolor() 1162 | check(buttons) 1163 | def main_fun(): 1164 | global special,x,x1,y,y1,aa,pos,pos1,SELECTED_KEY,KEY,color1,color2,color3,color4,color5,color6,color7,bwbw,showcolor,posmoves,eating,main,button1,button2,button3,button4,button5,button6,button7,button8,button9,button10,button11,button12,button13,button14,button15,button16,button17,button18,button19,button20,button21,button22,button23,button24,button25,button26,button27,button28,button29,button30,button31,button32,button33,button34,button35,button36,button37,button38,button39,button40,button41,button42,button43,button44,button45,button46,button47,button48,button49,button50,button51,button52,button53,button54,button55,button56,button57,button58,button59,button60,button61,button62,button63,button64,button65,button66,button67,button68,button69,button70,button71 1165 | files=open('configuration.txt','r') 1166 | l=files.readlines() 1167 | files.close() 1168 | color1=colorname(l[0]) 1169 | color2=colorname(l[1]) 1170 | color3=colorname(l[2]) 1171 | color4=colorname(l[3]) 1172 | color5=colorname(l[4]) 1173 | color6=colorname(l[5]) 1174 | color7=colorname(l[6]) 1175 | file=open('castling1.txt','w') 1176 | file.write('True__True\n') 1177 | file.close() 1178 | file=open('castling2.txt','w') 1179 | file.write('True__True\n') 1180 | file.close() 1181 | file=open('castling3.txt','w') 1182 | file.write('True__True\n') 1183 | file.close() 1184 | file=open('castling4.txt','w') 1185 | file.write('True__True\n') 1186 | file.close() 1187 | global click,labeling1,labeling2,labeling3,labeling4,labeling5,labeling6,labeling7,labeling8 1188 | click=True 1189 | main=Tk() 1190 | main.title(" SUDIP'S CHESS GAME") 1191 | main.config(bg='Powder Blue') 1192 | time=datetime.now() 1193 | x={'♞':'h','♖':'r','♝':'b','♟':'p','♚':'k','♛':'q',' ':' ','♜':'R'} 1194 | x1={'h':'♞','r':'♖','b':'♝','p':'♟','k':'♚','q':'♛',' ':' ','R':'♜'} 1195 | y={color4:'g',color1:'p',color3:'w'} 1196 | y1={'g':color4,'p':color1,'w':color3} 1197 | click = True 1198 | files=open('moves.txt','w') 1199 | files.write('''Rhbqkbhrpppppppp ppppppppRhbqkbhr 1200 | ggggggggggggggggppppppppppppppppppppppppppppwpppwwwwwwwwwwwwwwww\n''') 1201 | files.close() 1202 | posmoves=[] 1203 | special=[] 1204 | eating=[] 1205 | showcolor=False 1206 | SELECTED_KEY=' ' 1207 | KEY=' ' 1208 | bwbw=color3 1209 | buttons=StringVar() 1210 | button1 = Button(main,text='♜',fg= color4 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button1 ,SELECTED_KEY)) 1211 | button1 .grid(row= 0 , column= 1 ,) 1212 | button2 = Button(main,text='♞',fg= color4 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button2 ,SELECTED_KEY)) 1213 | button2 .grid(row= 0 , column= 2 ,) 1214 | button3 = Button(main,text='♝',fg= color4 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button3 ,SELECTED_KEY)) 1215 | button3 .grid(row= 0 , column= 3 ,) 1216 | button4 = Button(main,text='♛',fg= color4 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button4 ,SELECTED_KEY)) 1217 | button4 .grid(row= 0 , column= 4 ,) 1218 | button5 = Button(main,text='♚',fg= color4 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button5 ,SELECTED_KEY)) 1219 | button5 .grid(row= 0 , column= 5 ,) 1220 | button6 = Button(main,text='♝',fg= color4 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button6 ,SELECTED_KEY)) 1221 | button6 .grid(row= 0 , column= 6 ,) 1222 | button7 = Button(main,text='♞',fg= color4 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button7 ,SELECTED_KEY)) 1223 | button7 .grid(row= 0 , column= 7 ,) 1224 | button8 = Button(main,text='♖',fg= color4 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button8 ,SELECTED_KEY)) 1225 | button8 .grid(row= 0 , column= 8 ,) 1226 | button9 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button9 ,SELECTED_KEY)) 1227 | button9 .grid(row= 1 , column= 1 ,) 1228 | button10 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button10 ,SELECTED_KEY)) 1229 | button10 .grid(row= 1 , column= 2 ,) 1230 | button11 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button11 ,SELECTED_KEY)) 1231 | button11 .grid(row= 1 , column= 3 ,) 1232 | button12 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button12 ,SELECTED_KEY)) 1233 | button12 .grid(row= 1 , column= 4 ,) 1234 | button13 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button13 ,SELECTED_KEY)) 1235 | button13 .grid(row= 1 , column= 5 ,) 1236 | button14 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button14 ,SELECTED_KEY)) 1237 | button14 .grid(row= 1 , column= 6 ,) 1238 | button15 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button15 ,SELECTED_KEY)) 1239 | button15 .grid(row= 1 , column= 7 ,) 1240 | button16 = Button(main,text='♟',fg= color4 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button16 ,SELECTED_KEY)) 1241 | button16 .grid(row= 1 , column= 8 ,) 1242 | button17 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button17 ,SELECTED_KEY)) 1243 | button17 .grid(row= 2 , column= 1 ,) 1244 | button18 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button18 ,SELECTED_KEY)) 1245 | button18 .grid(row= 2 , column= 2 ,) 1246 | button19 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button19 ,SELECTED_KEY)) 1247 | button19 .grid(row= 2 , column= 3 ,) 1248 | button20 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button20 ,SELECTED_KEY)) 1249 | button20 .grid(row= 2 , column= 4 ,) 1250 | button21 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button21 ,SELECTED_KEY)) 1251 | button21 .grid(row= 2 , column= 5 ,) 1252 | button22 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button22 ,SELECTED_KEY)) 1253 | button22 .grid(row= 2 , column= 6 ,) 1254 | button23 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button23 ,SELECTED_KEY)) 1255 | button23 .grid(row= 2 , column= 7 ,) 1256 | button24 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button24 ,SELECTED_KEY)) 1257 | button24 .grid(row= 2 , column= 8 ,) 1258 | button25 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button25 ,SELECTED_KEY)) 1259 | button25 .grid(row= 3 , column= 1 ,) 1260 | button26 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button26 ,SELECTED_KEY)) 1261 | button26 .grid(row= 3 , column= 2 ,) 1262 | button27 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button27 ,SELECTED_KEY)) 1263 | button27 .grid(row= 3 , column= 3 ,) 1264 | button28 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button28 ,SELECTED_KEY)) 1265 | button28 .grid(row= 3 , column= 4 ,) 1266 | button29 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button29 ,SELECTED_KEY)) 1267 | button29 .grid(row= 3 , column= 5 ,) 1268 | button30 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button30 ,SELECTED_KEY)) 1269 | button30 .grid(row= 3 , column= 6 ,) 1270 | button31 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button31 ,SELECTED_KEY)) 1271 | button31 .grid(row= 3 , column= 7 ,) 1272 | button32 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button32 ,SELECTED_KEY)) 1273 | button32 .grid(row= 3 , column= 8 ,) 1274 | button33 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button33 ,SELECTED_KEY)) 1275 | button33 .grid(row= 4 , column= 1 ,) 1276 | button34 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button34 ,SELECTED_KEY)) 1277 | button34 .grid(row= 4 , column= 2 ,) 1278 | button35 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button35 ,SELECTED_KEY)) 1279 | button35 .grid(row= 4 , column= 3 ,) 1280 | button36 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button36 ,SELECTED_KEY)) 1281 | button36 .grid(row= 4 , column= 4 ,) 1282 | button37 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button37 ,SELECTED_KEY)) 1283 | button37 .grid(row= 4 , column= 5 ,) 1284 | button38 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button38 ,SELECTED_KEY)) 1285 | button38 .grid(row= 4 , column= 6 ,) 1286 | button39 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button39 ,SELECTED_KEY)) 1287 | button39 .grid(row= 4 , column= 7 ,) 1288 | button40 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button40 ,SELECTED_KEY)) 1289 | button40 .grid(row= 4 , column= 8 ,) 1290 | button41 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button41 ,SELECTED_KEY)) 1291 | button41 .grid(row= 5 , column= 1 ,) 1292 | button42 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button42 ,SELECTED_KEY)) 1293 | button42 .grid(row= 5 , column= 2 ,) 1294 | button43 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button43 ,SELECTED_KEY)) 1295 | button43 .grid(row= 5 , column= 3 ,) 1296 | button44 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button44 ,SELECTED_KEY)) 1297 | button44 .grid(row= 5 , column= 4 ,) 1298 | button45 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button45 ,SELECTED_KEY)) 1299 | button45 .grid(row= 5 , column= 5 ,) 1300 | button46 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button46 ,SELECTED_KEY)) 1301 | button46 .grid(row= 5 , column= 6 ,) 1302 | button47 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button47 ,SELECTED_KEY)) 1303 | button47 .grid(row= 5 , column= 7 ,) 1304 | button48 = Button(main,text=' ',fg= color1 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button48 ,SELECTED_KEY)) 1305 | button48 .grid(row= 5 , column= 8 ,) 1306 | button49 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button49 ,SELECTED_KEY)) 1307 | button49 .grid(row= 6 , column= 1 ,) 1308 | button50 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button50 ,SELECTED_KEY)) 1309 | button50 .grid(row= 6 , column= 2 ,) 1310 | button51 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button51 ,SELECTED_KEY)) 1311 | button51 .grid(row= 6 , column= 3 ,) 1312 | button52 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button52 ,SELECTED_KEY)) 1313 | button52 .grid(row= 6 , column= 4 ,) 1314 | button53 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button53 ,SELECTED_KEY)) 1315 | button53 .grid(row= 6 , column= 5 ,) 1316 | button54 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button54 ,SELECTED_KEY)) 1317 | button54 .grid(row= 6 , column= 6 ,) 1318 | button55 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button55 ,SELECTED_KEY)) 1319 | button55 .grid(row= 6 , column= 7 ,) 1320 | button56 = Button(main,text='♟',fg= color3 ,font = ('Times 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button56 ,SELECTED_KEY)) 1321 | button56 .grid(row= 6 , column= 8 ,) 1322 | button57 = Button(main,text='♜',fg= color3 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button57 ,SELECTED_KEY)) 1323 | button57 .grid(row= 7 , column= 1 ,) 1324 | button58 = Button(main,text='♞',fg= color3 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button58 ,SELECTED_KEY)) 1325 | button58 .grid(row= 7 , column= 2 ,) 1326 | button59 = Button(main,text='♝',fg= color3 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button59 ,SELECTED_KEY)) 1327 | button59 .grid(row= 7 , column= 3 ,) 1328 | button60 = Button(main,text='♛',fg= color3 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button60 ,SELECTED_KEY)) 1329 | button60 .grid(row= 7 , column= 4 ,) 1330 | button61 = Button(main,text='♚',fg= color3 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button61 ,SELECTED_KEY)) 1331 | button61 .grid(row= 7 , column= 5 ,) 1332 | button62 = Button(main,text='♝',fg= color3 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button62 ,SELECTED_KEY)) 1333 | button62 .grid(row= 7 , column= 6 ,) 1334 | button63 = Button(main,text='♞',fg= color3 ,font = ('Arial 26 bold'),bg= color2 ,height = 1 , width =3, command=lambda:cheker(button63 ,SELECTED_KEY)) 1335 | button63 .grid(row= 7 , column= 7 ,) 1336 | button64 = Button(main,text='♖',fg= color3 ,font = ('Arial 26 bold'),bg= color1 ,height = 1 , width =3, command=lambda:cheker(button64 ,SELECTED_KEY)) 1337 | button64 .grid(row= 7 , column= 8 ,) 1338 | button65 = Button(main,text='UNDO',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg= 'black' ,height = 3 , width =13, command=lambda:undo()) 1339 | button65 .grid(row= 4 , column=9 ,) 1340 | button66 = Button(main,text='SHOWMOVES',fg= 'Red',font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13, command=lambda:showonoff(button66)) 1341 | button66 .grid(row= 5 , column=9 ,) 1342 | button67 = Button(main,text='CONFIGURE',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13, command=lambda:configure()) 1343 | button67 .grid(row= 6 , column=9 ,) 1344 | button68 = Button(main,text='SAVEGAME',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13, command=lambda:save_open_game(button68)) 1345 | button68 .grid(row= 7, column=9 ,) 1346 | button69 = Button(main,text='OPENGAME',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13, command=lambda:save_open_game(button69)) 1347 | button69.grid(row= 3, column=9 ,) 1348 | button70 = Button(main,text='''REMOVE 1349 | COLOURERROR''',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13, command=lambda:colorerrorremover()) 1350 | button70.grid(row= 2, column=9 ,) 1351 | button71 = Button(main,text='rules',fg= 'Powder Blue' ,font = ('Arial 11 bold'),bg='black' ,height = 3 , width =13, command=lambda:rules()) 1352 | button71.grid(row= 1, column=9 ,) 1353 | Label(main,text='''***configuration 1354 | will lead to start 1355 | a new game''',bg='Powder blue').grid(row=0,column=9) 1356 | aa={65:button65,1 :button1 ,2 :button2 ,3 :button3 ,4 :button4 ,5 :button5 ,6 :button6 ,7 :button7 ,8 :button8 ,9 :button9 ,10 :button10 ,11 :button11 ,12 :button12 ,13 :button13 ,14 :button14 ,15 :button15 ,16 :button16 ,17 :button17 ,18 :button18 ,19 :button19 ,20 :button20 ,21 :button21 ,22 :button22 ,23 :button23 ,24 :button24 ,25 :button25 ,26 :button26 ,27 :button27 ,28 :button28 ,29 :button29 ,30 :button30 ,31 :button31 ,32 :button32 ,33 :button33 ,34 :button34 ,35 :button35 ,36 :button36 ,37 :button37 ,38 :button38 ,39 :button39 ,40 :button40 ,41 :button41 ,42 :button42 ,43 :button43 ,44 :button44 ,45 :button45 ,46 :button46 ,47 :button47 ,48 :button48 ,49 :button49 ,50 :button50 ,51 :button51 ,52 :button52 ,53 :button53 ,54 :button54 ,55 :button55 ,56 :button56 ,57 :button57 ,58 :button58 ,59 :button59 ,60 :button60 ,61 :button61 ,62 :button62 ,63 :button63 ,64 :button64} 1357 | pos={button1:[0,1],button2:[0,2],button3:[0,3],button4:[0,4],button5:[0,5],button6:[0,6],button7:[0,7],button8:[0,8],button9:[1,1],button10:[1,2],button11:[1,3],button12:[1,4],button13:[1,5],button14:[1,6],button15:[1,7],button16:[1,8],button17:[2,1],button18:[2,2],button19:[2,3],button20:[2,4],button21:[2,5],button22:[2,6],button23:[2,7],button24:[2,8],button25:[3,1],button26:[3,2],button27:[3,3],button28:[3,4],button29:[3,5],button30:[3,6],button31:[3,7],button32:[3,8],button33:[4,1],button34:[4,2],button35:[4,3],button36:[4,4],button37:[4,5],button38:[4,6],button39:[4,7],button40:[4,8],button41:[5,1],button42:[5,2],button43:[5,3],button44:[5,4],button45:[5,5],button46:[5,6],button47:[5,7],button48:[5,8],button49:[6,1],button50:[6,2],button51:[6,3],button52:[6,4],button53:[6,5],button54:[6,6],button55:[6,7],button56:[6,8],button57:[7,1],button58:[7,2],button59:[7,3],button60:[7,4],button61:[7,5],button62:[7,6],button63:[7,7],button64:[7,8]} 1358 | pos1={(0,1):button1,(0,2):button2,(0,3):button3,(0,4):button4,(0,5):button5,(0,6):button6,(0,7):button7,(0,8):button8,(1,1):button9,(1,2):button10,(1,3):button11,(1,4):button12,(1,5):button13,(1,6):button14,(1,7):button15,(1,8):button16,(2,1):button17,(2,2):button18,(2,3):button19,(2,4):button20,(2,5):button21,(2,6):button22,(2,7):button23,(2,8):button24,(3,1):button25,(3,2):button26,(3,3):button27,(3,4):button28,(3,5):button29,(3,6):button30,(3,7):button31,(3,8):button32,(4,1):button33,(4,2):button34,(4,3):button35,(4,4):button36,(4,5):button37,(4,6):button38,(4,7):button39,(4,8):button40,(5,1):button41,(5,2):button42,(5,3):button43,(5,4):button44,(5,5):button45,(5,6):button46,(5,7):button47,(5,8):button48,(6,1):button49,(6,2):button50,(6,3):button51,(6,4):button52,(6,5):button53,(6,6):button54,(6,7):button55,(6,8):button56,(7,1):button57,(7,2):button58,(7,3):button59,(7,4):button60,(7,5):button61,(7,6):button62,(7,7):button63,(7,8):button64} 1359 | main.mainloop() 1360 | time1=datetime.now() 1361 | t=time1-time 1362 | time=Tk() 1363 | showinfo('time',str(t)) 1364 | if click==True: 1365 | time.destroy() 1366 | 1367 | --------------------------------------------------------------------------------