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
|
|
|
|
|
|
|
# Make Dist::Zilla happy. |
13
|
|
|
|
|
|
|
# ABSTRACT: Read chess opening books in polyglot format |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Chess::Opening::Book::ECO; |
16
|
|
|
|
|
|
|
$Chess::Opening::Book::ECO::VERSION = '0.3'; |
17
|
1
|
|
|
1
|
|
66632
|
use common::sense; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
55
|
use Fcntl qw(:seek); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
119
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
444
|
use Chess::Opening::ECO::Entry; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
8
|
use base 'Chess::Opening::Book'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
462
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
1
|
|
|
1
|
1
|
88
|
my $self = ''; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
15161
|
require Chess::Opening::ECO; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
22
|
bless \$self, shift; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub lookupFEN { |
34
|
2
|
|
|
2
|
1
|
2473
|
my ($self, $fen) = @_; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
18
|
my $positions = Chess::Opening::ECO->positions; |
37
|
|
|
|
|
|
|
|
38
|
2
|
50
|
|
|
|
141160
|
return if !exists $positions->{$fen}; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
7
|
my $position = $positions->{$fen}; |
41
|
|
|
|
|
|
|
my $entry = Chess::Opening::ECO::Entry->new( |
42
|
|
|
|
|
|
|
$fen, |
43
|
|
|
|
|
|
|
eco => $position->{eco}, |
44
|
2
|
|
|
|
|
34
|
variation => $position->{variation}); |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
7
|
foreach my $move (keys %{$position->{moves}}) { |
|
2
|
|
|
|
|
27
|
|
47
|
22
|
|
|
|
|
51
|
$entry->addMove(move => $move); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
60095
|
return $entry; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |