-module(move). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([to_string/1]). -export_type([move/0]). -type move() :: {normal, position:position(), position:position(), gleam@option:option(piece:piece()), gleam@option:option(piece:piece())} | {castle, position:position(), position:position()} | {en_passant, position:position(), position:position()}. -spec to_string(move()) -> binary(). to_string(Move) -> From = position:to_string(erlang:element(2, Move)), To = position:to_string(erlang:element(3, Move)), Captured@2 = case Move of {normal, _, _, none, none} -> <<""/utf8>>; {normal, _, _, none, {some, Promotion}} -> <<" promoting to "/utf8, (piece:to_string(Promotion))/binary>>; {normal, _, _, {some, Captured}, none} -> <<" capturing "/utf8, (piece:to_string(Captured))/binary>>; {normal, _, _, {some, Captured@1}, {some, Promotion@1}} -> <<<<<<" capturing "/utf8, (piece:to_string(Captured@1))/binary>>/binary, " and promoting to "/utf8>>/binary, (piece:to_string(Promotion@1))/binary>>; {castle, _, _} -> <<" castling"/utf8>>; {en_passant, _, _} -> <<" en passant"/utf8>> end, <<<<<>/binary, To/binary>>/binary, Captured@2/binary>>.