I wonder whether there's an open source chess engine that plays totally random moves. If not, how hard would it be to transform Stockfish into such an engine?
I ask this because I have something in mind to do with such an engine, of course.
I'd prefer open source because I could know which pseudo random number generator the engine uses and I'd prefer one that's "good".
Thanks!
Open source engine random moves
Moderators: hgm, Rebel, chrisw
-
- Posts: 4889
- Joined: Thu Mar 09, 2006 6:34 am
- Location: Pen Argyl, Pennsylvania
Re: Open source engine random moves
Search Brutus random or BrustusRND. Plays random moves and CCRL tested it and its rating was about 210. Not sure if it's open source.
-
- Posts: 265
- Joined: Sat Feb 22, 2014 8:37 pm
Re: Open source engine random moves
Thanks, I just downloaded it. Apparently only works under windows (ouch), and yes it seems to be closed source so I don't know how good or bad the prng is.MikeB wrote:Search Brutus random or BrustusRND. Plays random moves and CCRL tested it and its rating was about 210. Not sure if it's open source.
Regarding Stockfish option, should I modify search.cpp, abort the search early and return any legal move randomly? Or do I need to tweak several files?
-
- Posts: 286
- Joined: Mon Jun 03, 2013 7:05 pm
- Location: Italy
Re: Open source engine random moves
RandomFish sounds good
Simply generate all moves at the root, generate one random number between 0 and N-1 (where N is the number of moves the movegen generates) and play it, totally skipping search.
Is that enough?
Simply generate all moves at the root, generate one random number between 0 and N-1 (where N is the number of moves the movegen generates) and play it, totally skipping search.
Is that enough?
-
- Posts: 265
- Joined: Sat Feb 22, 2014 8:37 pm
Re: Open source engine random moves
Is this code in movegen.cpp? I'm not sure where exactly.xmas79 wrote:RandomFish sounds good
Simply generate all moves at the root, generate one random number between 0 and N-1 (where N is the number of moves the movegen generates) and play it, totally skipping search.
Is that enough?
Do I need to modify search.cpp and write somewhere "return Rootmoves" where i is a random number between 0 and N-1 where N is the number of legal moves for a given position?
Edit: I need it to be aware of the 50 moves draw rule.
Edit2: Nevermind about that last sentence, I suppose cutechess will adjudicate games with that rule.
-
- Posts: 265
- Joined: Sat Feb 22, 2014 8:37 pm
Re: Open source engine random moves
I don't see where in the code SF returns its move.
-
- Posts: 265
- Joined: Sat Feb 22, 2014 8:37 pm
Re: Open source engine random moves
I think I made it. I'll make my test.
-
- Posts: 265
- Joined: Sat Feb 22, 2014 8:37 pm
Re: Open source engine random moves
Unfortunately my SF version doesn't play entirely randomly. I've made a few changes in search.cpp, like best = rootMoves[j].pv[0]; where j is a random int between 0 and the number of legal moves for the root position.
Here's the code of the file I modified: http://pastebin.com/zENrhpgM, with my changes. I'd appreciate if someone could fix it and make SF play randomly and then post the code either in github or pastebin.
I've ran a match of about 60 games between 2 such modified SF and got around 10 wins which is way too many. That's why I believe it doesn't play entirely randomly.
Here's the code of the file I modified: http://pastebin.com/zENrhpgM, with my changes. I'd appreciate if someone could fix it and make SF play randomly and then post the code either in github or pastebin.
I've ran a match of about 60 games between 2 such modified SF and got around 10 wins which is way too many. That's why I believe it doesn't play entirely randomly.
-
- Posts: 10948
- Joined: Wed Jul 26, 2006 10:21 pm
- Full name: Kai Laskos
Re: Open source engine random moves
Why? Have a look at:Isaac wrote: I've ran a match of about 60 games between 2 such modified SF and got around 10 wins which is way too many. That's why I believe it doesn't play entirely randomly.
http://www.talkchess.com/forum/viewtopic.php?t=40193
"One billion random games generated with a single thread on a 3.2 GHz Intel Core i3:
Code: Select all
[] rgstat 1000000000
Summary:
Checkmate 153,023,351 (0.153023)
FiftyMoves 199,868,185 (0.199868)
Insufficient 560,510,846 (0.560511)
Repetition 25,427,172 (0.0254272)
Stalemate 61,170,446 (0.0611704)
Count: 1,000,000,000 Elapsed: 159960 (6251.57 Hz / 0.00015996 s)
Could you share a Windows binary?
-
- Posts: 931
- Joined: Tue Mar 09, 2010 3:46 pm
- Location: New York
- Full name: Álvaro Begué (RuyDos)
Re: Open source engine random moves
I made a random-moving version of my engine and I removed most of the needless parts. What's a good place for me to post it?
EDIT: Let's try DropBox. https://www.dropbox.com/sh/1o3ymy403yy8 ... 0-MUa?dl=0
EDIT: Let's try DropBox. https://www.dropbox.com/sh/1o3ymy403yy8 ... 0-MUa?dl=0