1 /***************************************************************************
2 check.cpp - description
4 begin : Mon Sep 19 2005
5 copyright : (C) 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 ***************************************************************************/
22 Board::add_pawn(uint8_t col
, uint8_t where
)
24 LinePawns
*lp
= &line_pawns
[IS_WHITE(col
)][X(where
)];
25 int row
= IS_WHITE(col
) ? Y(where
) : 7-Y(where
);
29 ASSERT(lp
->count
< 7);
30 for(int i
=0;i
<lp
->count
;i
++)
31 ASSERT(lp
->pos
[i
] != row
);
34 while(f
&& (lp
->pos
[f
-1]>row
))
36 lp
->pos
[f
] = lp
->pos
[f
-1];
44 Board::del_pawn(uint8_t col
, uint8_t where
)
46 LinePawns
*lp
= &line_pawns
[IS_WHITE(col
)][X(where
)];
47 int row
= IS_WHITE(col
) ? Y(where
) : 7-Y(where
);
50 while(lp
->pos
[f
] != row
)
53 ASSERT(f
< lp
->count
);
58 lp
->pos
[f
-1] = lp
->pos
[f
];
64 Board::recalc_line_pawns()
68 line_pawns
[i
][j
].count
= 0;
77 if(PIECE_OF(data
[piece_pos
])==PAWN
)
78 add_pawn(data
[piece_pos
], piece_pos
);
84 Board::check_line_pawns()
89 LinePawns
*lp
= &line_pawns
[i
][j
];
90 for(int k
=0;k
<lp
->count
;k
++)
91 ASSERT(data
[POS_XY(j
, i
? lp
->pos
[k
] : 7-lp
->pos
[k
])] == (i
?WP
:BP
));
94 if(data
[POS_XY(j
, k
)] == (i
?WP
:BP
))
96 ASSERT(n
== lp
->count
);