TalkChess.com
Hosted by Your Move Chess & Games

Author Message
H.G.Muller

Joined: 10 Mar 2006
Posts: 22012
Location: Amsterdam

Post subject: Re: How to implement KPK ?    Posted: Thu Mar 21, 2013 10:33 am

The white pass and black pass look very similar, so perhaps it is more elegant to merge them into one routine:

 Code: void Pass (int stm) {   int wk, bk, p, d;   for(wk=0; wk<64; wk++) for(bk=0; bk<64; bk++) for(p=0; p<64; p++) {     int k = stm == WTM ? wk : bk     int O88 = (k & 070) + k; // 0x88 square number of King     if(dtc[stm][wk][p][bk]) continue; // already decided     dtc[stm][wk][p][bk] = stm;  // assume lost if btm, undecided if wtm     if(bk != p && stm == WTM) { // pawn not captured, so can move       if(p+8 != bk && dtc[BTM][wk][p+8][bk] > 0)  { dtc[WTM][wk][p][bk] = 1; continue; }       if(p+7 == bk && (p & 7) != 0)  { dtc[WTM][wk][p][bk] = 1; continue; }       if(p+9 == bk && (p & 7) != 7)  { dtc[WTM][wk][p][bk] = 1; continue; }     }     for(d=0; d<8; d++) {       int to = O88 + steps[d];       if(to & 0x88) continue; // off board       if(stm == WTM ? dtc[BTM][to][p][bk] > 0 : dtc[WTM][wk][p][to] > 0)       { dtc[stm][wk][p][bk] = !stm; break; }     }   } } void Build () {   int i;   Init();   for(i=0; i<100; i++) // won't take more than 100 moves     Pass(WTM), Pass(BTM);   Pack(); }

I guess the bk == p positions should be set to -1 in Init(), and not to 1; the Pass() code does not ever test the state of the daughter position in dtc when it captures the black King with a Pawn, but just assigns a win. So the only testing of this position that ever is important is when the black King stepped onto the Pawn, whether on the previous ply or longer before that. The btm cases have to be marked as draw, to prevent black being forced to 'step off' the Pawn again by zugzwang when white does not have a King move to capture the black King, and tries another one.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
Subject Author Date/Time
Chan Rasjid Thu Mar 21, 2013 3:43 am
H.G.Muller Thu Mar 21, 2013 7:46 am
Chan Rasjid Thu Mar 21, 2013 8:27 am
H.G.Muller Thu Mar 21, 2013 10:07 am
Re: How to implement KPK ? H.G.Muller Thu Mar 21, 2013 10:33 am
Chan Rasjid Thu Mar 21, 2013 6:10 pm
Don Dailey Tue Apr 02, 2013 6:56 pm
Lucas Braesch Thu Mar 21, 2013 11:03 am
H.G.Muller Thu Mar 21, 2013 11:52 am
Lucas Braesch Thu Mar 21, 2013 12:04 pm
H.G.Muller Thu Mar 21, 2013 6:36 pm
H.G.Muller Thu Mar 21, 2013 9:00 pm
Chan Rasjid Sat Mar 30, 2013 8:15 am
Evert Glebbeek Sat Mar 30, 2013 8:42 am
Sven Schüle Sat Mar 30, 2013 12:12 pm
Chan Rasjid Sat Mar 30, 2013 12:20 pm
Sven Schüle Sat Mar 30, 2013 12:42 pm
Chan Rasjid Sat Mar 30, 2013 2:03 pm
Sven Schüle Sat Mar 30, 2013 6:29 pm
Wylie Garvin Sat Mar 30, 2013 12:50 pm
Chan Rasjid Sat Mar 30, 2013 1:53 pm
Evert Glebbeek Sat Mar 30, 2013 2:03 pm
H.G.Muller Sat Mar 30, 2013 2:26 pm
Sven Schüle Sat Mar 30, 2013 6:38 pm
H.G.Muller Sat Mar 30, 2013 8:13 pm
Sven Schüle Sat Mar 30, 2013 8:58 pm
H.G.Muller Sat Mar 30, 2013 10:58 pm
Sven Schüle Sat Mar 30, 2013 11:51 pm
H.G.Muller Sun Mar 31, 2013 7:35 am
Sven Schüle Sun Mar 31, 2013 9:02 am
H.G.Muller Sun Mar 31, 2013 9:09 am
Sven Schüle Sun Mar 31, 2013 9:13 am
Steven Edwards Mon May 13, 2013 2:14 am
Don Dailey Mon May 13, 2013 2:20 am
Chan Rasjid Sat Mar 30, 2013 12:18 pm
H.G.Muller Sat Mar 30, 2013 9:08 am
Chan Rasjid Sun May 12, 2013 10:27 pm
Ronald de Man Sun May 12, 2013 11:11 pm
Chan Rasjid Mon May 13, 2013 7:39 am
Don Dailey Mon May 13, 2013 2:14 am
Steven Edwards Tue May 14, 2013 7:19 am
Chan Rasjid Tue May 14, 2013 2:45 pm
Chan Rasjid Tue May 14, 2013 2:50 pm

 Jump to: Select a forum Computer Chess Club Forums----------------Computer Chess Club: General TopicsComputer Chess Club: Tournaments and MatchesComputer Chess Club: Programming and Technical DiscussionsComputer Chess Club: Engine Origins Other Forums----------------Chess Thinkers ForumChess Players ForumForum Help and Suggestions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum