Skip to content

Instantly share code, notes, and snippets.

@NicolaM94
Last active February 5, 2023 01:39
Show Gist options
  • Save NicolaM94/75826a753105c3a3aecae4f6890b631a to your computer and use it in GitHub Desktop.
Save NicolaM94/75826a753105c3a3aecae4f6890b631a to your computer and use it in GitHub Desktop.
Solution to the algorithm
from pieces import *
blackKing = (5,8)
pawn = Pawn(7,2)
print("Pawn moves: ",pawn.possibleMoves())
for pos in pawn.possibleMoves():
if king == pos:
print("Check by the pawn!")
tower = Tower(5,3)
print("Tower moves: ",tower.possibleMoves())
for pos in tower.possibleMoves():
if king == pos:
print("Check by the tower!")
bishop = Bishop(2,7)
print("Bishop moves: ",bishop.possibleMoves())
for pos in bishop.possibleMoves():
if king == pos:
print("Check by the bishop!")
queen = Queen(3,2)
print("Queen moves: ",queen.possibleMoves())
for pos in queen.possibleMoves():
if king == pos:
print("Check by the queen!")
knight = Knight(6,6)
print("Knight moves: ",knight.possibleMoves())
for pos in knight.possibleMoves():
if king == pos:
print("Check by the knight!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment