MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / notResultsInCheck

Function notResultsInCheck

projects/Chess/main.py:522–564  ·  view source on GitHub ↗
(x1, y1, x2, y2)

Source from the content-addressed store, hash-verified

520
521
522def notResultsInCheck(x1, y1, x2, y2):
523 global grid, validMovegen
524 grid2 = []
525 for i in range(8):
526 grid2.append([])
527 for j in range(8):
528 grid2[i].append(grid[i][j])
529 grid2[x2][y2] = grid[x1][y1]
530 grid2[x1][y1] = 0
531
532 white = grid2[x2][y2].isupper()
533 kingX, kingY = None, None
534 pos = []
535
536 for i in range(8):
537 for j in range(8):
538 if white:
539 if grid2[i][j] == "K":
540 kingX = i
541 kingY = j
542 else:
543 if grid2[i][j] == "k":
544 kingX = i
545 kingY = j
546 if grid2[i][j] != 0:
547 if white:
548 if grid2[i][j].islower():
549 pos.append([i, j])
550 else:
551 if grid2[i][j].isupper():
552 pos.append([i, j])
553
554 vMoves = []
555 for i in range(len(pos)):
556 vMoves.append(validMoveGen.generateValidMoves(pos[i][0], pos[i][1], grid2))
557
558 for i in range(len(vMoves)):
559 i1 = vMoves[i]
560 for j in range(len(i1)):
561 j1 = i1[j]
562 if kingX == j1[0] and kingY == j1[1]:
563 return False
564 return True
565
566
567# define Event object

Callers 1

eventMethod · 0.85

Calls 1

generateValidMovesMethod · 0.80

Tested by

no test coverage detected