A Chess forum. ChessBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ChessBanter forum » Chess Newsgroups » rec.games.chess.computer (Computer Chess)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , ,

Generate a list of legal moves (command-line)



 
 
Thread Tools Display Modes
  #1  
Old March 5th 08, 02:07 AM posted to rec.games.chess.computer
whystopnow
external usenet poster
 
Posts: 4
Default Generate a list of legal moves (command-line)

I'm looking for a tool that will generate a list of legal moves based
on reading a list of moves made (like a .PGN). I'd like to interact
with it via command-line. Ideally, I'd just say "here's the file" and
it would spit out a list of legal moves - it would know whose turn
based on the moves so far.

I don't see a way to do this with crafty - there's no option to ask it
what the legal moves are, though I imagine it wouldn't be hard to edit
the code since it obviously has to generate such a list when it
plays. Just wondering if anyone knows of something that already does
this that is command-line friendly.

Thanks!
Ads
  #2  
Old March 5th 08, 04:11 AM posted to rec.games.chess.computer
johnny_t
external usenet poster
 
Posts: 129
Default Generate a list of legal moves (command-line)

whystopnow wrote:
I'm looking for a tool that will generate a list of legal moves based
on reading a list of moves made (like a .PGN). I'd like to interact
with it via command-line. Ideally, I'd just say "here's the file" and
it would spit out a list of legal moves - it would know whose turn
based on the moves so far.

I don't see a way to do this with crafty - there's no option to ask it
what the legal moves are, though I imagine it wouldn't be hard to edit
the code since it obviously has to generate such a list when it
plays. Just wondering if anyone knows of something that already does
this that is command-line friendly.

Thanks!


Many a program's move generator do not make a list of "legal" moves.
Legality is checked as needed and the branch simply gets pruned out, and
some programs don't even create all legal moves. Like Rybka arguably
the strongest program doesn't create bishop promotions for instance,
because the program would be overall WEAKER if it did.

There are a few projects out there that you should be able to modify to
do what you need.
  #3  
Old March 5th 08, 04:53 PM posted to rec.games.chess.computer
Martin Brown
external usenet poster
 
Posts: 615
Default Generate a list of legal moves (command-line)

In message , johnny_t
writes
whystopnow wrote:
I'm looking for a tool that will generate a list of legal moves based
on reading a list of moves made (like a .PGN). I'd like to interact
with it via command-line. Ideally, I'd just say "here's the file" and
it would spit out a list of legal moves - it would know whose turn
based on the moves so far.
I don't see a way to do this with crafty - there's no option to ask
it
what the legal moves are, though I imagine it wouldn't be hard to edit
the code since it obviously has to generate such a list when it
plays. Just wondering if anyone knows of something that already does
this that is command-line friendly.
Thanks!


Many a program's move generator do not make a list of "legal" moves.
Legality is checked as needed and the branch simply gets pruned out,
and some programs don't even create all legal moves. Like Rybka
arguably the strongest program doesn't create bishop promotions for
instance, because the program would be overall WEAKER if it did.


That isn't necessarily the case. It fails to find solutions to certain
types of constructed chess puzzle as a result of this decision. And I
can't see that generating the bishop promotion last rather than not at
all would be that much of a performance hit. I quickly constructed the
following position to test this out:

8/5P1k/4N1p1/6P1/8/p1p5/PpP5/1K6 w - - 0 1

Sure enough Shredder10 finds f8=B #14, so does Crafty19.19 but Rybka
ignores this solution preferring instead to win tediously by gradually
mopping up the pawns. It still thinks f8=N is its best bet even at ply
19.

I grant you that situations where under promotion to a bishop is needed
are exceedingly rare in match play, but they do sometimes occur in
puzzles.

There are a few projects out there that you should be able to modify to
do what you need.


Regards,
--
Martin Brown

--
Posted via a free Usenet account from http://www.teranews.com

  #4  
