Skip to content

Instantly share code, notes, and snippets.

View void-hoge's full-sized avatar
🤘

voidhoge void-hoge

🤘
  • Pref. Hyogo
View GitHub Profile
uint64 o = (cells[c] & 0x7F7F7F7F7F7F7F7F) << 1,
p = cells[1-c] & 0xFEFEFEFEFEFEFEFE;
uint64 left = (~(p | o) & (p + o)) & 0xFEFEFEFEFEFEFEFE;
typedef int color;
const color white = 0;
const color black = 1;
const color empty = -1;
bool Board::checkError(){
return (~(OR(cells)) != 0);
}
bool Board::isFinish(){
return (~(OR(confirmedCells)) == 0);
}
void Board::set(int coordinate, int c){
for (int i = 0; i < 16; ++i){
cells[i][coordinate] = false;
}
base mask = 0;
int x = coordinate /16, y = coordinate %16, block;
mask |= (xMask << (x*16));
mask |= (yMask << y);
block = (x/4)*4 + y/4;
const base xMask = 0x000000000000ffff;
const base constant = 0x0001000100010001;
const base yMask = (constant << 192) | (constant << 128) | (constant << 64) | constant;
const base constantBlock = 0x000f000f000f000f;
const base blockMask[16] = { ((constantBlock << 0) << 0), ((constantBlock << 4) << 0), ((constantBlock << 8) << 0), ((constantBlock << 12) << 0),
((constantBlock << 0) << 64), ((constantBlock << 4) << 64), ((constantBlock << 8) << 64), ((constantBlock << 12) << 64),
((constantBlock << 0) << 128), ((constantBlock << 4) << 128), ((constantBlock << 8) << 128), ((constantBlock << 12) << 128),
((constantBlock << 0) << 192), ((constantBlock << 4) << 192), ((constantBlock << 8) << 192), ((constantBlock << 12) << 192)};