Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualÁlvaro

Posted 15 March 2013 - 09:03 AM

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.]

#7Álvaro

Posted 15 March 2013 - 09:02 AM

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 = 0x0123012010l;
  long black = 0x0000111223l;

  // 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.]

#6Álvaro

Posted 15 March 2013 - 08:58 AM

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>

typedef unsigned long u64;

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

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

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

  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.]

#5Álvaro

Posted 15 March 2013 - 08:57 AM

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>

typedef unsigned long u64;

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

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

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

  std::printf("6lx\n", white);
  std::printf("6lx\n", black);
  std::printf("6lx\n", white_blocked_mills);
  std::printf("6lx\n", white_open_mills);
}
[EDIT: I found an easier way to code it than what I originally posted.]

#4Álvaro

Posted 15 March 2013 - 08:57 AM

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 it:
 
#include <cstdio>

typedef unsigned long u64;

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

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

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

  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.]

#3Álvaro

Posted 15 March 2013 - 08:56 AM

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 it:
 
#include <cstdio>

typedef unsigned long long u64;

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

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

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

  std::printf("6llx\n", white);
  std::printf("6llx\n", black);
  std::printf("6llx\n", white_blocked_mills);
  std::printf("6llx\n", white_open_mills);
}
[EDIT: I found an easier way to code it than what I originally posted.]

PARTNERS