Old March 5th 08, 06:37 PM posted to rec.games.chess.computer
fhub
external usenet poster
 
Posts: 9
Default Generate a list of legal moves (command-line)


Martin Brown schrieb:

I grant you that situations where under promotion to a bishop is needed
are exceedingly rare in match play, but they do sometimes occur in
puzzles.


You´re right, but for seriously solving mate puzzle I won´t consider
using usual chess engine like Shredder, Crafty or any other. They
mostly don´t give correct (i.e. shortest) mates.

E.g. your position above is in fact #12 (and not #14 as Shredder
states):

ChestUCI Ver.5.0:
CPU: Celeron 400MHz
FEN: 8/5P1k/4N1p1/6P1/8/p1p5/PpP5/1K6 w - - (6+5)
Position-Analysis: C0/R0/K2/P1/X1 W:2/11
Parameters found in Database: #12; 03:26; 00:11 @ C6/R0/K5/P1/X4;
Search for Special-Mate [C6/R0/K5/P1/X4] in 12 ... (Hash=64MB)
12 00:12 366.608 66.655 +M12 1.f8B
Search completed ... (Time=11.76s)
Mate in 12 found ! (1 Solution in 00:11)
12/12 00:14 850.883 72.353 +M12 1.f8B Kh8 2.Bxa3 Kh7 3.Nf8+ Kg7
4.Bd6 Kf7 5.a3 Kg7 6.a4 Kf7 7.a5 Kg7 8.a6 Kf7 9.a7 Kg7 10.a8Q Kf7
11.Qa7+ Kg8 12.Qh7+
Best move: f8B, Value: +Mate in 12, Depth: 12/12, Time: 00:14,967,
850.883 Nodes, 72.353 N/sec

  #5  
Old March 5th 08, 10:45 PM posted to rec.games.chess.computer
johnny_t
external usenet poster
 
Posts: 129
Default Generate a list of legal moves (command-line)

Martin Brown wrote:
In message , johnny_t
writes
whystopnow wrote:
I'm looking for a tool that will generate a list of legal moves based
on reading a list of moves made (like a .PGN). I'd like to interact
with it via command-line. Ideally, I'd just say "here's the file" and
it would spit out a list of legal moves - it would know whose turn
based on the moves so far.
I don't see a way to do this with crafty - there's no option to ask it
what the legal moves are, though I imagine it wouldn't be hard to edit
the code since it obviously has to generate such a list when it
plays. Just wondering if anyone knows of something that already does
this that is command-line friendly.
Thanks!


Many a program's move generator do not make a list of "legal" moves.
Legality is checked as needed and the branch simply gets pruned out,
and some programs don't even create all legal moves. Like Rybka
arguably the strongest program doesn't create bishop promotions for
instance, because the program would be overall WEAKER if it did.


That isn't necessarily the case. It fails to find solutions to certain
types of constructed chess puzzle as a result of this decision. And I
can't see that generating the bishop promotion last rather than not at
all would be that much of a performance hit. I quickly constructed the
following position to test this out:

8/5P1k/4N1p1/6P1/8/p1p5/PpP5/1K6 w - - 0 1

Sure enough Shredder10 finds f8=B #14, so does Crafty19.19 but Rybka
ignores this solution preferring instead to win tediously by gradually
mopping up the pawns. It still thinks f8=N is its best bet even at ply 19.

I grant you that situations where under promotion to a bishop is needed
are exceedingly rare in match play, but they do sometimes occur in puzzles.

There are a few projects out there that you should be able to modify
to do what you need.


Regards,


What isn't necessarily the case? The reason that the engine would be
weaker, is that this rare case would have to be tested for with every
branch that has a pawn promotion. The time spent doing that is time
spent NOT looking at more useful things. Meaning that the play will be
weaker. But it will fail to find really rare cases that almost never
happen in real life or certain puzzles. Some think this is blasphemy
others think ELO spent in futile pursuits are wasted ELO.

  #6  
Old March 6th 08, 05:54 AM posted to rec.games.chess.computer
whystopnow
external usenet poster
 
Posts: 4
Default Generate a list of legal moves (command-line)

On Mar 4, 8:11 pm, johnny_t wrote:

There are a few projects out there that you should be able to modify to
do what you need.


Care to be slightly less mysterious?
  #7  
Old March 6th 08, 08:10 AM posted to rec.games.chess.computer
Martin Brown
external usenet poster
 
Posts: 615
Default Generate a list of legal moves (command-line)

In message
,
whystopnow writes
On Mar 4, 8:11 pm, johnny_t wrote:

There are a few projects out there that you should be able to modify to
do what you need.


Care to be slightly less mysterious?


There are several full source chess programs about but the first simple
short commented one that I spotted in a quick search was:

http://www.tckerrigan.com/Chess/TSCP

It says it observes all official rules - which is pretty good for the
size.

There is also source from the very old VAX Pascal chess program lurking
somewhere online although one dodgy version of the move generator I
recall would only allow pawn captures if the square in front of the pawn
was vacant! And it never allowed for under promotion at all.

Regards,
--
Martin Brown

--
Posted via a free Usenet account from http://www.teranews.com

  #8  
Old March 6th 08, 03:09 PM posted to rec.games.chess.computer
David Richerby
external usenet poster
 
Posts: 2,546
Default Generate a list of legal moves (command-line)

johnny_t wrote:
Martin Brown wrote:
johnny_t writes
Like Rybka arguably the strongest program doesn't create bishop
promotions for instance, because the program would be overall
WEAKER if it did.


That isn't necessarily the case. It fails to find solutions to
certain types of constructed chess puzzle as a result of this
decision. And I can't see that generating the bishop promotion last
rather than not at all would be that much of a performance hit.


What isn't necessarily the case? The reason that the engine would
be weaker, is that this rare case would have to be tested for with
every branch that has a pawn promotion. The time spent doing that
is time spent NOT looking at more useful things. Meaning that the
play will be weaker.


It is not necessarily the case that the engine will be weaker if it
considers bishop promotions. There are two competing factors in
ignoring bishop promotions:

1. in some very rare positions, the engine might fail to find the best
move (possibly the only winning move) because it doesn't even
consider it;

2. the rest of the search should go ever so slightly quicker, which
gives it a chance of finding a better move in nearly all positions
involving pawn promotion.

Taken in isolation, 1 makes the engine weaker and 2 makes it
stronger. But, of course, they're not taken in isolation -- both
effects occur and the question is which is the more significant. You
and Rybka's author believe that 2 is more significant than 1, which
means that ignoring the possibility of bishop promotions increases the
effective strength of the engine.

I would tend to agree with you but, without data, this is just our
supposition. It seems likely to me that disregarding bishop
promotions increases the effective strength of the engine but it isn't
*necessarily* the case.


Dave.

--
David Richerby Love Apple (TM): it's like a tasty
www.chiark.greenend.org.uk/~davidr/ fruit that you can share with someone
special!
  #9  
Old March 7th 08, 01:45 AM posted to rec.games.chess.computer
johnny_t
external usenet poster
 
Posts: 129
Default Generate a list of legal moves (command-line)

David Richerby wrote:
johnny_t wrote:
Martin Brown wrote:
johnny_t writes
Like Rybka arguably the strongest program doesn't create bishop
promotions for instance, because the program would be overall
WEAKER if it did.
That isn't necessarily the case. It fails to find solutions to
certain types of constructed chess puzzle as a result of this
decision. And I can't see that generating the bishop promotion last
rather than not at all would be that much of a performance hit.

What isn't necessarily the case? The reason that the engine would
be weaker, is that this rare case would have to be tested for with
every branch that has a pawn promotion. The time spent doing that
is time spent NOT looking at more useful things. Meaning that the
play will be weaker.


It is not necessarily the case that the engine will be weaker if it
considers bishop promotions. There are two competing factors in
ignoring bishop promotions:

