pan.cr
Portable Action Notation
A Crystal interface for data serialization in PAN format.
Installation
-
Add the dependency to your
shard.yml
:dependencies: pan: github: sashite/pan.cr
-
Run
shards install
Usage
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}]
Examples
# 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}]
License
This library is available as open source under the terms of the MIT License.
About Sashite
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!
Repository
pan.cr
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- almost 4 years ago
- July 3, 2020
License
MIT License
Links
Synced at
Thu, 02 May 2024 22:59:23 GMT
Languages