On 11-May-2013 17:15:32 Ted Harding wrote:
On 11-May-2013 16:33:37 Srdjan Todorovic wrote:
On 11 May 2013 12:23, Ted Harding Ted.Harding@wlandres.net wrote:
I have a query. Is there some program which, given a Chess position and which player has the move, can output a (preferably numbered) list of the possible moves for that player in that position?
The only thing I can think of is having a look at 'gnuchess'. There's no useful man page, but the info page lists some stuff that could be of help.
I ran xboard (gnuchess frontend perhaps?) and it has some options that could be useful for setting up a board visually, and also seems to output a list of possible moves at each stage for the computer player.
This suggests that perhaps with enough tinkering, it could do what you want.
Regards, Srdjan
Thanks Srdjan (and thanks Anton Anyshon for comments also :)!
Thanks to your hint, I found out that if you enter "show moves" when it's your turn it will then list the available moves. Then you can pick.
The background to my query is that I've had the notion of playing against the computer using a program which selects its move more or less randomly (including completely randomly). For that I need a list of available moves to feed to the program each time it's the program's turn to move. And there it is! (Saves having to type them all in every time).
Non-uniform randomness could include giving different weights to possible moves by King, Queen, Rooks, Knights, Bishops, Pawns.
Anyway, that's a start, and thanks to you both! Ted.
Well, here's round 1!
One awkward feature of the gnuchess "show moves" command is that, if the player is in check (so something has to be done about that right away), the moves displayed include all those which would be legal if the player was not in check!
So I've had to subset the list to those which are legal given that the player is in check, when this occurs. Then I've used a random number generator to choose a random move. Here is the first game in this tournament:
Mymove is : b5# 0-1{computer wins as black} White(15) : show game White Black 1. e4 Nc6 2. Qh5 Nf6 3. c3 Nxh5 4. h3 Nf6 5. Be2 Nxe4 6. Bd1 e5 7. Bh5 Qh4 8. g4 Qxf2+ 9. Kd1 Qf1+ 10. Kc2 Nf2 11. Bxf7+ Kxf7 12. Nf3 Qd3+ 13. Kb3 Qd5+ 14. Ka4 b5#
Well, it's a start! (And it didn't take long, even using manual input).
Ted.
------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@wlandres.net Date: 11-May-2013 Time: 19:15:29 This message was sent by XFMail -------------------------------------------------