Author: Tord Romstad
Date: 15:19:47 11/12/05
Go up one level in this thread
On November 12, 2005 at 05:48:14, Frederik Tack wrote: >I have to disagree on that one. It's better to take performance into account >from the beginning and make a good design for your program. If you only do it at >the end, you might find yourself unable to do the neccessary performance >improvements because your design doesn't allow it anymore. This reasoning is flawed. The risk that you wil ultimately be unable to do the necessary performance improvements because your design doesn't allow it is much *bigger* if you heavily emphasise low-level optimisation from the beginning. When the program is young, you don't know how it is going to evolve, and your ideas of which problems you will find and where the bottlenecks in the finished program will be are very likely to be incorrect. You will end up optimising your data structures for what you perceive as problems early on, and these early optimisations will come back to haunt you later when you face all the *really* difficult problems which you cannot imagine yet. The way to avoid painting yourself into a corner is to make an effort to make your low-level algorithms and data structures as simple and flexible as possible, even at the expense of some speed. Try to keep things fluid, and to make it easy to rip out the low-level code and replace it with something very different when the need arises. When you have a good search and eval, no serious bugs, and no very good idea about how to proceed, you can finally consider profiling your code and try to optimise some of the bottlenecks. Regarding your question at the beginning of the thread: I also use a pseudo-legal move generator (except when in check, when I use a special check evasion generator which only returns legal moves). However, I always check the moves for legality before I make them. Stalemate detection works as follows: int search( ... ) { ... int legal_moves = 0; move_list = generate_moves(); for(move in move_list) { if(move_is_legal(move)) { legal_moves++; make_move(move); search( ... ); unmake_move(move); } } if(legal_moves == 0) return STALEMATE_VALUE; ... } This works fine, and has no measurable cost whatsoever. A little flaw is that I cannot detect stalemates in the qsearch, but I can live with that. Tord
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.