|
|
|
@ -1,24 +1,21 @@
|
|
|
|
|
#include "constants.h"
|
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// TAKE
|
|
|
|
|
void _push_if_valid_pos(int x, int y, std::unordered_set<Position> *pns){
|
|
|
|
|
if (is_valid_position(x, y)){
|
|
|
|
|
pns->insert(pair_to_pos(x, y));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _get_all_moves_rook(int x, int y, std::unordered_set<Position> *pns){
|
|
|
|
|
for (int offset=1; offset<8; offset++){
|
|
|
|
|
int xpoff = x+offset;
|
|
|
|
|
int ypoff = y+offset;
|
|
|
|
|
int xnoff = x-offset;
|
|
|
|
|
int ynoff = y-offset;
|
|
|
|
|
_push_if_valid_pos(xpoff, y, pns);
|
|
|
|
|
_push_if_valid_pos(x, ypoff, pns);
|
|
|
|
|
_push_if_valid_pos(xnoff, y, pns);
|
|
|
|
|
_push_if_valid_pos(x, ynoff, pns);
|
|
|
|
|
_push_if_valid_pos(x+offset, y, pns);
|
|
|
|
|
_push_if_valid_pos(x, y+offset, pns);
|
|
|
|
|
_push_if_valid_pos(x-offset, y, pns);
|
|
|
|
|
_push_if_valid_pos(x, y-offset, pns);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _get_all_moves_bishop(int x, int y, std::unordered_set<Position> *pns){
|
|
|
|
|
for (int offset=1; offset<8; offset++){
|
|
|
|
|
int xpoff = x+offset;
|
|
|
|
|