]> git.sesse.net Git - stockfish/commitdiff
Avoid a tricky line in shelter_storm()
authorMarco Costalba <mcostalba@gmail.com>
Sat, 23 Feb 2013 18:27:32 +0000 (19:27 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 23 Feb 2013 18:27:32 +0000 (19:27 +0100)
kf = (kf == FILE_A) ? kf++ : ....

is tricky becuase kf is updated twice and it happens
to do the right thing just by accident.

Rewrite in a better way.

Spotted by pdimov

No functional change.

src/pawns.cpp

index fca33f281a2bb69c6641d6f0c519b50a40c9dadf..c1a93169bd7e394f3b3abffb1234a122864e479d 100644 (file)
@@ -231,7 +231,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
   Rank rkUs, rkThem;
   File kf = file_of(ksq);
 
-  kf = (kf == FILE_A) ? kf++ : (kf == FILE_H) ? kf-- : kf;
+  kf = (kf == FILE_A) ? FILE_B : (kf == FILE_H) ? FILE_G : kf;
 
   for (int f = kf - 1; f <= kf + 1; f++)
   {