magic in fruit

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: magic in fruit

Post by bob »

ethanara wrote::p

but seriously, if i do it like toga, how should i do it?
This is not a 30 minute job. Adding the magic code is trivial. But that is bitboard, which means everything _else_ inside fruit has to be converted from mailbox to bitboard. That is a challenge.

Or you might try the approach of another well-known attempt and take Crafty, and remove its evaluation and search, and replace it with that of fruit. But you still have to modify the parts of fruit you choose to take, but the rest of Crafty will work just fine.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: magic in fruit

Post by lucasart »

bob wrote:
ethanara wrote::p

but seriously, if i do it like toga, how should i do it?
This is not a 30 minute job. Adding the magic code is trivial. But that is bitboard, which means everything _else_ inside fruit has to be converted from mailbox to bitboard. That is a challenge.

Or you might try the approach of another well-known attempt and take Crafty, and remove its evaluation and search, and replace it with that of fruit. But you still have to modify the parts of fruit you choose to take, but the rest of Crafty will work just fine.
I agree, except on one point: magic are not trivial to generate. I remember spending countless hours on my own implementation of rotated bitboards, after I saw an article on the subject, and tried to figure it out by myself.
Marco Costalba has posted a *excellent quality* code on how to generate and use magic bitboards in this forum, and it doesn't look trivial at all...
The best way is probably to take Strelka's source code, since Strelka is a complete rewrite of Fruit with Bitboards (and some further improvements)
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: magic in fruit

Post by Desperado »

lucasart wrote:
bob wrote:
ethanara wrote::p

but seriously, if i do it like toga, how should i do it?
This is not a 30 minute job. Adding the magic code is trivial. But that is bitboard, which means everything _else_ inside fruit has to be converted from mailbox to bitboard. That is a challenge.

Or you might try the approach of another well-known attempt and take Crafty, and remove its evaluation and search, and replace it with that of fruit. But you still have to modify the parts of fruit you choose to take, but the rest of Crafty will work just fine.
I agree, except on one point: magic are not trivial to generate. I remember spending countless hours on my own implementation of rotated bitboards, after I saw an article on the subject, and tried to figure it out by myself.
Marco Costalba has posted a *excellent quality* code on how to generate and use magic bitboards in this forum, and it doesn't look trivial at all...
The best way is probably to take Strelka's source code, since Strelka is a complete rewrite of Fruit with Bitboards (and some further improvements)
Hi Lucas,

i dont think Strelka is a good place to start with bitboards.
Mainly 2 reasons i have in mind.
- too many hard coded numbers,
too many expressions using hard coded numbers.
- weak documentaion (at least if you cannot read russian language or whatever it is)

While experienced (bitboard) chess programmers _may_ read it like daily newspaper,
a beginner will hardly read it in that way. So for didactical purposes it is
certainly not the first (best) choice.

have a nice day.

Michael
wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 5:03 pm
Location: British Columbia, Canada

Re: magic in fruit

Post by wgarvin »

lucasart wrote:... Strelka is a complete rewrite of Fruit with Bitboards (and some further improvements)
I know some people say that, and it might be indirectly true. However, I believe Strelka is actually a reverse-engineered and slightly-modified version of Rybka. Any structural similarities between Fruit and Strelka 2.0 (the only version I've looked at) are due to the Fruit code being plagarised by Rybka. Osipov may have known or suspected this, and used Fruit as a guide to help understand the disassembly, I don't know. I did study disassemblies of the eval and search of Rybka 1.0 Beta, and found that Strelka 2.0 matched them very closely. There are various small changes but they are both bitboard engines, and they match too closely to only be linked through a common ancestor which uses a mailbox board representation, not bitboards. I believe Strelka is a direct clone of Rybka, just as Vas said at that time.
wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 5:03 pm
Location: British Columbia, Canada

Re: magic in fruit

Post by wgarvin »

A thread mentioned in another post, that seems relevant to Strelka's origins:
http://www.talkchess.com/forum/viewtopic.php?p=390971