Author: Robert Hyatt
Date: 11:04:42 06/05/01
Go up one level in this thread
On June 05, 2001 at 11:29:41, Vincent Diepeveen wrote: >On June 05, 2001 at 11:14:29, Robert Hyatt wrote: > >>> >>>Now see what i get in beowulf. Instead of that in 2001 dudes program >>>better they program things out FOR EVERY PIECE. >>> >>>Even blackpawns and whitepawns are written out. >>> >>>Man such a student i would directly ship back. >>> >>> "Please make the code more general student, if you multiply a 2048 x 2048 >>> array you don't write out every multiplication either!". >>> >>>See here below the horror which i found in moves.c from beowulf project. >>> >>>How do you plan to let people learn from this code? >>> >>>They must learn to "write everything out"?? >>> >>>Please use a few for loops, even in bitboards you can do that, >>>or have you forgotten how loops work? >> >>Depends on the purpose. "unrolling" is a well-known way to speed up code. >>Compact does not always equal fast. Unrolling also eliminates some tests and >>branches, which is also good. > >I know, where did you hear me talk about getting it faster this generator? > >Dann Corbitt said this project was setup to let people learn how to write >their own chessprogram and to show how algorithms and implementing >a chessprogram in a nice manner works. > >So my comment on this piece of code is that it's not written in a way >where students learn from. > >They learn directly how to hack from this: "write everything out". > >In this piece of crap code i see everywhere: > > if (side == WHITE) > tsq = B->WhiteKnights; > else > tsq = B->BlackKnights; > >Note you can eliminate these branches, which speeds code up bigtime. A decent compiler won't use a branch there _anyway_. It will use a conditional move. > >In a test to generate for white a few million of times a list of moves >the branches will be correctly predicted, but normally spoken you get >a big misprediction there as then you generate for white and next >move for black, that hurts :) Just don't do a branch. :) > >Apart from that it's very ugly to see code like that, >i prefer more compact code to teach students and those who >want to start their own program! What they see is what they will do. I think it better to show how it _should_ be done, as opposed to teaching bad habits by showing how it could be done more concisely.
This page took 0.01 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.