Make unordered_sets unto vectors

master
Tait Hoyem 5 years ago
parent 52ec82f7df
commit 16add284ef

@ -1,5 +1,5 @@
#include "constants.h"
#include <unordered_set>
#include <vector>
#include <array>
#include <iostream>
@ -23,7 +23,7 @@ Color _rev_color(Color c){
}
// This function will set the boolean guarding it to false if it is blocked, thus stopping it from running.
void _add_if_not_blocked(int pos, int from, std::unordered_set<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite, bool *is_not_blocked){
void _add_if_not_blocked(int pos, int from, std::vector<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite, bool *is_not_blocked){
if (*is_not_blocked){
if (!is_valid_position(pos)){
*is_not_blocked = false;
@ -31,47 +31,47 @@ void _add_if_not_blocked(int pos, int from, std::unordered_set<int> *pns, std::a
if (_xy_is_color(pos, board, color_of_piece)){
*is_not_blocked = false;
} else if (_xy_is_color(pos, board, color_of_opposite)){
pns->insert(make_move(from, pos));
pns->push_back(make_move(from, pos));
*is_not_blocked = false;
} else {
pns->insert(make_move(from, pos));
pns->push_back(make_move(from, pos));
}
}
}
}
// This function is for non-ray types only, as it ignores the 'ray rules', and just jumps over stuff (e.g. knight), or only moves one space generally (e.g. king)
void _add_if_not_blocked(int pos, int from, std::unordered_set<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite){
void _add_if_not_blocked(int pos, int from, std::vector<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite){
if (!is_valid_position(pos) ||
_xy_is_color(pos, board, color_of_piece)){
return;
} else {
pns->insert(make_move(from, pos));
pns->push_back(make_move(from, pos));
}
}
// This is a specialized function for the pawn's diagonal takes.
// It will only to pns if there is a piece of opposite color on it.
void _pawn_diag_add_if_not_blocked(int pos, int from, std::unordered_set<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite, int en_passant){
void _pawn_diag_add_if_not_blocked(int pos, int from, std::vector<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite, int en_passant){
if (is_valid_position(pos) && (_xy_is_color(pos, board, color_of_opposite) ||
pos == en_passant)){
pns->insert(make_move(from, pos));
pns->push_back(make_move(from, pos));
}
}
// This is a specialized functions for the pawn's inability to take going forward.
// Notice the lack of insertion where there usually is when (x,y) is a different color.
void _pawn_add_if_not_blocked(int pos, int from, std::unordered_set<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite, bool *is_not_blocked){
// Notice the lack of push_backion where there usually is when (x,y) is a different color.
void _pawn_add_if_not_blocked(int pos, int from, std::vector<int> *pns, std::array<PieceType, 120> *board, Color color_of_piece, Color color_of_opposite, bool *is_not_blocked){
if (*is_not_blocked){
if ((*board)[pos] != PieceType::NONE ||
(*board)[pos] == PieceType::INV){
*is_not_blocked = false;
} else {
pns->insert(make_move(from, pos));
pns->push_back(make_move(from, pos));
}
}
}
void _get_all_moves_rook(int pos, std::unordered_set<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
void _get_all_moves_rook(int pos, std::vector<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
for (int rk_off : ROOK_PIECE_OFFSETS){
bool* not_blocked = new bool(true);
for (int offset=1; offset<8; offset++){
@ -93,7 +93,7 @@ void _get_all_moves_rook(int pos, std::unordered_set<int> *pns, std::array<Piece
*/
}
void _get_all_moves_bishop(int pos, std::unordered_set<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
void _get_all_moves_bishop(int pos, std::vector<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
for (int bs_off : BISHOP_PIECE_OFFSETS){
bool* not_blocked = new bool(true);
for (int offset=1; offset<8; offset++){
@ -118,7 +118,7 @@ void _get_all_moves_bishop(int pos, std::unordered_set<int> *pns, std::array<Pie
}
*/
}
void _get_all_moves_knight(int pos, std::unordered_set<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
void _get_all_moves_knight(int pos, std::vector<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
for (int kn_off : KNIGHT_PIECE_OFFSETS){
bool* not_blocked = new bool(true);
_add_if_not_blocked(pos+kn_off, pos, pns, board, pc, rc);
@ -134,7 +134,7 @@ void _get_all_moves_knight(int pos, std::unordered_set<int> *pns, std::array<Pie
*/
}
void _get_all_moves_king(int pos, std::unordered_set<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
void _get_all_moves_king(int pos, std::vector<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc){
for (int kn_off : KING_PIECE_OFFSETS){
bool* not_blocked = new bool(true);
_add_if_not_blocked(pos+kn_off, pos, pns, board, pc, rc);
@ -153,7 +153,7 @@ void _get_all_moves_king(int pos, std::unordered_set<int> *pns, std::array<Piece
*/
}
void _get_all_moves_pawn(int pos, std::unordered_set<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc, int en_passant){
void _get_all_moves_pawn(int pos, std::vector<int> *pns, std::array<PieceType, 120>* board, Color pc, Color rc, int en_passant){
// if it's white use different offsets, and pawn starting rank
int offset2 = pc==Color::WHITE?-20:20;

@ -2,7 +2,7 @@
#define BITWISE_H
#include "constants.h"
#include <unordered_set>
#include <vector>
// Using macros for ease of use, can also use functons, but I don't see the point.

@ -49,13 +49,13 @@ Color rev_color(Color c){
return c==Color::WHITE?Color::BLACK:Color::WHITE;
}
std::unordered_set<int> get_possible_movers(Position pn, std::array<PieceType, 120> board){
std::unordered_set<int> pns = {Position::A1};
std::vector<int> get_possible_movers(Position pn, std::array<PieceType, 120> board){
std::vector<int> pns = {Position::A1};
return pns;
}
std::unordered_set<int> get_possible_moves(Position pn, std::array<PieceType, 120> board){
std::unordered_set<int> pns = {Position::A1};
std::vector<int> get_possible_moves(Position pn, std::array<PieceType, 120> board){
std::vector<int> pns = {Position::A1};
get_all_moves(pn, &board, &pns);
return pns;
}
@ -69,11 +69,11 @@ int get_pos_of(PieceType pt, std::array<PieceType, 120> const *board){
return Position::NA;
}
std::unordered_set<int> get_poss_of(PieceType pt, std::array<PieceType, 120> const *board){
std::unordered_set<int> results;
std::vector<int> get_poss_of(PieceType pt, std::array<PieceType, 120> const *board){
std::vector<int> results;
for (int pn = Position::A8; pn!=Position::H1; pn++){
if ((*board)[pn] == pt){
results.insert(pn);
results.push_back(pn);
}
}
return results;
@ -88,7 +88,7 @@ void get_poss_of(PieceType pt, std::array<PieceType, 120>* board, std::vector<in
}
//TODO: Make faster by running from king squar eonly, instead of running on every piece of opposite team.
void filter_checked_moves(PieceType pt, std::array<PieceType, 120> *board, std::unordered_set<int> *pns){
void filter_checked_moves(PieceType pt, std::array<PieceType, 120> *board, std::vector<int> *pns){
PieceType my_king = is_white(pt)?PieceType::W_KING:PieceType::B_KING;
int my_king_pos = get_pos_of(my_king, board);
int attackers = 0;
@ -110,7 +110,7 @@ void filter_checked_moves(PieceType pt, std::array<PieceType, 120> *board, std::
std::vector<int> psns;
get_poss_of(other_p, &moved_board, &psns);
for (auto psn : psns){
std::unordered_set<int> other_moves;
std::vector<int> other_moves;
get_all_moves(psn, &moved_board, &other_moves, false);
// for every position the piece can mvoe to
for (int cp : other_moves){
@ -136,7 +136,7 @@ void filter_checked_moves(PieceType pt, std::array<PieceType, 120> *board, std::
}
}
void get_all_moves(int pos, std::array<PieceType, 120>* board, std::unordered_set<int>* moves, bool recursive, int en_passant){
void get_all_moves(int pos, std::array<PieceType, 120>* board, std::vector<int>* moves, bool recursive, int en_passant){
PieceType pt = (*board)[pos];
Color color_of_piece = get_color(pt);
Color color_of_opponent = rev_color(color_of_piece);
@ -174,8 +174,8 @@ void get_all_moves(int pos, std::array<PieceType, 120>* board, std::unordered_se
}
}
std::unordered_set<int> get_all_moves(int pos, std::array<PieceType, 120> board, bool recursive, int en_passant){
std::unordered_set<int> moves;
std::vector<int> get_all_moves(int pos, std::array<PieceType, 120> board, bool recursive, int en_passant){
std::vector<int> moves;
get_all_moves(pos, &board, &moves, recursive, en_passant);
return moves;
}

@ -1,12 +1,12 @@
#include "constants.h"
#include <unordered_set>
#include <vector>
#include <utility>
#include <vector>
#include <math.h>
// Returns a list of positions with PieceType pt
int get_pos_of(PieceType pt, std::array<PieceType, 120> const *board);
std::unordered_set<int> get_poss_of(PieceType pt, std::array<PieceType, 120> const *board);
std::vector<int> get_poss_of(PieceType pt, std::array<PieceType, 120> const *board);
// Convert a Position number into a pair of x y coordiinates
std::pair<int, int> pos_to_pair(Position pn);
@ -32,18 +32,18 @@ Color rev_color(Color c);
// Get all positions of pieces which can move to this square
// This may require helper functions for each individual peice.
// TODO rename to something less stupid.
void get_possible_movers(Position pn, std::array<PieceType, 120> *pt,std::unordered_set<int> *moves);
void get_possible_movers(Position pn, std::array<PieceType, 120> *pt,std::vector<int> *moves);
// Get all possible moved for piece in Position pn.
// This may require helper functions for each individual piece.
void get_possible_moves(Position pn, std::array<PieceType, 120> *pt,std::unordered_set<int> *moves);
void get_possible_moves(Position pn, std::array<PieceType, 120> *pt,std::vector<int> *moves);
// This functions removes moves that put your own king in check.
void filter_checked_moves(int pos, std::array<PieceType, 120> *board, std::unordered_set<int> *moves);
void filter_checked_moves(int pos, std::array<PieceType, 120> *board, std::vector<int> *moves);
// Get all moves for piece in Position pn.
void get_all_moves(int pos, std::array<PieceType, 120> *pt,std::unordered_set<int> *moves, bool recursive=true, int en_passant=Position::NA);
std::unordered_set<int> get_all_moves(int pos, std::array<PieceType, 120> board, bool recursive=true, int en_passant=Position::NA);
void get_all_moves(int pos, std::array<PieceType, 120> *pt,std::vector<int> *moves, bool recursive=true, int en_passant=Position::NA);
std::vector<int> get_all_moves(int pos, std::array<PieceType, 120> board, bool recursive=true, int en_passant=Position::NA);
// Dumb function to do board moves.
// Does not check if move is valid, just does it.

@ -1,4 +1,4 @@
#include <unordered_set>
#include <vector>
#include <constants.h>
const int B_QUEEN_POS = E4;
@ -17,7 +17,7 @@ const std::array<PieceType, 120> B_QUEEN_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_QUEEN_ALL_MOVES = {
const std::vector<int> B_QUEEN_ALL_MOVES = {
A8, E8,
B7, E7, H7,
C6, E6, G6,
@ -44,7 +44,7 @@ const std::array<PieceType, 120> B_BISHOP_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_BISHOP_ALL_MOVES = {
const std::vector<int> B_BISHOP_ALL_MOVES = {
H8,
A7, G7,
B6, F6,
@ -70,7 +70,7 @@ const std::array<PieceType, 120> B_KNIGHT_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_KNIGHT_ALL_MOVES = {
const std::vector<int> B_KNIGHT_ALL_MOVES = {
C7, E7,
B6, F6,
B4, F4,
@ -93,7 +93,7 @@ const std::array<PieceType, 120> B_ROOK_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_ROOK_ALL_MOVES = {
const std::vector<int> B_ROOK_ALL_MOVES = {
E8, E7, E6,
A5, B5, C5, D5, F5, G5, H5,
E4, E3, E2, E1
@ -116,7 +116,7 @@ const std::array<PieceType, 120> B_KING_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_KING_ALL_MOVES = {
const std::vector<int> B_KING_ALL_MOVES = {
B5, C5, D5,
B4, D4,
B3, C3, D3
@ -139,7 +139,7 @@ const std::array<PieceType, 120> B_PAWN_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_PAWN_ALL_MOVES = {
const std::vector<int> B_PAWN_ALL_MOVES = {
F3
};
const int B_KNIGHT_SIDE1_POS = B7;
@ -157,7 +157,7 @@ const std::array<PieceType, 120> B_KNIGHT_SIDE1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_KNIGHT_SIDE1_ALL_MOVES = {
const std::vector<int> B_KNIGHT_SIDE1_ALL_MOVES = {
D8,
D6,
A5, C5
@ -177,7 +177,7 @@ const std::array<PieceType, 120> B_KING_SIDE1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_KING_SIDE1_ALL_MOVES = {
const std::vector<int> B_KING_SIDE1_ALL_MOVES = {
B8,
A7,B7
};
@ -197,6 +197,6 @@ const std::array<PieceType, 120> B_PAWN_SIDE1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> B_PAWN_SIDE1_ALL_MOVES = {
const std::vector<int> B_PAWN_SIDE1_ALL_MOVES = {
A6, A5
};

@ -1,4 +1,4 @@
#include <unordered_set>
#include <vector>
#include <constants.h>
const int W_QUEEN_POS = E4;
@ -32,7 +32,7 @@ const std::array<PieceType, 120> W_QUEEN_BOARD_BLOCKED = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> W_QUEEN_ALL_MOVES = {
const std::vector<int> W_QUEEN_ALL_MOVES = {
A8, E8,
B7, E7, H7,
C6, E6, G6,
@ -59,7 +59,7 @@ const std::array<PieceType, 120> W_BISHOP_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> W_BISHOP_ALL_MOVES = {
const std::vector<int> W_BISHOP_ALL_MOVES = {
H8,
A7, G7,
B6, F6,
@ -100,13 +100,13 @@ const std::array<PieceType, 120> W_KNIGHT_SIDE1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> W_KNIGHT_SIDE1_ALL_MOVES = {
const std::vector<int> W_KNIGHT_SIDE1_ALL_MOVES = {
D8,
D6,
A5, C5
};
const std::unordered_set<int> W_KNIGHT_ALL_MOVES = {
const std::vector<int> W_KNIGHT_ALL_MOVES = {
C7, E7,
B6, F6,
B4, F4,
@ -129,7 +129,7 @@ const std::array<PieceType, 120> W_ROOK_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> W_ROOK_ALL_MOVES = {
const std::vector<int> W_ROOK_ALL_MOVES = {
E8, E7, E6,
A5, B5, C5, D5, F5, G5, H5,
E4, E3, E2, E1
@ -168,12 +168,12 @@ const std::array<PieceType, 120> W_KING_SIDE1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> W_KING_SIDE1_ALL_MOVES = {
const std::vector<int> W_KING_SIDE1_ALL_MOVES = {
B8,
A7,B7
};
const std::unordered_set<int> W_KING_ALL_MOVES = {
const std::vector<int> W_KING_ALL_MOVES = {
B5, C5, D5,
B4, D4,
B3, C3, D3
@ -196,7 +196,7 @@ const std::array<PieceType, 120> W_PAWN_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> W_PAWN_ALL_MOVES = {
const std::vector<int> W_PAWN_ALL_MOVES = {
F5
};
@ -215,4 +215,4 @@ const std::array<PieceType, 120> W_PAWN_SIDE1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> W_PAWN_SIDE1_ALL_MOVES;
const std::vector<int> W_PAWN_SIDE1_ALL_MOVES;

@ -1,7 +1,7 @@
#include "catch.hpp"
#include <constants.h>
#include <sstream>
#include <unordered_set>
#include <vector>
// override default printing for Positions so it prints the value (e.g. 32), then, in parenthasies, the location (e.g. A4).
// Example: A4(32)
@ -44,8 +44,8 @@ namespace Catch {
};
// This overrides vectors of positions. I want it to print a board with the positions that are selected so we can see a representation of what positions are selected.
template<>
struct StringMaker<std::unordered_set<int>> {
static std::string convert(std::unordered_set<int> const& uo_poss){
struct StringMaker<std::vector<int>> {
static std::string convert(std::vector<int> const& uo_poss){
std::vector<int> poss(uo_poss.begin(), uo_poss.end());
std::stringstream ss;
std::string files = " A B C D E F G H";

@ -22,8 +22,8 @@ const std::array<PieceType, 120> DUMB_MOVE_1 = {
};
TEST_CASE("Test that the get_to_squares works, this is required!", "[get_to_squares]"){
std::unordered_set<int> to_squares = {Position::H1};
std::unordered_set<int> moves = {0b11000100000000};
std::vector<int> to_squares = {Position::H1};
std::vector<int> moves = {0b11000100000000};
REQUIRE(get_to_squares(moves) == to_squares);
}
@ -107,7 +107,7 @@ TEST_CASE("Test that moves that put king in check are not returned", "[get_all_m
CHECK(get_to_squares(get_all_moves(ROOK_CHECK_TEST_POS, ROOK_CHECK_TEST_BOARD)) == ROOK_CHECK_TEST_MOVES);
CHECK(get_to_squares(get_all_moves(PAWN_CHECK_TEST_POS, PAWN_CHECK_TEST_BOARD)) == PAWN_CHECK_TEST_MOVES);
auto pawn_diag_moves = get_all_moves(PAWN_DIAG_TEST1_POS, PAWN_DIAG_TEST1_BOARD);
std::unordered_set<int> pawn_start_flags = {0, 1, 0};
std::vector<int> pawn_start_flags = {0, 1, 0};
CHECK(get_to_squares(pawn_diag_moves) == PAWN_DIAG_TEST1_MOVES);
CHECK(get_pawn_start_flags(pawn_diag_moves) == pawn_start_flags);
}

@ -1,55 +1,55 @@
#include "test_functions.h"
#include <bitwise.h>
#include <unordered_set>
#include <vector>
#include <algorithm>
std::unordered_set<int> get_to_squares(std::unordered_set<int> moves){
std::unordered_set<int> transformed;
std::vector<int> get_to_squares(std::vector<int> moves){
std::vector<int> transformed;
for (int mv : moves){
transformed.insert(get_to_sq(mv));
transformed.push_back(get_to_sq(mv));
}
return transformed;
}
std::unordered_set<int> get_from_squared(std::unordered_set<int> moves){
std::unordered_set<int> transformed;
std::vector<int> get_from_squared(std::vector<int> moves){
std::vector<int> transformed;
for (int mv : moves){
transformed.insert(get_from_sq(mv));
transformed.push_back(get_from_sq(mv));
}
return transformed;
}
std::unordered_set<int> get_captured_pieces(std::unordered_set<int> moves){
std::unordered_set<int> transformed;
std::vector<int> get_captured_pieces(std::vector<int> moves){
std::vector<int> transformed;
for (int mv : moves){
transformed.insert(get_captured_pc(mv));
transformed.push_back(get_captured_pc(mv));
}
return transformed;
}
std::unordered_set<int> get_promoted_pieces(std::unordered_set<int> moves){
std::unordered_set<int> transformed;
std::vector<int> get_promoted_pieces(std::vector<int> moves){
std::vector<int> transformed;
for (int mv : moves){
transformed.insert(get_promoted_to_pc(mv));
transformed.push_back(get_promoted_to_pc(mv));
}
return transformed;
}
std::unordered_set<int> get_en_passant_flags(std::unordered_set<int> moves){
std::unordered_set<int> transformed;
std::vector<int> get_en_passant_flags(std::vector<int> moves){
std::vector<int> transformed;
for (int mv : moves){
transformed.insert(get_en_pass_flag(mv));
transformed.push_back(get_en_pass_flag(mv));
}
return transformed;
}
std::unordered_set<int> get_pawn_start_flags(std::unordered_set<int> moves){
std::unordered_set<int> transformed;
std::vector<int> get_pawn_start_flags(std::vector<int> moves){
std::vector<int> transformed;
for (int mv : moves){
std::cout << "MOVE: \n";
transformed.insert(get_pawn_st_flag(mv));
transformed.push_back(get_pawn_st_flag(mv));
}
return transformed;
}
std::unordered_set<int> get_castle_flags(std::unordered_set<int> moves){
std::unordered_set<int> transformed;
std::vector<int> get_castle_flags(std::vector<int> moves){
std::vector<int> transformed;
for (int mv : moves){
transformed.insert(get_castle_flag(mv));
transformed.push_back(get_castle_flag(mv));
}
return transformed;
}

@ -1,12 +1,12 @@
#ifndef TEST_FUNCTIONS_H
#define TEST_FUNCTOPMS_H
#include <unordered_set>
#include <vector>
std::unordered_set<int> get_from_squares(std::unordered_set<int> moves);
std::unordered_set<int> get_to_squares(std::unordered_set<int> moves);
std::unordered_set<int> get_captured_pieces(std::unordered_set<int> moves);
std::unordered_set<int> get_promoted_pieces(std::unordered_set<int> moves);
std::unordered_set<int> get_en_passant_flags(std::unordered_set<int> moves);
std::unordered_set<int> get_pawn_start_flags(std::unordered_set<int> moves);
std::unordered_set<int> get_castle_flags(std::unordered_set<int> moves);
std::vector<int> get_from_squares(std::vector<int> moves);
std::vector<int> get_to_squares(std::vector<int> moves);
std::vector<int> get_captured_pieces(std::vector<int> moves);
std::vector<int> get_promoted_pieces(std::vector<int> moves);
std::vector<int> get_en_passant_flags(std::vector<int> moves);
std::vector<int> get_pawn_start_flags(std::vector<int> moves);
std::vector<int> get_castle_flags(std::vector<int> moves);
#endif

@ -1,21 +1,21 @@
#include <unordered_set>
#include <vector>
#include <constants.h>
/// This is for possible moves on a default board
const std::unordered_set<int> DEFAULT_B_A_PAWN_POSSIBLE_MOVES = {
const std::vector<int> DEFAULT_B_A_PAWN_POSSIBLE_MOVES = {
A6, A5
};
const std::unordered_set<int> DEFAULT_W_A_PAWN_POSSIBLE_MOVES = {
const std::vector<int> DEFAULT_W_A_PAWN_POSSIBLE_MOVES = {
A3, A4
};
const std::unordered_set<int> DEFAULT_W_R_KNIGHT_POSSIBLE_MOVES = {
const std::vector<int> DEFAULT_W_R_KNIGHT_POSSIBLE_MOVES = {
H3, F3
};
// EMPTY
const std::unordered_set<int> DEFAULT_W_R_ROOK_POSSIBLE_MOVES = {};
const std::vector<int> DEFAULT_W_R_ROOK_POSSIBLE_MOVES = {};
const std::unordered_set<int> B_PAWNS_SQUARES = {
const std::vector<int> B_PAWNS_SQUARES = {
A7, B7, C7, D7, E7, F7, G7, H7
};
@ -37,7 +37,7 @@ const std::array<PieceType, 120> KNIGHT_BLOCKED1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
// Should NOT inclde D7
const std::unordered_set<int> KNIGHT_BLOCKED1_MOVES = {
const std::vector<int> KNIGHT_BLOCKED1_MOVES = {
A6, C6
};
@ -57,7 +57,7 @@ const std::array<PieceType, 120> BISHOP_BLOCKED1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
// Should NOT include A8, H8, G2, or H1
const std::unordered_set<int> BISHOP_BLOCKED1_MOVES = {
const std::vector<int> BISHOP_BLOCKED1_MOVES = {
B7,
C6,E6,
C4,E4,
@ -65,7 +65,7 @@ const std::unordered_set<int> BISHOP_BLOCKED1_MOVES = {
A2
};
// Should NOT include B2 (black queen) as it is obstructed by the bishop on D5
const std::unordered_set<int> BISHOP_BLOCKED1_CAN_MOVE_TO_B_KING = {
const std::vector<int> BISHOP_BLOCKED1_CAN_MOVE_TO_B_KING = {
D5
};
const int BISHOP_BLOCKED1_KING_POS = F3;
@ -87,7 +87,7 @@ const std::array<PieceType, 120> ROOK_BLOCKED1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
// Should NOT include E-H2 or B3-1
const std::unordered_set<int> ROOK_BLOCKED1_MOVES = {
const std::vector<int> ROOK_BLOCKED1_MOVES = {
B8,
A7, C7, D7,
B6,B5,B4
@ -108,7 +108,7 @@ const std::array<PieceType, 120> PAWN_DIAG_TEST1_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> PAWN_DIAG_TEST1_MOVES = {
const std::vector<int> PAWN_DIAG_TEST1_MOVES = {
D6, E6, E5
};
@ -128,7 +128,7 @@ const std::array<PieceType, 120> ROOK_CHECK_TEST_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> ROOK_CHECK_TEST_MOVES = {
const std::vector<int> ROOK_CHECK_TEST_MOVES = {
C5, E5
};
@ -147,7 +147,7 @@ const std::array<PieceType, 120> PAWN_CHECK_TEST_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> PAWN_CHECK_TEST_MOVES = {E6, E5};
const std::vector<int> PAWN_CHECK_TEST_MOVES = {E6, E5};
// These boards tests for en pessent squares.
@ -167,7 +167,7 @@ const std::array<PieceType, 120> EN_PASSANT_TEST_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> EN_PASSANT_TEST_MOVES = {
const std::vector<int> EN_PASSANT_TEST_MOVES = {
E6, D6
};
@ -186,4 +186,4 @@ const std::array<PieceType, 120> NO_EN_PASSANT_TEST_BOARD = {
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
};
const std::unordered_set<int> NO_EN_PASSANT_TEST_MOVES = {D6};
const std::vector<int> NO_EN_PASSANT_TEST_MOVES = {D6};

Loading…
Cancel
Save