1 /***************************************************************************
4 begin : mar ott 22 2002
5 copyright : (C) 2002-2005 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
21 Engine::incremental_sort_moves(Move
* mv
,int num_mv
)
25 for(int j
=0;j
<num_mv
;j
++)
33 SWITCH(mv
[0], mv
[bmvi
]);
37 Engine::sort_moves(Move
* m
,int num
)
46 for(int j
=0;j
<num
;j
+=2)
48 int n
= MIN(2, (num
-j
));
52 if(crin
[0].val
< crin
[1].val
)
53 SWITCH(crin
[0],crin
[1]);
59 for(int i
=2; i
<num
; i
<<=1)
65 for(int j
=0; j
<num
; j
+=segs
)
67 int n
= MIN(segs
, (num
-j
));
68 int n1
= i
; //first half
72 if(n2
<=0) //only one half? if so copy
80 int tmp1
= 0, tmp2
= n1
;
84 if(crin
[tmp1
].val
> crin
[tmp2
].val
)
86 *(crout
++) = crin
[tmp1
++];
89 for(int i
=tmp2
; i
<n
;i
++)
90 *(crout
++) = crin
[tmp2
++];
96 *(crout
++) = crin
[tmp2
++];
99 for(int i
=tmp1
; i
<n1
;i
++)
100 *(crout
++) = crin
[tmp1
++];
110 memcpy(m
,mv_tmp
,num
*sizeof(Move
));