1. in some very rare positions, the engine might fail to find the best
move (possibly the only winning move) because it doesn't even
consider it;

2. the rest of the search should go ever so slightly quicker, which
gives it a chance of finding a better move in nearly all positions
involving pawn promotion.

Taken in isolation, 1 makes the engine weaker and 2 makes it
stronger. But, of course, they're not taken in isolation -- both
effects occur and the question is which is the more significant. You
and Rybka's author believe that 2 is more significant than 1, which
means that ignoring the possibility of bishop promotions increases the
effective strength of the engine.

I would tend to agree with you but, without data, this is just our
supposition. It seems likely to me that disregarding bishop
promotions increases the effective strength of the engine but it isn't
*necessarily* the case.


It is a much longer, wordier version that I had compressed into the word
"rare".

But for sake of completeness we can further examine two words, weaker
and rare. And even "I believe".

First, I actually do not have a dog in this fight, the whole Rybka issue
was solely an "ad computerem" device. They are the strongest program,
they don't use all the legal moves. Trying to get an existing engine to
create a list of legal moves, while on surface seems obvious and easy
cuz aren't they "always" creating a move list in every position. And the
answer is suprisingly, most don't. They check legality by implication,
and some even ignore otherwise legal moves.

Next "rare." The Bishop case is very rare. Namely because the queen
also moves diagonally. It would be very rare that a queen would not
solve the case, and the bishop would. It has been seen in puzzles, but
not in the wild (though I am nowhere near an exhaustive expert on this).
What is also interesting, is that in certain parts of the game there
is loads and loads of possible pawn promotions and each of them would
have to be checked for bishop promotions, if you checked for such things
and it would hardly ever, especially in real life matter, and so such
things are simply pruned, by implication, from the search tree.

By weaker... Everytime you make a decision to prune a tree for whatever
reason may mask a deeper truth that would make the program stronger.
This is a truism of selective search. But you are making the assumption
that the remaining search realm will be more fruitful in the additional
depth you are allowed to search in this time frame. This can only be
determined by test. And so far Rybka has in any test passed. As it
goes forward, there will be advances in evaluation, selectivity and
speed of search. This will lead to new balances that will hopefully
lead to a stronger engine. This is true for all engines, and computer
"play" programs as well.

But for brevity, I just packaged all the above into "rare" compared to
the time lost. QED


Cheers
  #10  
Old March 7th 08, 01:49 AM posted to rec.games.chess.computer
johnny_t
external usenet poster
 
Posts: 129
Default Generate a list of legal moves (command-line)

whystopnow wrote:
On Mar 4, 8:11 pm, johnny_t wrote:

There are a few projects out there that you should be able to modify to
do what you need.


Care to be slightly less mysterious?


Mostly because I have a lack of personal experience with this precise
question. Not a mystery per se.

But with black candles and other enchantments I typed the words "Chess
Move Generator" into Google, and was amazed by the amount of material
nearly 100,000 citations. I think you may find after some clarification
here, that your answer may lie there.

Good Luck
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting knight moves foot rec.games.chess.misc (Chess General) 42 October 13th 07 01:12 PM
Goichberg's List samsloan rec.games.chess.play-by-email (Chess - Play by Email) 1 March 19th 07 09:09 PM
Goichberg's List samsloan alt.chess (Alternative Chess Group) 0 March 19th 07 07:25 PM
Positions with the most legal moves Martin Brown rec.games.chess.analysis (Chess Analysis) 30 November 20th 06 09:17 AM
Positions with the most legal moves Martin Brown rec.games.chess.computer (Computer Chess) 30 November 20th 06 09:17 AM


All times are GMT +1. The time now is 12:42 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Content Relevant URLs by vBSEO 2.4.0
Copyright ©2004-2008 ChessBanter, part of the NewsgroupBanter project.
The comments are property of their posters.
Ringtones - News - Credit Cards UK - Payday Loans - Buy Anything On eBay