Followers 0

Negamax AI and staying on the same turn

26 posts in this topic

I would describe the position with two bitboards (White, Black) and two magic sums. It might be reasonable to also have other bitboards that you might use often, like empties, so you don't keep recomputing them in different parts of the program (this happens in chess; not sure if it's worth it in this case).

About the 2 small problems you can't figure out, this code solves them:

#include <cstdio>

int main() {
// These are numbers like magic sums, designed so every combination
// of white and black occupation is tested
long white = 0x0000000123012010l;
long black = 0x0000000000111223l;

// White's count ends in "10" while black's count ends in "0"
long white_blocked_mills = ~white & (white>>1) & black & 0x1111111111111111l;

// White's count ends in "10" while black's count ends in "1"
long white_open_mills = ~white & (white>>1) & ~black & 0x1111111111111111l;

std::printf("%016lx\n", white);
std::printf("%016lx\n", black);
std::printf("%016lx\n", white_blocked_mills);
std::printf("%016lx\n", white_open_mills);
}

[EDIT: I found an easier way to code it than what I originally posted.] Edited by Álvaro
0

Share on other sites

Thanks. That will help!!

0

Create an account

Register a new account