ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

see
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
Sven Schüle



Joined: 15 May 2008
Posts: 3478
Location: Berlin, Germany

PostPost subject: Re: see    Posted: Wed Nov 29, 2017 8:49 pm Reply to topic Reply with quote

flok wrote:
Code:
// xy are of the victim
int Scene::getSEE(const int x, const int y, const ChessPiece *const attacker) const
{
   const ChessPiece *const victim = b.getAt(x, y);

   const PlayerColor c = attacker -> getColor();

   // bit 0...15: if set, then a white piece can walk over and/or attack this field, 16...31 black
   const uint32_t bits = ss.back().tcs.cells[y][x];

   int see_val = victim -> getEvalVal();
   int trophy_val = attacker -> getEvalVal();

   PlayerColor sc = opponentColor(c);
   int so[] = { 0, 16 }; // where to start to search in the bit pattern. so[0] is for white
   constexpr int soe[] = { 16, 32 }; // where to stop searching. soe[0] is for white

   for(; so[sc] < soe[sc];) {
      // find a 1 bit
      while((bits & (1 << so[sc])) == 0) {
         // if end of pattern, stop searching
         if (++so[sc] == soe[sc])
            break;
      }

      if (so[sc] >= soe[sc])
         break;

      if (sc == c)
         see_val += trophy_val;
      else
         see_val -= trophy_val;

      // get eval val. bit number is an index in pieces[color][index] pointing to the
      // piece.
      trophy_val = sc == WHITE ? pieces[sc][so[sc]] -> getEvalVal() : pieces[sc][so[sc] - 16] -> getEvalVal();

      // on to the next bit!
      so[sc]++;

      sc = opponentColor(sc);
   }

   return see_val;
}

I think this is not a correct SEE implementation. Whenever you find a new attacker for the target square you always have the choice between "making the capture" and "standing pat" (i.e., doing nothing). So at any point in your loop over pieces attacking the target square (not just in the root!) you would have to calculate the outcome of the capture but then ignore it if it loses material (so in fact you would also need to modify your algorithm). Just like in QS. What you seem to do in the code shown above is to always make the capture with the lowest remaining attacker, until no more attackers are left. But that is incorrect because it does not consider standing pat. For instance if the last enemy piece that did a capture was a knight and your next attacker is a queen but the enemy has another knight as attacker (defender) then you must detect that QxN NxQ is worse than not capturing.

It is slightly harder to do that correctly with an iterative algorithm compared to the very simple recursive one, but of course it is possible (by definition).
Back to top
View user's profile Send private message
Display posts from previous:   
Subject Author Date/Time
see Folkert van Heusden Tue Nov 28, 2017 1:11 pm
      Re: see Álvaro Begué Tue Nov 28, 2017 1:30 pm
            Re: see Folkert van Heusden Tue Nov 28, 2017 1:38 pm
                  Re: see Tamás Kuzmics Tue Nov 28, 2017 1:43 pm
                  Re: see Álvaro Begué Tue Nov 28, 2017 1:49 pm
      Re: see Tamás Kuzmics Tue Nov 28, 2017 1:32 pm
      Re: see Marco Belli Tue Nov 28, 2017 3:26 pm
            Re: see Álvaro Begué Tue Nov 28, 2017 3:58 pm
                  Re: see Marco Belli Tue Nov 28, 2017 4:35 pm
                        Re: see Folkert van Heusden Tue Nov 28, 2017 7:34 pm
                              Re: see Peter Österlund Tue Nov 28, 2017 8:11 pm
      Re: see Steve Maughan Tue Nov 28, 2017 9:36 pm
            Re: see Folkert van Heusden Wed Nov 29, 2017 5:03 pm
                  Re: see Steve Maughan Wed Nov 29, 2017 5:16 pm
                  Re: see Sven Schüle Wed Nov 29, 2017 8:49 pm
                        Re: see Álvaro Begué Wed Nov 29, 2017 9:00 pm
                        Re: see laurie tunnicliffe Thu Nov 30, 2017 2:01 am
                              Re: see Álvaro Begué Thu Nov 30, 2017 5:07 am
                                    Re: see laurie tunnicliffe Thu Nov 30, 2017 5:43 am
                                          Re: see Álvaro Begué Thu Nov 30, 2017 11:47 am
                                                Re: see Richard Delorme Thu Nov 30, 2017 12:44 pm
      Re: see Maarten Claessens Wed Nov 29, 2017 9:11 am
            Re: see Folkert van Heusden Wed Nov 29, 2017 9:20 am
                  Re: see Marco Belli Wed Nov 29, 2017 9:50 am
                        Re: see Folkert van Heusden Wed Nov 29, 2017 2:00 pm
                  Re: see Maarten Claessens Wed Nov 29, 2017 10:34 am
                  Re: see Álvaro Begué Wed Nov 29, 2017 11:33 am
      Re: see Tony Soares Fri Dec 01, 2017 10:51 am
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
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




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads