cheeplay

chess PGN replay in the terminal
git clone git://git.alexkarle.com.com/cheeplay
Log | Files | Refs | README | LICENSE

commit 982629b822f8419398ef17b56abf26a79f2acc14 (patch)
parent 0ffc26c270fc14ae309b41e1c3d4e5aee5b9adb1
Author: Alex Karle <alex@alexkarle.com>
Date:   Sat, 14 May 2022 17:09:42 -0400

Add initial board printout with unicode pieces

Woo! Checkit:

r !./cheeplay.scm

♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
■ □ ■ □ ■ □ ■ □
□ ■ □ ■ □ ■ □ ■
■ □ ■ □ ■ □ ■ □
□ ■ □ ■ □ ■ □ ■
♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜

Diffstat:
Acheeplay.scm | 46++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+), 0 deletions(-)

diff --git a/cheeplay.scm b/cheeplay.scm @@ -0,0 +1,46 @@ +#!/usr/local/bin/chicken-csi -ss +(import (chicken format)) + +(define B + '((BR BN BB BQ BK BB BN BR) + (BP BP BP BP BP BP BP BP) + (x x x x x x x x) + (x x x x x x x x) + (x x x x x x x x) + (x x x x x x x x) + (WP WP WP WP WP WP WP WP) + (WR WN WB WQ WK WB WN WR))) + +(define (fori lst proc) + ;; cdr's down 'lst', calling proc w each element and the index + (let loop ((i 0) (items lst)) + (if (null? items) + 'ok + (begin (proc (car items) i) (loop (+ i 1) (cdr items)))))) + +(define (prpiece x i j) + ; Print the unicode version of the piece + (display (format "~A " + (cond + ((eq? 'x x) (if (= 0 (modulo (+ i j) 2)) "■" "□")) + ((eq? 'BK x) "♔") + ((eq? 'BQ x) "♕") + ((eq? 'BR x) "♖") + ((eq? 'BB x) "♗") + ((eq? 'BN x) "♘") + ((eq? 'BP x) "♙") + ((eq? 'WK x) "♚") + ((eq? 'WQ x) "♛") + ((eq? 'WR x) "♜") + ((eq? 'WB x) "♝") + ((eq? 'WN x) "♞") + ((eq? 'WP x) "♟") + (else (error "bad piece!")))))) + +(define (prboard) + (fori B (lambda (row i) + (fori row (lambda (x j) (prpiece x i j))) + (newline)))) + +(define (main args) + (prboard))