ychess is a chess implementation written in nim.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
569 B

  1. from strutils import parseInt
  2. import rdstdin
  3. import ./chess
  4. proc runGame(): void =
  5. var game = initGame()
  6. game.echoBoard(game.toMove)
  7. while not game.isCheckmate(game.toMove) and not game.isStalemate(game.toMove):
  8. echo "Make a move"
  9. echo game.toMove
  10. var move = readLine(stdin)
  11. while not game.checkedMove(notationToMove(move, game.toMove)):
  12. move = readLine(stdin)
  13. game.echoBoard(game.toMove)
  14. if game.isCheckmate(game.toMove):
  15. echo $game.toMove & " was checkmated"
  16. if game.isStalemate(game.toMove):
  17. echo "Stalemate"
  18. runGame()