• Advertisement
Sign in to follow this  

Negamax AI and staying on the same turn

This topic is 1774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Sign in to follow this  

  • Advertisement