Sign in to follow this  
cryo75

Negamax AI and staying on the same turn

Recommended Posts

alvaro    21246
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this