Moderator: Andres Valverde
Pradu wrote:Here's my order of generating moves:
1) Promotions
2) Castling
3) Pawn Moves
4) Knight Moves
5) Bishop Moves
6) Rook Moves
7) Queen Moves
8) King Moves
I generate moves all at once and then order them. I also do not see how moves can be generated one by one and played in the order of the move generation (except for mabe the hashed move).
mathmoi wrote:You do not order captures before normals moves ? I think this greatly reduce your branching factor.
Andrew Fan wrote:Partial move ordering can be done by using the followings:
1.Move in the hashtable or in the PV.
2.Promote to piece value.
3.Value of captured piece - value of capturing piece.
4.Piece square table delta value for the move.
5.Killers and history bonus.
I try hashed moves first and only generate moves when no cut-off occurs.
Normal move generation order:
Captures and promotions
Non-captures
Special move generation:
Check evasion
Good luck with you engine.
Andrew
Try the hash move
If (no cutoffs occurs) then
Generates all other moves and order them
endif
Thomas Mayer wrote:you can update a move list incrementally.
Pradu wrote:Thomas Mayer wrote:you can update a move list incrementally.
Won't the overhead of incrementing be more than the generation of new moves if using bitboards?
Matthias Hartwich wrote:The moves are generated incrementally in small chunks.
mathmoi wrote:Pradu wrote:Thomas Mayer wrote:you can update a move list incrementally.
Won't the overhead of incrementing be more than the generation of new moves if using bitboards?
[...]
One avantage of a bitboard-based-incremental move generator is that it is easy and fast to find for wich pieces the moves need to be regenerated. Say you move a piece from c1 to c4. You must regenerates the moves for:
1) That piece
2) All the pice attacking c1
3) All the piece attacking c4
FEN: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
+-*--b--c--d--*--f--g--*-+ MS Vis.Studio C++ Vers. 13.10
8 |[r][n][b][q][k][b][n][r]| (Compilation: Aug 11 2005)
7 |[p][p][p][p][p][p][p][p]|
6 | ::: ::: ::: :::| Perft Testseries
5 |::: ::: ::: ::: |
4 | ::: ::: ::: :::| (without caching)
3 |::: ::: ::: ::: |
2 |<P><P><P><P><P><P><P><P>| Smirf Test No.: 00
1 |<R><N><B><Q><K><B><N><R>|
=>+-*--b--c--d--*--f--g--*-+ Break Time 5.0 Sec.
Ply Nodes all (x) (e.p.) all (+) (#) Prom. Castl. Sec.
-------------------------------------------------------------------------------
1 20 0 0 0 0 0 0 0
2 400 0 0 0 0 0 0 0
3 8902 34 0 12 0 0 0 0
4 197281 1576 0 469 8 0 0 0
5 4865609 82719 258 27351 347 0 0 0.2
6 119060324 2812008 5248 809099 10828 0 0 4.8
7 3195901860 108329926 319617 33103848 435767 0 883453 126.1
-------------------------------------------------------------------------------
FEN: r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 25
+-*--b--c--d--*--f--g--*-+ MS Vis.Studio C++ Vers. 13.10
8 |[r]::: :::[k]::: [r]| (Compilation: Aug 11 2005)
7 |[p] [p][p][q][p][b] |
6 |[b][n] :::[p][n][p]:::| Perft Testseries
5 |::: :::<P><N> ::: |
4 | [p] :::<P>::: :::| (without caching)
3 |::: <N> :::<Q>:::[p]|
2 |<P><P><P><B><B><P><P><P>| Smirf Test No.: 01
1 |<R> ::: <K> :::<R>|
=>+-*--b--c--d--*--f--g--*-+ Break Time 5.0 Sec.
Ply Nodes all (x) (e.p.) all (+) (#) Prom. Castl. Sec.
-------------------------------------------------------------------------------
1 48 8 0 0 0 0 2 0
2 2039 351 1 3 0 0 91 0
3 97862 17102 45 993 1 0 3162 0
4 4085603 757163 1929 25523 43 15172 128013 0.2
5 193690690 35043416 73365 3309887 30171 8392 4993637 8.2
-------------------------------------------------------------------------------
Sven Sch?le wrote:mathmoi wrote:Pradu wrote:Thomas Mayer wrote:you can update a move list incrementally.
Won't the overhead of incrementing be more than the generation of new moves if using bitboards?
[...]
One avantage of a bitboard-based-incremental move generator is that it is easy and fast to find for wich pieces the moves need to be regenerated. Say you move a piece from c1 to c4. You must regenerates the moves for:
1) That piece
2) All the pice attacking c1
3) All the piece attacking c4
Hi Mathieu,
you will probably maintain one move list per colour. Each move may affect both move lists then, concerning your items 2+3. Furthermore, there are several special nontrivial cases, think of e.p., promotion or castling stuff.
Sven Sch?le wrote:Then, checks are problematic, most replies become illegal but two plies later the same moves are legal again very often. Recalculate, or save the previously legal moves when detecting check? Pinning a piece is similar.
Sven Sch?le wrote:Also consider the effort for restoring the move list when unmaking a move.
Incrementally updating a move list may indeed require some tricky data structures to allow for efficient insert/remove operations. Instead of one linear move list, you might want to maintain a list of move lists, one per piece (consider capturing a queen, or moving a piece which was attacked by a rook and a bishop and defended by two rooks; much removing and inserting to be done).
Bitboards may help here partially but AFAIK you need a move list, too (please correct me if I'm wrong because I'm not an experienced bitboarder).
In my opinion all this produces a very large overhead, so I doubt whether this could be an improvement.
Sven Sch?le wrote:But I do not intend to discourage you, nor anyone else who is interested in trying incremental move generation. Feel free to show why I'm wrong!
Sven
roce: setboard rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
roce: disp
8 {r}{n}{b}{q}{k}{b}{n}{r}
7 {p}{p}{p}{p}{p}{p}{p}{p}
6 . . . . . . . .
5 . . . . . . . .
4 . . . . . . . .
3 . . . . . . . .
2 [P][P][P][P][P][P][P][P]
1 [R][N][B][Q][K][B][N][R]
a b c d e f g h
ply: 1, turn: white
castling: QKqk
white king: e1 black king: e8
roce: perft 5
Perft (5): 4865609 nodes, Time: 0.407 s
roce: perft 6
Perft (6): 119060324 nodes, Time: 11.093 s
roce: setboard r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
0 25
roce: disp
8 {r} . . . {k} . . {r}
7 {p} . {p}{p}{q}{p}{b} .
6 {b}{n} . . {p}{n}{p} .
5 . . . [P][N] . . .
4 . {p} . . [P] . . .
3 . . [N] . . [Q] . {p}
2 [P][P][P][B][B][P][P][P]
1 [R] . . . [K] . . [R]
a b c d e f g h
ply: 25, turn: white
castling: QKqk
white king: e1 black king: e8
roce: perft 4
Perft (4): 4085603 nodes, Time: 0.281 s
roce: perft 5
Perft (5): 193690690 nodes, Time: 12.813 s
roce: analyze
depth nodes score time best line
1 20 0.25 0.00 d2d4
2 170 0.00 0.00 d2d4 e7e5
3 1773 0.25 0.00 d2d4 d7d5 e2e4
4 18282 0.00 0.01 b1c3 e7e5 e2e4 d7d5
5 238934 1.05 0.23 e2e4 b8c6 f1b5 c6d4 b5d7
6 2123001 -0.78 2.25 b2b3 e7e6 c1b2 d8h4 b1c3 h4f2
7 15885018 0.99 17.27 b1c3 e7e6 e2e4 f8b4 c3b5 g8f6 b5c7
[quote][/quote]
Roman Hartmann wrote:creating all legal moves in a certain position
they are created in a certain order:
--castling moves
--king moves
--knight moves
--pawn moves (includes ep, promotion moves)
--rook moves
--bishop moves
--queen moves
-sorting them according to square tables+material gain
Return to Programming and Technical Discussions
Users browsing this forum: No registered users and 43 guests