本文整理汇总了C++中Stone::getBitBoard方法的典型用法代码示例。如果您正苦于以下问题:C++ Stone::getBitBoard方法的具体用法?C++ Stone::getBitBoard怎么用?C++ Stone::getBitBoard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stone
的用法示例。
在下文中一共展示了Stone::getBitBoard方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkNotCollideAndContact
bool Ground::checkNotCollideAndContact(Stone &stone_to_arrange, int bx, int by) {
// speed-up: int gx = bx / BOARD_WIDTH, gy = by / BOARD_HEIGHT;
int gx = bx >> 3, gy = by >> 3;
// speed-up: int remx = bx % BOARD_WIDTH, remy = by % BOARD_HEIGHT;
int remx = bx & 7, remy = by & 7;
BitBoard arrange = stone_to_arrange.getBitBoard();
BitBoard current = shiftDown(shiftRight(arrange, remx), remy);
BitBoard right = shiftDown(shiftLeft(arrange, BOARD_WIDTH - remx), remy);
BitBoard bottom = shiftUp(shiftRight(arrange, remx), BOARD_HEIGHT - remy);
BitBoard right_bottom = shiftUp(shiftLeft(arrange, BOARD_WIDTH - remx), BOARD_HEIGHT - remy);
int c_idx = gy * GROUND_BITBOARD_WIDTH + gx;
int r_idx = gy * GROUND_BITBOARD_WIDTH + gx + 1;
int b_idx = (gy + 1) * GROUND_BITBOARD_WIDTH + gx;
int rb_idx = (gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1;
bool collide = (_obstacle[c_idx] & current)
|| (_obstacle[r_idx] & right)
|| (_obstacle[b_idx] & bottom)
|| (_obstacle[rb_idx] & right_bottom);
bool contact = (_contact[c_idx] & current)
|| (_contact[r_idx] & right)
|| (_contact[b_idx] & bottom)
|| (_contact[rb_idx] & right_bottom);
return !collide && contact;
}
示例2: calculateNumBlockInNeumannNeighborhood
int Ground::calculateNumBlockInNeumannNeighborhood(Stone &stone_to_arrange, int bx, int by) {
// speed-up: int gx = bx / BOARD_WIDTH, gy = by / BOARD_HEIGHT;
int gx = bx >> 3, gy = by >> 3;
// speed-up: int remx = bx % BOARD_WIDTH, remy = by % BOARD_HEIGHT;
int remx = bx & 7ull, remy = by & 7ull;
BitBoard arrange = stone_to_arrange.getBitBoard();
BitBoard current = shiftDown(shiftRight(arrange, remx), remy);
BitBoard right = shiftDown(shiftLeft(arrange, BOARD_WIDTH - remx), remy);
BitBoard bottom = shiftUp(shiftRight(arrange, remx), BOARD_HEIGHT - remy);
BitBoard right_bottom = shiftUp(shiftLeft(arrange, BOARD_WIDTH - remx), BOARD_HEIGHT - remy);
return countBits(_left_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_left_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_left_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_left_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom)
+ countBits(_right_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_right_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_right_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_right_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom)
+ countBits(_top_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_top_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_top_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_top_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom)
+ countBits(_bottom_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_bottom_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_bottom_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_bottom_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom);
}
示例3: arrange
void Ground::arrange(Stone &stone_to_arrange, int bx, int by) {
if (stone_to_arrange.isPassed())
return;
// speed-up: int gx = bx / BOARD_WIDTH, gy = by / BOARD_HEIGHT;
int gx = bx >> 3, gy = by >> 3;
// speed-up: int remx = bx % BOARD_WIDTH, remy = by % BOARD_HEIGHT;
int remx = bx & 7ull, remy = by & 7ull;
BitBoard arrange = stone_to_arrange.getBitBoard();
BitBoard current = shiftDown(shiftRight(arrange, remx), remy);
BitBoard right = shiftDown(shiftLeft(arrange, BOARD_WIDTH - remx), remy);
BitBoard bottom = shiftUp(shiftRight(arrange, remx), BOARD_HEIGHT - remy);
BitBoard right_bottom = shiftUp(shiftLeft(arrange, BOARD_WIDTH - remx), BOARD_HEIGHT - remy);
_obstacle[gy * GROUND_BITBOARD_WIDTH + gx] |= current;
_obstacle[gy * GROUND_BITBOARD_WIDTH + gx + 1] |= right;
_obstacle[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] |= bottom;
_obstacle[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] |= right_bottom;
arrangeContact(_contact, stone_to_arrange.getBitBoard(), bx - 1, by);
arrangeContact(_contact, stone_to_arrange.getBitBoard(), bx, by - 1);
arrangeContact(_contact, stone_to_arrange.getBitBoard(), bx + 1, by);
arrangeContact(_contact, stone_to_arrange.getBitBoard(), bx, by + 1);
arrangeContact(_right_contact, stone_to_arrange.getBitBoard(), bx - 1, by);
arrangeContact(_bottom_contact, stone_to_arrange.getBitBoard(), bx, by - 1);
arrangeContact(_left_contact, stone_to_arrange.getBitBoard(), bx + 1, by);
arrangeContact(_top_contact, stone_to_arrange.getBitBoard(), bx, by + 1);
updateContactAndClosedArray();
}
示例4: contactWithStones
bool Ground::contactWithStones(Stone &stone_to_arrange, int bx, int by) {
// speed-up: int gx = bx / BOARD_WIDTH, gy = by / BOARD_HEIGHT;
int gx = bx >> 3, gy = by >> 3;
// speed-up: int remx = bx % BOARD_WIDTH, remy = by % BOARD_HEIGHT;
int remx = bx & 7, remy = by & 7;
BitBoard arrange = stone_to_arrange.getBitBoard();
BitBoard current = shiftDown(shiftRight(arrange, remx), remy);
BitBoard right = shiftDown(shiftLeft(arrange, BOARD_WIDTH - remx), remy);
BitBoard bottom = shiftUp(shiftRight(arrange, remx), BOARD_HEIGHT - remy);
BitBoard right_bottom = shiftUp(shiftLeft(arrange, BOARD_WIDTH - remx), BOARD_HEIGHT - remy);
return (_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
|| (_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
|| (_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
|| (_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom);
}
示例5: calculateNumBlockInNeumannNeighborhoodWithWeight
int Ground::calculateNumBlockInNeumannNeighborhoodWithWeight(Stone &stone_to_arrange, int bx, int by) {
// speed-up: int gx = bx / BOARD_WIDTH, gy = by / BOARD_HEIGHT;
int gx = bx >> 3, gy = by >> 3;
// speed-up: int remx = bx % BOARD_WIDTH, remy = by % BOARD_HEIGHT;
int remx = bx & 7ull, remy = by & 7ull;
BitBoard arrange = stone_to_arrange.getBitBoard();
BitBoard current = shiftDown(shiftRight(arrange, remx), remy);
BitBoard right = shiftDown(shiftLeft(arrange, BOARD_WIDTH - remx), remy);
BitBoard bottom = shiftUp(shiftRight(arrange, remx), BOARD_HEIGHT - remy);
BitBoard right_bottom = shiftUp(shiftLeft(arrange, BOARD_WIDTH - remx), BOARD_HEIGHT - remy);
int one = countBits(_one_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_one_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_one_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_one_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom);
int corner = countBits(_corner_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_corner_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_corner_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_corner_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom);
int both_side = countBits(_both_side_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_both_side_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_both_side_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_both_side_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom);
int three = countBits(_three_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_three_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_three_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_three_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom);
int four = countBits(_four_contact[gy * GROUND_BITBOARD_WIDTH + gx] & current)
+ countBits(_four_contact[gy * GROUND_BITBOARD_WIDTH + gx + 1] & right)
+ countBits(_four_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx] & bottom)
+ countBits(_four_contact[(gy + 1) * GROUND_BITBOARD_WIDTH + gx + 1] & right_bottom);
return 1 * one + 2 * corner + 2 * both_side + 3 * three + 4 * four;
}