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.6'; |
17
|
1
|
|
|
1
|
|
69420
|
use common::sense; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
63
|
use Fcntl qw(:seek); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
154
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
447
|
use Chess::Opening::ECO::Entry; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
8
|
use base 'Chess::Opening::Book'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
463
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
1
|
|
|
1
|
1
|
89
|
my $self = ''; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
12068
|
require Chess::Opening::ECO; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
25
|
bless \$self, shift; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub lookupFEN { |
34
|
3
|
|
|
3
|
1
|
3441
|
my ($self, $fen) = @_; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
28
|
my $positions = Chess::Opening::ECO->positions; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Ignore en passant field, half move count and move number for lookup so |
39
|
|
|
|
|
|
|
# that transpositions work correctly. |
40
|
3
|
|
|
|
|
230716
|
$fen =~ s/[ \011-\015]+[-a-h1-8]+[ \011-\015]+[0-9]+[ \011-\015]+[0-9]+[ \011-\015]*$//; |
41
|
|
|
|
|
|
|
|
42
|
3
|
50
|
|
|
|
25
|
return if !exists $positions->{$fen}; |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
10
|
my $position = $positions->{$fen}; |
45
|
|
|
|
|
|
|
my $entry = Chess::Opening::ECO::Entry->new( |
46
|
|
|
|
|
|
|
$fen, |
47
|
|
|
|
|
|
|
length => $position->{length}, |
48
|
|
|
|
|
|
|
significant => $position->{significant}, |
49
|
|
|
|
|
|
|
history => $position->{history}, |
50
|
|
|
|
|
|
|
eco => $position->{eco}, |
51
|
3
|
|
|
|
|
68
|
variation => $position->{variation}); |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
12
|
foreach my $move (keys %{$position->{moves}}) { |
|
3
|
|
|
|
|
25
|
|
54
|
23
|
|
|
|
|
58
|
$entry->addMove(move => $move); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
93406
|
return $entry; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |