HW3: removed use of signed integers in loops
This commit is contained in:
parent
1e1a51c9f6
commit
6b3e3a2da9
1 changed files with 9 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue