by Uri Blass » 19 Oct 2004, 01:37
Hi Reinhard,
Your result encourage me to think again about speed imprvement in my move generator.
I have some questions about your move generator.
1)Do you have some list of pawn captures that is updated incrementally?
I think that it is a waste of time to check if every pawn can capture to the left side and to the right side after every move and it is better to have some table for that purpose but it is possible that my intuition is misleading and the only way for me seems to be to check and try it.
I think about the following ways to save checks if square are empty:
1)having array pawninfo[64] when
pawninfo[sq]&1 if pawn at square sq can move 1 step forward.
pawninfo[sq]&2 if pawn at square sq can move 2 steps forward.
pawninfo[sq]&4 if pawn at square sq can capture to the right side.
pawninfo[sq]&8 if pawn at square sq can capture to the left side.
This is not exactly a table of captures and I still need to check for every pawn if (pawninfo[sq]&12) but it seems faster than what I do now to find if pawn can capture when I do special check for every pawn if it can capture to the right side and if it can capture to the left side.
Another idea is to have a list of captures
pawncapture[16][2] that is updated incrementally after every move is an option but maybe it is faster to have linked list for that purpose and not array.
seeing some source code for solving a similiar problem(not has to be inside a chess program) may be productive for me.
2)Did you consider to have list of moves for both sides that is updated after every move(The idea is that you do not need to generate again and again moves like a3 and if a3 is on the list of moves in the initial position
then it is also in the list after 1.e4 e5
Example in the opening position you generate list of 20 moves of white and black.
After 1.e4 you do the following steps:
1)adding e5,Be2,Bd3,Bc4,Bb5 Ba6,Qe2,Qf3,Qg4,Qh5,Ke2,Ne2 to the list of moves of white
2)deleting e3,e4 from the list of moves of white
3)Not changing the moves of black.
After 1...e5 you do the following steps:
1)adding Be7,Bd6,Bc5,Bb4,Ba3,Qe7,Qf6,Qg5,Qh4,Ke7,Ne7 to the list of black moves.
2)deleting e6,e5 from the list of black moves
3)deleting e5 from the list of white moves.
I believe that implementing this idea without bugs is hard and I even did not try to do it but it is possible that somebody can come with faster move generator if (s)he implement it.