X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=Position.pm;h=b847d101162a51a23d6bd7b5ff758a9a66a98930;hp=6b772a67b82fafe4bcffb5b44a09849a8fb49eeb;hb=a8b50dfb8117c5495784ae330ccefa8db2355e83;hpb=c555a037520769fe44012c04b4fe668eb1849b0a diff --git a/Position.pm b/Position.pm index 6b772a6..b847d10 100644 --- a/Position.pm +++ b/Position.pm @@ -127,6 +127,11 @@ sub parse_pretty_move { return $pos->{'board'}->parse_pretty_move($move, $pos->{'toplay'}); } +sub num_pieces { + my ($pos) = @_; + return $pos->{'board'}->num_pieces(); +} + # Returns a new Position object. sub make_move { my ($pos, $from_row, $from_col, $to_row, $to_col, $promo) = @_; @@ -190,6 +195,16 @@ sub make_move { return bless $np; } +# Returns a new Position object, and the parsed UCI move. +sub make_pretty_move { + my ($pos, $move) = @_; + + my ($from_row, $from_col, $to_row, $to_col, $promo) = $pos->parse_pretty_move($move); + my $uci_move = Board::move_to_uci_notation($from_row, $from_col, $to_row, $to_col, $promo); + $pos = $pos->make_move($from_row, $from_col, $to_row, $to_col, $promo); + return ($pos, $uci_move); +} + sub _pos_to_square { my ($row, $col) = @_; return sprintf("%c%d", ord('a') + $col, 8 - $row);