Skip Menu |

This queue is for tickets about the Chess CPAN distribution.

Report information
The Basics
Id: 28540
Status: open
Worked: 45 min
Priority: 0/
Queue: Chess

People
Owner: BJR [...] cpan.org
Requestors: vertolet666 [...] yandex.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: fixed bug in Chess::Game
Date: Sun, 29 Jul 2007 17:38:39 +0400
To: bug-Chess [...] rt.cpan.org
From: Семичёв Сергей <vertolet666 [...] yandex.ru>
I solved the bug as I reported before. You may see this report here http://rt.cpan.org/Ticket/Display.html?id=28538 The question is sub 'sub _player_has_moves' in Game.pm doesn't take into account legal moves of King. I have rewrited it like this: ------------------------------------------ sub _player_has_moves { my ($self, $player) = @_; my $obj_data = _get_game($$self); my $movelist = $obj_data->{movelist}; my $movenum = $movelist->get_move_num; my $king; if (exists($obj_data->{_player_has_moves}{$player}{$movenum})) { return $obj_data->{_player_has_moves}{$player}{$movenum}; } foreach my $piece (@{$obj_data->{pieces}{$player}}) { $king = ($piece->isa('Chess::Piece::King')) ? $piece : undef; if (defined $king) { my @rsqs = $king->reachable_squares(); my $csq = $king->get_current_square(); foreach my $sq (@rsqs) { if ($self->is_move_legal($csq, $sq)) { $obj_data->{_player_has_moves}{$player}{$movenum} = 1; return 1; } } }; next if ($piece->isa('Chess::Piece::King') or $piece->captured()); my @rsqs = $piece->reachable_squares(); my $csq = $piece->get_current_square(); foreach my $sq (@rsqs) { if ($self->is_move_legal($csq, $sq)) { $obj_data->{_player_has_moves}{$player}{$movenum} = 1; return 1; } } }; $obj_data->{_player_has_moves}{$player}{$movenum} = 0; return 0; } ------------------------------------------ Now this it works correctly. Best regards, Semichev Sergei.
From: BJR [...] cpan.org
On Sun Jul 29 09:39:14 2007, vertolet666@yandex.ru wrote: Show quoted text
> The question is sub 'sub _player_has_moves' in Game.pm doesn't take > into account legal moves of King.
Yes, that's the problem. Thanks for finding it :) I've uploaded Chess 0.6.2 with a fix and test for this bug. Please download the updated version rather than use this fix as mine is slightly different. Regards, Brian
This bug fixed in Chess version 0.6.2.
Subject: Re: [rt.cpan.org #28540] fixed bug in Chess::Game
Date: Sat, 04 Aug 2007 02:02:17 +0400
To: bug-Chess [...] rt.cpan.org
From: Семичёв Сергей <vertolet666 [...] yandex.ru>
Thanks for fixing bug. I've downloaded Chess 0.6.2. It works correctly. One more question. Are you planning to make a support of move conversion to PGN format? I mean, for example "g1-f3" to "Nf3". The inversed conversion "Nf3" to "g1-f3" is also actual. It would be a real bound forward. Best regards, Sergey. 31.07.07, 07:19, via RT <bug-Chess@rt.cpan.org>: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=28540 > > On Sun Jul 29 09:39:14 2007, vertolet666@yandex.ru wrote:
> > The question is sub 'sub _player_has_moves' in Game.pm doesn't take > > into account legal moves of King.
> Yes, that's the problem. Thanks for finding it :) I've uploaded Chess > 0.6.2 with a fix and test for this bug. Please download the updated > version rather than use this fix as mine is slightly different. > Regards, > Brian
Subject: Re: [rt.cpan.org #28540] fixed bug in Chess::Game
Date: Sat, 04 Aug 2007 00:27:39 -0600
To: bug-Chess [...] rt.cpan.org
From: Brian Richardson <brian [...] cubik.ca>
Семичёв Сергей via RT wrote: Show quoted text
> Thanks for fixing bug. I've downloaded Chess 0.6.2. It works correctly. > One more question. Are you planning to make a support of move conversion to PGN format? > I mean, for example "g1-f3" to "Nf3". > The inversed conversion "Nf3" to "g1-f3" is also actual. > It would be a real bound forward. >
There seem to already be some PGN projects in CPAN. I didn't really look at them as my interest was more in creating a programmable framework than importing/exporting PGN files. I've corresponded with Hugh S. Myers in the past on the perl-chess on Yahoo! Groups. His module is called Chess::PGN::Filter and can be found on CPAN. However, we have not collaborated in any way and the two projects are currently separate. Does Hugh's module suffice for your needs? I'd be interested in further development along those lines if CPAN is still deficient. Thanks for your interest, Brian
Subject: Re: [rt.cpan.org #28540] fixed bug in Chess::Game
Date: Sat, 04 Aug 2007 20:58:35 +0400
To: bug-Chess [...] rt.cpan.org
From: Семичёв Сергей <vertolet666 [...] yandex.ru>
I've learned all the modules concerning PGN. But none of them is what I need. Chess::PGN::Filter just converts from pure PGN to other format. But my aim is to get PGN having two squares. Your Chess module is great without doubt, but I suppose it's not completed for writing full-fledged chess programms in Perl. It's just my opinion. Forget about it :) 04.08.07, 10:28, Brian Richardson via RT <bug-Chess@rt.cpan.org>: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=28540 > > Семичёв Сергей via RT wrote:
> > Thanks for fixing bug. I've downloaded Chess 0.6.2. It works correctly. > > One more question. Are you planning to make a support of move conversion to PGN format? > > I mean, for example "g1-f3" to "Nf3". > > The inversed conversion "Nf3" to "g1-f3" is also actual. > > It would be a real bound forward. > >
> There seem to already be some PGN projects in CPAN. I didn't really look > at them as my interest was more in creating a programmable framework > than importing/exporting PGN files. I've corresponded with Hugh S. Myers > in the past on the perl-chess on Yahoo! Groups. His module is called > Chess::PGN::Filter and can be found on CPAN. However, we have not > collaborated in any way and the two projects are currently separate. > Does Hugh's module suffice for your needs? I'd be interested in further > development along those lines if CPAN is still deficient. > Thanks for your interest, > Brian