line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! /bin/false |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright (C) 2019 Guido Flohr , |
4
|
|
|
|
|
|
|
# all rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# This program is free software. It comes without any warranty, to |
7
|
|
|
|
|
|
|
# the extent permitted by applicable law. You can redistribute it |
8
|
|
|
|
|
|
|
# and/or modify it under the terms of the Do What the Fuck You Want |
9
|
|
|
|
|
|
|
# to Public License, Version 2, as published by Sam Hocevar. See |
10
|
|
|
|
|
|
|
# http://www.wtfpl.net/ for more details. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Chess::Opening::Book::Entry; |
13
|
|
|
|
|
|
|
$Chess::Opening::Book::Entry::VERSION = '0.5'; |
14
|
3
|
|
|
3
|
|
24
|
use common::sense; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
28
|
|
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
191
|
use Locale::TextDomain 'com.cantanea.Chess-Opening'; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
17
|
|
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
1719
|
use Chess::Opening::Book::Move; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1322
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
114
|
|
|
114
|
1
|
105004
|
my ($class, $fen) = @_; |
22
|
|
|
|
|
|
|
|
23
|
114
|
|
|
|
|
543
|
bless { |
24
|
|
|
|
|
|
|
__fen => $fen, |
25
|
|
|
|
|
|
|
__moves => {}, |
26
|
|
|
|
|
|
|
__count => 0, |
27
|
|
|
|
|
|
|
}, $class; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub addMove { |
31
|
288
|
|
|
288
|
1
|
1378
|
my ($self, %args) = @_; |
32
|
|
|
|
|
|
|
|
33
|
288
|
50
|
|
|
|
639
|
if (!exists $args{move}) { |
34
|
0
|
|
|
|
|
0
|
require Carp; |
35
|
0
|
|
|
|
|
0
|
Carp::croak(__x("the named argument '{arg}' is required", |
36
|
|
|
|
|
|
|
arg => 'move')); |
37
|
|
|
|
|
|
|
} |
38
|
288
|
50
|
|
|
|
1089
|
if ($args{move} !~ /^[a-h][1-8][a-h][1-8][qrbn]?$/) { |
39
|
0
|
|
|
|
|
0
|
require Carp; |
40
|
0
|
|
|
|
|
0
|
Carp::croak(__x("invalid move '{move}'", |
41
|
|
|
|
|
|
|
move => '$args{move}')); |
42
|
|
|
|
|
|
|
} |
43
|
288
|
50
|
|
|
|
613
|
$args{count} = $args{weight} if exists $args{weight}; |
44
|
288
|
50
|
66
|
|
|
1664
|
if (exists $args{count} && $args{count} |
|
|
|
33
|
|
|
|
|
45
|
|
|
|
|
|
|
&& $args{count} !~ /^[1-9][0-9]*$/) { |
46
|
0
|
|
|
|
|
0
|
require Carp; |
47
|
0
|
|
|
|
|
0
|
Carp::croak(__"count must be a positive integer"); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
288
|
|
|
|
|
1075
|
my $move = Chess::Opening::Book::Move->new(%args); |
51
|
288
|
|
|
|
|
715
|
$self->{__moves}->{$args{move}} = $move; |
52
|
288
|
|
|
|
|
768
|
$self->{__counts} += $move->count; |
53
|
|
|
|
|
|
|
|
54
|
288
|
|
|
|
|
839
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
2
|
1
|
1638
|
sub fen { shift->{__fen} } |
58
|
2
|
|
|
2
|
1
|
874
|
sub moves { shift->{__moves} } |
59
|
2
|
|
|
2
|
1
|
1050
|
sub counts { shift->{__counts} } |
60
|
2
|
|
|
2
|
1
|
935
|
sub weights { shift->{__counts} } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |