Created
June 27, 2025 11:37
-
-
Save mogggen/d119a4c895f933be56e4ce82a8d3a24c to your computer and use it in GitHub Desktop.
v 0.1 - needs to fix bishop and queen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# all chess notation for legal moves in fide chess | |
pieces = 'B', 'K', 'N', 'Q', 'R' | |
# pawn moves | |
for c in range(ord('a'), ord('h') + 1): | |
continue | |
caputres = ['x' + x for x in (chr(c-1), chr(c+1)) if 'a' <= x <= 'h'] | |
caputres = [''] + caputres | |
for caputre in caputres: | |
for r in range(1, 9): | |
checks = [x for x in ('', '+', '#') if 1 < r < 8] | |
promotions = ['=' + piece for piece in pieces if (r == 1 or r == 8) and piece != 'K'] | |
for checkNProm in checks + promotions: | |
print(chr(c) + caputre + str(r) + checkNProm) | |
# piece moves | |
for piece in pieces: | |
for c in range(1, 9): | |
for r in range(1, 9): | |
if piece == 'K': | |
continue | |
print(piece + chr(c + ord('`')) + str(r)) | |
if piece == 'R': | |
continue | |
for i in range(1, 9): | |
for frm in enumerate(['', chr(i + ord('`')), str(i)]): | |
if frm[0] == 1 and frm[1] == chr(c + ord('`')): continue | |
if frm[0] == 2 and frm[1] == str(r): continue | |
for check in '', '+', '#': | |
if check == '' and frm[0] == 0: continue | |
print(piece + frm[1] + chr(c + ord('`')) + str(r) + check) | |
print(piece + frm[1] + 'x' + chr(c + ord('`')) + str(r) + check) | |
if piece == 'B': | |
diag = [(x , 8-x) for x in range(1, 8)] | |
for dist in range(-7, 8): | |
if dist == 0: continue | |
for check in '', '+', '#': | |
slopeUp = complex(c, r) + complex(dist, dist) | |
print(slopeUp) | |
if 1 <= slopeUp.real <= 8 and 1 <= slopeUp.imag <= 8: | |
if (int(slopeUp.real), int(slopeUp.imag)) in diag: | |
print(piece + chr(int(slopeUp.real) + ord('`')) + str(int(slopeUp.imag)) + chr(c + ord('`')) + str(r) + check) | |
print(piece + chr(int(slopeUp.real) + ord('`')) + str(int(slopeUp.imag)) + 'x' + chr(c + ord('`')) + str(r) + check) | |
slopeDown = complex(c, r) + complex(dist, -dist) | |
print(slopeDown) | |
if 1 <= slopeDown.real <= 8 and 1 <= slopeDown.imag <= 8: | |
if (int(slopeDown.real), int(slopeDown.imag)) in diag: | |
print(piece + chr(int(slopeDown.real) + ord('`')) + str(int(slopeDown.imag)) + chr(c + ord('`')) + str(r) + check) | |
print(piece + chr(int(slopeDown.real) + ord('`')) + str(int(slopeDown.imag)) + 'x' + chr(c + ord('`')) + str(r) + check) | |
print(piece + chr(c + ord('`')) + str(r) + check) | |
print(piece + 'x' + chr(c + ord('`')) + str(r) + check) | |
print("Bxh8", "Bxa8", "Bxa1", "Bxh1") | |
if pieces == 'Q': | |
pass | |
# castling | |
print("O-O") | |
print("O-O-O") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment