Author: Uri Blass
Date: 15:23:38 09/02/01
Go up one level in this thread
On September 02, 2001 at 16:28:00, Odd Gunnar Malin wrote: >On September 02, 2001 at 12:29:40, Bruce Moreland wrote: > >>On September 02, 2001 at 07:29:12, Uri Blass wrote: >> >>>My question is when it is a good idea to define global variables >>>instead of local variables >> >>If your program is new, don't worry about this kind of nonsense yet. You >>probably have huge performance gains that can be made because functions that are >>simply inefficient, and you can probably get huge performance gains by ordering >>moves better and pruning crap out of your tree. >> > >I just want to mention an incident that happened to me the other night. >Be aware that I’m new to thinking of speed when programming (e.g. my first >chessengine). > >In my routine for finding attacked squares I looped through the board for >finding a piece with the right color. And when I find one I made moves for it >and looked at the 'to square' to see if it hit the square in question. > >So after I had lay down one night a lightning was hitting my head. Why not put a >bishop, rook etc. on the square in question and see if it hit it self. Of course >I had to try it once and it really made a speed up in the move generation of 2-3 >times. > >I'm sure this is known knowledge but as a stubborn I am I don’t want to study >other codes and only read text pages on chess programming. There even could be a >lot better methods to do the attack routine too. For me the programming it self >is the fun part and not the result. > >When I tested my new move generation routine in real play it was not giving me a >whole ply longer search, so when a 200-300% speedup gives such a result there >could not be much gained in fiddling with compiler options, local/global >variables etc. that gives under 10% speedup. I agree that the main speed improvement is by better algorithm and I still have ideas for better algorithm that were not used. I already did it and I know that there are still some ideas for doing the same thing faster but I doubt if I can get a speed improvement of 200-300% because it means that I can be significantly faster than Crafty in calculating perft 6 from the initial positon. Note that I used only plain C with optimize for speed by microsoft visual studio and no assembler tricks and no register variables. I also feel similiar about studying other codes and I only used similiar structure to TSCP and some macros from Crafty but my move generator is clearly not similiar to TSCP or crafty because I generate only legal moves. I guess the best is to live after >the KISS principle and run the code through a profiler only before it shall be >released. > >I would believe that this was not the last lightning that are hitting me in this >field. I agree that it is probably not the last idea that you are going to use in your program You can remember information from previous moves about attacked squares and not continue to generate the same information again and again. After every move you should update only the information that is changed. you can think about a move like e2-e4 as: 1)delete a pawn(e2 square) 2)add a pawn( e4 square) The last idea helped me to update the information because updating 1 and 2 at the same procedure seems to be too complicated for me. It is only a general idea and implementing it was not easy but it improved the speed of my move generator significantly. Uri
This page took 0 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.