A Crystal interface for data serialization in PAN format.
-
Add the dependency to your
shard.yml
:dependencies: pan: github: sashite/pan.cr
-
Run
shards install
Working with PAN can be very simple, for example:
require "pan"
# Emit a PAN string
actions = [
{52, 36, "♙", nil}
]
PAN.dump(*actions) # => "52,36,♙"
# Parse a PAN string
PAN.parse("52,36,♙") # => [{52, 36, "♙", nil}]
# Black castles on king-side
PAN.dump({60, 62, "♔", nil}, {63, 61, "♖", nil}) # => "60,62,♔;63,61,♖"
PAN.parse("60,62,♔;63,61,♖") # => [{60, 62, "♔", nil}, {63, 61, "♖", nil}]
# Promoting a chess pawn into a knight
PAN.dump({12, 4, "♘", nil}) # => "12,4,♘"
PAN.parse("12,4,♘") # => [{12, 4, "♘", nil}]
# Capturing a rook and promoting a shogi pawn
PAN.dump({33, 24, "+P", "R"}) # => "33,24,+P,R"
PAN.parse("33,24,+P,R") # => [{33, 24, "+P", "R"}]
# Dropping a shogi pawn
PAN.dump({nil, 42, "P", nil}) # => "*,42,P"
PAN.parse("*,42,P") # => [{nil, 42, "P", nil}]
# Capturing a white chess pawn en passant
PAN.dump({33, 32, "♟", nil}, {32, 40, "♟", nil}) # => "33,32,♟;32,40,♟"
PAN.parse("33,32,♟;32,40,♟") # => [{33, 32, "♟", nil}, {32, 40, "♟", nil}]
This library is available as open source under the terms of the MIT License.
This library is maintained by Sashite.
With some lines of code, let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!