HW3: removed use of signed integers in loops

This commit is contained in:
Claudio Maggioni 2019-12-13 09:29:32 +01:00
parent 1e1a51c9f6
commit 6b3e3a2da9

View file

@ -199,12 +199,12 @@ void rook_positions(struct search_status* s, struct piece_position* p) {
unsigned c_cols = columns(s->chessboard);
unsigned c_rows = rows(s->chessboard);
for (int col = 0; col < c_cols; col++) {
for (unsigned col = 0; col < c_cols; col++) {
if (col == p->column) continue;
consider(s, col, p->row);
}
for (int row = 0; row < c_rows; row++) {
for (unsigned row = 0; row < c_rows; row++) {
if (row == p->row) continue;
consider(s, p->column, row);
}
@ -228,22 +228,22 @@ void knight_positions(struct search_status* s, struct piece_position* p) {
void bishop_positions(struct search_status* s, struct piece_position* p) {
unsigned cs = columns(s->chessboard);
unsigned rs = rows(s->chessboard);
int r, c;
unsigned r, c;
for (r = p->row - 1, c = p->column - 1; r >= 0 && c >= 0; r--, c--) {
consider(s, c, r);
for (r = p->row, c = p->column; r >= 1 && c >= 1; r--, c--) {
consider(s, c - 1, r - 1);
}
for (r = p->row + 1, c = p->column + 1; r < rs && c < cs; r++, c++) {
consider(s, c, r);
}
for (r = p->row - 1, c = p->column + 1; r >= 0 && c < cs; r--, c++) {
consider(s, c, r);
for (r = p->row, c = p->column + 1; r >= 1 && c < cs; r--, c++) {
consider(s, c, r - 1);
}
for (r = p->row + 1, c = p->column - 1; r < rs && c >= 0; r++, c--) {
consider(s, c, r);
for (r = p->row + 1, c = p->column; r < rs && c >= 1; r++, c--) {
consider(s, c - 1, r);
}
}